Skip to content

Commit

Permalink
Merge pull request #10 from Wolkabout/with_1_decimal_presition
Browse files Browse the repository at this point in the history
v4.3.4
  • Loading branch information
srdjastankovic committed Mar 28, 2018
2 parents 69bfccc + 504ac7d commit d3f1d88
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 32 deletions.
4 changes: 4 additions & 0 deletions RELEASE NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
WolkSensor is a device with built-in temperature, pressure, humidity and movement sensor.
List of Firmware Release Versions for WolkSensor device in WolkSensor.bin file:

**Version 4.3.4**
- [BUGFIX] "nan" for OFFSET_FACTORY's while read from eeprom changed with 0,0,0 as default offset factory values
- [NEW] New decimal numbers scale is 1. Example T:20.1

**Version 4.3.3**
- [BUGFIX] Update certification time on every connection to the platform
- [BUGFIX] Reject values for offset which are not decimal
Expand Down
2 changes: 1 addition & 1 deletion wolksensor/SDK/core/command_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ static bool parse_commad_argument(command_t* command, char* argument)
case COMMAND_HUMIDITY_OFFSET:
case COMMAND_PRESSURE_OFFSET:
{
if (strlen(argument)>(MAX_INT_LENGTH+1) || !is_string_decimal_numeric(argument))
if (strlen(argument)>(MAX_INT_LENGTH) || !is_string_decimal_numeric(argument))
return false;

float value = atof(argument);
Expand Down
20 changes: 11 additions & 9 deletions wolksensor/SDK/core/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,11 +576,11 @@ command_execution_result_t cmd_temp_offset(command_t* command, circular_buffer_t
atmo_offset_factory[3] = 1;
atmo_offset_factory[0] = command->argument.float_argument;
if(global_dependencies.config_write(atmo_offset_factory, CFG_OFFSET_FACTORY, 1, sizeof(atmo_offset_factory)))
LOG_PRINT(1, PSTR("Factory temperature offset is written: %0.2f \n\r"), atmo_offset_factory[0]);
LOG_PRINT(1, PSTR("Factory temperature offset is written: %.1f \n\r"), atmo_offset_factory[0]);
}
atmo_offset[0] = command->argument.float_argument;
if(global_dependencies.config_write(&atmo_offset, CFG_OFFSET, 1, sizeof(atmo_offset)))
LOG_PRINT(1, PSTR("Temperature offset is written: %g \n\r"), atmo_offset[0]);
LOG_PRINT(1, PSTR("Temperature offset is written: %.1f \n\r"), atmo_offset[0]);
}

append_temp_offset(atmo_offset[0], response_buffer);
Expand All @@ -604,10 +604,11 @@ command_execution_result_t cmd_humidity_offset(command_t* command, circular_buff
atmo_offset_factory[4] = 1;
atmo_offset_factory[2] = command->argument.float_argument;
if(global_dependencies.config_write(atmo_offset_factory, CFG_OFFSET_FACTORY, 1, sizeof(atmo_offset_factory)))
LOG_PRINT(1, PSTR("Factory temperature offset is written: %0.2f \n\r"), atmo_offset_factory[2]);
LOG_PRINT(1, PSTR("Factory temperature offset is written: %.1f \n\r"), atmo_offset_factory[2]);
}
atmo_offset[2] = command->argument.float_argument;
global_dependencies.config_write(&atmo_offset, CFG_OFFSET, 1, sizeof(atmo_offset));
if(global_dependencies.config_write(&atmo_offset, CFG_OFFSET, 1, sizeof(atmo_offset)))
LOG_PRINT(1, PSTR("Humidity offset is written: %.1f \n\r"), atmo_offset[2]);
}

append_humidity_offset(atmo_offset[2], response_buffer);
Expand All @@ -631,10 +632,11 @@ command_execution_result_t cmd_pressure_offset(command_t* command, circular_buff
atmo_offset_factory[5] = 1;
atmo_offset_factory[1] = command->argument.float_argument;
if(global_dependencies.config_write(atmo_offset_factory, CFG_OFFSET_FACTORY, 1, sizeof(atmo_offset_factory)))
LOG_PRINT(1, PSTR("Factory temperature offset is written: %0.2f \n\r"), atmo_offset_factory[1]);
LOG_PRINT(1, PSTR("Factory temperature offset is written: %.1f \n\r"), atmo_offset_factory[1]);
}
atmo_offset[1] = command->argument.float_argument;
global_dependencies.config_write(&atmo_offset, CFG_OFFSET, 1, sizeof(atmo_offset));
if(global_dependencies.config_write(&atmo_offset, CFG_OFFSET, 1, sizeof(atmo_offset)))
LOG_PRINT(1, PSTR("Pressure offset is written: %.1f \n\r"), atmo_offset[1]);
}

append_pressure_offset(atmo_offset[1], response_buffer);
Expand All @@ -657,9 +659,9 @@ command_execution_result_t cmd_offset_factory(command_t* command, circular_buffe

if(global_dependencies.config_write(&atmo_offset, CFG_OFFSET, 1, sizeof(atmo_offset)))
{
LOG_PRINT(1, PSTR("Temperature offset is written: %g"), atmo_offset[0]);
LOG_PRINT(1, PSTR("Pressure offset is written: %g"), atmo_offset[1]);
LOG_PRINT(1, PSTR("Humidity offset is written: %g \n\r"), atmo_offset[2]);
LOG_PRINT(1, PSTR("Temperature offset is written: %.1f\n\r"), atmo_offset[0]);
LOG_PRINT(1, PSTR("Pressure offset is written: %.1f\n\r"), atmo_offset[1]);
LOG_PRINT(1, PSTR("Humidity offset is written: %.1f \n\r"), atmo_offset[2]);
}
else
LOG(1, "Failed to write offset factory settings into offset eeprom");
Expand Down
13 changes: 11 additions & 2 deletions wolksensor/SDK/core/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ bool load_offset_status(void)
{
if (global_dependencies.config_read(&atmo_offset, CFG_OFFSET, 1, sizeof(atmo_offset)))
{
LOG_PRINT(1, PSTR("Temperature offset is written: %g \n\rPressure offset is written: %g \n\rHumidity offset is written: %g \n\r"), atmo_offset[0], atmo_offset[1], atmo_offset[2]);
LOG_PRINT(1, PSTR("Temperature offset is written: %.1f \n\rPressure offset is written: %.1f \n\rHumidity offset is written: %.1f \n\r"), atmo_offset[0], atmo_offset[1], atmo_offset[2]);
return true;
}

Expand All @@ -323,7 +323,16 @@ bool load_offset_factory_status(void)
{
if(global_dependencies.config_read(&atmo_offset_factory, CFG_OFFSET_FACTORY, 1, sizeof(atmo_offset_factory)))
{
LOG_PRINT(1, PSTR("Temperature offset factory is written: %0.2f \n\rPressure offset factory is written: %0.2f \n\rHumidity offset factory is written: %0.2f \n\r"), atmo_offset_factory[0], atmo_offset_factory[1], atmo_offset_factory[2]);
if( isnan(atmo_offset_factory[0]) || isnan(atmo_offset_factory[1]) || isnan(atmo_offset_factory[2]) )
{
LOG(1, "Could not read Temperature offset factory status, defaulting to 0 \n\rCould not read Pressure offset factory status, defaulting to 0 \n\rCould not read Humidity offset factory status, defaulting to 0");
atmo_offset_factory[0] = 0;
atmo_offset_factory[1] = 0;
atmo_offset_factory[2] = 0;

return false;
}

return true;
}

Expand Down
16 changes: 8 additions & 8 deletions wolksensor/SDK/core/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static uint16_t serialize_sensor_reading(sensor_readings_t* sensor_reading, char
{
if(sensor_reading->values[i] != SENSOR_VALUE_NOT_SET)
{
size += sprintf_P(buffer + size, PSTR("%c:%.2f,"), sensors[i].id, sensor_reading->values[i]);
size += sprintf_P(buffer + size, PSTR("%c:%.1f,"), sensors[i].id, sensor_reading->values[i]);
}
}

Expand Down Expand Up @@ -759,21 +759,21 @@ bool append_mqtt_password(char* password, circular_buffer_t* response_buffer)

bool append_temp_offset(uint16_t offset, circular_buffer_t* message_buffer)
{
sprintf_P(tmp, PSTR("TEMP_OFFSET %g;"), atmo_offset[0]);
sprintf_P(tmp, PSTR("TEMP_OFFSET %.1f;"), atmo_offset[0]);
circular_buffer_add_array(message_buffer, tmp, strlen(tmp));
return true;
}

bool append_humidity_offset(uint16_t offset, circular_buffer_t* message_buffer)
{
sprintf_P(tmp, PSTR("HUMIDITY_OFFSET %g;"), atmo_offset[2]);
sprintf_P(tmp, PSTR("HUMIDITY_OFFSET %.1f;"), atmo_offset[2]);
circular_buffer_add_array(message_buffer, tmp, strlen(tmp));
return true;
}

bool append_pressure_offset(uint16_t offset, circular_buffer_t* message_buffer)
{
sprintf_P(tmp, PSTR("PRESSURE_OFFSET %g;"), atmo_offset[1]);
sprintf_P(tmp, PSTR("PRESSURE_OFFSET %.1f;"), atmo_offset[1]);
circular_buffer_add_array(message_buffer, tmp, strlen(tmp));
return true;
}
Expand All @@ -786,12 +786,12 @@ bool append_offset_factory(char* offset_factory, circular_buffer_t* message_buff
}
else
{
static char array[6];
static char array[20];

sprintf_P(tmp, PSTR("OFFSET_FACTORY P:%g,"), atmo_offset_factory[1]);
sprintf_P(array, PSTR("T:%g,"), atmo_offset_factory[0]);
sprintf_P(tmp, PSTR("OFFSET_FACTORY P:%.1f,"), atmo_offset_factory[1]);
sprintf_P(array, PSTR("T:%.1f,"), atmo_offset_factory[0]);
strcat(tmp, array);
sprintf_P(array, PSTR("H:%g;"), atmo_offset_factory[2]);
sprintf_P(array, PSTR("H:%.1f;"), atmo_offset_factory[2]);
strcat(tmp, array);

LOG_PRINT(1, PSTR("tmp: %s \n\r"), tmp);
Expand Down
4 changes: 2 additions & 2 deletions wolksensor/tests/functional/initialisation/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
VID = 'VID_0403'
PID = 'PID_6015'

SSID = "theHome"
SSID = "wolkabout"
AUTH = "WPA2"
PASS = "Welcome26"
PASS = "Walkm3int0"

URL = '52.213.16.227'
HOSTNAME = 'api-demo.wolkabout.com'
Expand Down
8 changes: 4 additions & 4 deletions wolksensor/tests/functional/tests/data_driven.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,17 @@ def data_driven():
logging_device.error("Return value is %s" %return_value)

logging_device.info("\n\r\t\t-------- TEMP_OFFSET --------")
if not test('TEMP_OFFSET', ['0', '2', '-1', '1.1', '1.76', '-1.5', '-0.92', '3.7', '-2'], ['3.71', '-2.01', '38.23', '-21.879', '', '-1.temperature.+1.QWE', 'app.wolkabout.com', '\Test1234', '!")(*&^%;']):
if not test('TEMP_OFFSET', ['0.0', '2.0', '-1.0', '1.1', '1.7', '-1.5', '-0.9', '3.7', '-2.0'], ['3.71', '-2.01', '38.23', '-21.879', '', '-1.temperature.+1.QWE', 'app.wolkabout.com', '\Test1234', '!")(*&^%;']):
return_value = False
logging_device.error("Return value is %s" %return_value)

logging_device.info("\n\r\t\t-------- HUMIDITY_OFFSET --------")
if not test('HUMIDITY_OFFSET', ['0', '2', '-1', '1.3', '1.23', '-1.9', '-2.97', '3', '-3'], ['3.1', '-3.1', '78.12', '', '-1.humidity.+1.QWE', 'app.wolkabout.com', '\Test1234', '!")(*&^%;']):
if not test('HUMIDITY_OFFSET', ['0.0', '2.0', '-1.0', '1.3', '1.3', '-1.9', '-2.9', '3.0', '-3.0'], ['3.1', '-3.1', '78.12', '', '-1.humidity.+1.QWE', 'app.wolkabout.com', '\Test1234', '!")(*&^%;']):
return_value = False
logging_device.error("Return value is %s" %return_value)

logging_device.info("\n\r\t\t-------- PRESSURE_OFFSET --------")
if not test('PRESSURE_OFFSET', ['0', '2', '-8', '8.2', '1.25', '-2.6', '-1.23', '10', '-10'], ['10.1', '-10.1', '94.65', '', '-1.pressure.+1.QWE', 'app.wolkabout.com', '\Test1234', '!")(*&^%;']):
if not test('PRESSURE_OFFSET', ['0.0', '2.0', '-8.0', '8.2', '1.5', '-2.6', '-1.3', '10.0', '-10.0'], ['10.1', '-10.1', '94.65', '', '-1.pressure.+1.QWE', 'app.wolkabout.com', '\Test1234', '!")(*&^%;']):
return_value = False
logging_device.error("Return value is %s" %return_value)

Expand All @@ -181,7 +181,7 @@ def data_driven():
if not test('ACQUISITION', [], ['empty', 'CLEAR', '', '-1.pressure.+1.QWE', '!")(*&^%;']):
return_value = False
logging_device.error("Return value is %s" %return_value)

logging_device.log("\n\r")
return return_value

Expand Down
4 changes: 1 addition & 3 deletions wolksensor/tests/functional/tests/flow_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def flow_states():
if response != True:
return_value = False
logging_device.error("Return value is %s. Response from command NOW; is: %s" %(return_value, response))

'''
logging_device.info("\n\r\t\t-------- set Wifi with WPA secure --------")
if not set_wifi_parameters('WolkSensorWlan2', 'WPA', 'WolkSensorFabrication'):
Expand Down Expand Up @@ -73,7 +72,6 @@ def flow_states():
return_value = False
logging_device.error("Return value is %s. Response from command NOW; is: %s" %(return_value, response))
'''

logging_device.log("\t---False flow---")
if not set_wifi_parameters('my0penwl4n', 'NONE', 'NULL'):
return_value = False
Expand Down Expand Up @@ -202,7 +200,7 @@ def set_offset(pressure_offset, temperature_offset, humidity_offset):
logging_device.log("\t -->MOVE WolkSensor to continue testing<--")
send_string_serial_wait("READINGS;")
received_string = receive_string_serial()
while ",M:1.00;" not in received_string:
while ",M:1.0;" not in received_string:
send_string_serial_wait("READINGS;")
received_string = receive_string_serial()
time.sleep(0.5)
Expand Down
3 changes: 2 additions & 1 deletion wolksensor/wolksensor/WolkSensor/platform_specific.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
#include <avr/interrupt.h>
#include <avr/sleep.h>
#include <avr/pgmspace.h>
#include <math.h>

#define FW_VERSION_MAJOR 4 // number 0 -99
#define FW_VERSION_MINOR 3 // number 0 -99
#define FW_VERSION_PATCH 3 // number 0 -99
#define FW_VERSION_PATCH 4 // number 0 -99

#define SYNCHRONIZED_BLOCK_START register8_t saved_sreg = SREG; cli();
#define SYNCHRONIZED_BLOCK_END SREG = saved_sreg;
Expand Down
4 changes: 2 additions & 2 deletions wolksensor/wolksensor/src/util_conversions.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bool is_string_decimal_numeric(const char *str)
{
if(*str == '.')
{
if(strlen(str)==1)
if(strlen(str) == 1)
return false;
++str;
++number_of_dots;
Expand All @@ -57,7 +57,7 @@ bool is_string_decimal_numeric(const char *str)
++str;
}

if( number_of_dots>1 )
if(number_of_dots > 1)
return false;

return true;
Expand Down

0 comments on commit d3f1d88

Please sign in to comment.