Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add fields for ratelimit testing #232

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/components/Blockly/blocks/sensebox-osem.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Blockly.Blocks["sensebox_osem_connection"] = {
this.setColour(getColour().sensebox);
this.appendDummyInput()
.appendField(Blockly.Msg.senseBox_osem_connection)
.appendField( new Blockly.FieldDropdown([[Blockly.Msg.senseBox_osem_host, "opensensemap.org"], [Blockly.Msg.senseBox_osem_host_testing, "testing.opensensemap.org"]]), "HOST")
.appendField("SSL")
.appendField(new Blockly.FieldCheckbox(ssl), "SSL");
this.appendDummyInput()
Expand Down Expand Up @@ -53,6 +54,10 @@ Blockly.Blocks["sensebox_osem_connection"] = {
.setAlign(Blockly.ALIGN_LEFT)
.appendField(Blockly.Msg.senseBox_osem_access_token)
.appendField(new Blockly.FieldTextInput("access_token"), "access_token");
this.appendDummyInput()
.setAlign(Blockly.ALIGN_LEFT)
.appendField(Blockly.Msg.senseBox_osem_xallowtoken)
.appendField(new Blockly.FieldTextInput("ratelimit-token"), "ratelimit-token");
this.appendStatementInput("DO")
.appendField(Blockly.Msg.senseBox_sensor)
.setCheck(null);
Expand Down
8 changes: 5 additions & 3 deletions src/components/Blockly/generator/sensebox-osem.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Blockly.Arduino.sensebox_osem_connection = function (Block) {
var box_id = this.getFieldValue("BoxID");
var branch = Blockly.Arduino.statementToCode(Block, "DO");
var access_token = this.getFieldValue("access_token");
var host = this.getFieldValue("HOST");
var ratelimit_token = this.getFieldValue("ratelimit-token");
var blocks = this.getDescendants();
var type = this.getFieldValue("type");
var ssl = this.getFieldValue("SSL");
Expand All @@ -50,7 +52,7 @@ Blockly.Arduino.sensebox_osem_connection = function (Block) {
Blockly.Arduino.definitions_["SenseBoxID"] =
'const char SENSEBOX_ID [] PROGMEM = "' + box_id + '";';
Blockly.Arduino.definitions_["host"] =
'const char server [] PROGMEM ="ingress.opensensemap.org";';
`const char server [] PROGMEM ="ingress.${host}";`;
if (wifi === true) {
if (ssl === "TRUE") {
Blockly.Arduino.libraries_["library_bearSSL"] =
Expand Down Expand Up @@ -154,7 +156,7 @@ ${
if (connected == true) {
// construct the HTTP POST request:
sprintf_P(buffer,
PSTR("POST /boxes/%s/data HTTP/1.1\\nAuthorization: ${access_token}\\nHost: %s\\nContent-Type: "
PSTR("POST /boxes/%s/data HTTP/1.1\\nAuthorization: ${access_token}\\nX-Allow-Token: ${ratelimit_token}\\nHost: %s\\nContent-Type: "
"text/csv\\nConnection: close\\nContent-Length: %i\\n\\n"),
SENSEBOX_ID, server, num_measurements * lengthMultiplikator);
// send the HTTP POST request:
Expand Down Expand Up @@ -253,7 +255,7 @@ ${
if (connected == true) {
// construct the HTTP POST request:
sprintf_P(buffer,
PSTR("POST /boxes/%s/data HTTP/1.1\\nAuthorization: ${access_token}\\nHost: %s\\nContent-Type: "
PSTR("POST /boxes/%s/data HTTP/1.1\\nAuthorization: ${access_token}\\nX-Allow-Token: ${ratelimit_token}\\nHost: %s\\nContent-Type: "
"text/csv\\nConnection: close\\nContent-Length: %i\\n\\n"),
SENSEBOX_ID, server, num_measurements * lengthMultiplikator);
// send the HTTP POST request:
Expand Down
3 changes: 2 additions & 1 deletion src/components/Blockly/msg/de/sensebox-osem.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ export const OSEM = {
senseBox_send_to_osem: "Sende Messwert an die openSenseMap",
senseBox_osem_connection: "Verbinde mit openSenseMap:",
senseBox_osem_host: "opensensemap.org",
senseBox_osem_host_workshop: "workshop.opensensemap.org",
senseBox_osem_host_testing: "testing.opensensemap.org",
senseBox_osem_exposure: "Typ",
senseBox_osem_stationary: "Stationär",
senseBox_osem_mobile: "Mobil",
senseBox_osem_access_token: "API Schlüssel",
senseBox_osem_xallowtoken: "X-ALLOW-TOKEN",
senseBox_send_mobile_to_osem:
"Sende Messwert und Standort an die openSenseMap",
senseBox_send_mobile_to_osem_tip:
Expand Down
3 changes: 2 additions & 1 deletion src/components/Blockly/msg/en/sensebox-osem.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ export const OSEM = {
senseBox_send_to_osem: "Send measurement to openSenseMap",
senseBox_osem_connection: "Connect to openSenseMap",
senseBox_osem_host: "opensensemap.org",
senseBox_osem_host_workshop: "workshop.opensensemap.org",
senseBox_osem_host_testing: "testing.opensensemap.org",
senseBox_osem_exposure: "Type",
senseBox_osem_stationary: "Stationary",
senseBox_osem_mobile: "Mobile",
senseBox_osem_access_token: "API Key",
senseBox_osem_xallowtoken: "X-ALLOW-TOKEN",
senseBox_send_mobile_to_osem: "Send measurement and location to openSenseMap",
senseBox_send_mobile_to_osem_tip: "Send Value and Location to openSenseMap",
senseBox_osem_restart: "Restart device if disconnected?",
Expand Down