sensebox / ardublockly-1

Visual programming for the new senseBox MCU. Based on blockly, extends Arduino code generation and implements senseBox facilities.
https://blockly.sensebox.de/
Apache License 2.0
9 stars 9 forks source link

lengthMultiplikator too low for mobile sensebox #180

Open henrymartin1 opened 4 years ago

henrymartin1 commented 4 years ago

Hi sensebox/blockly team, as a arduino newbie I really appreaciated the possibility to use the blockly version to work with the sensebox. However I encountered a bug that took me some time to find and solve.

I was trying to reproduce the project for the mobile sensebox shown here: https://sensebox.de/projects/de/2020-03-09-mobilemessstation#schritt-3-%C3%BCbertragen-der-messwerte-an-die-opensensemap

My setup submitted this string

815f775f2fe6255b001bd228f1,    38.71,2020-10-08T13:44:40Z,8.xxxxxx,47.xxxxxx, 100.00

that was 84 characters long. However, the variable lengthMultiplikator is fixed to 77.

I solved the problem by calculating the lengthMultiplikator in the submitValues function. Here is the code (be aware that I am not used to writing c code):

sprintf_P(contentBuffer, PSTR("%s,%9.2f,%s,%3.6f,%3.6f,%5.2f\n"), measurements[0].sensorId,
        measurements[0].value, timeStamp, lat, lng, altitude);
      DEBUG2("lat: "); DEBUG2(lat); DEBUG2(" long: "); DEBUG(lng);
      // transmit buffer to client
      lengthMultiplikator = strlen(contentBuffer);
mariopesch commented 4 years ago

Thanks @henrymartin1 for the issue. I'll check and fix it.