Skip to content
This repository has been archived by the owner on Sep 23, 2021. It is now read-only.

Commit

Permalink
Fix RAWv1 on negative temperatures, add packaging script
Browse files Browse the repository at this point in the history
  • Loading branch information
ojousima committed Oct 31, 2019
1 parent 02a4332 commit f637cb8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions libraries/ruuvi_sensor_formats/sensortag.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,12 @@ void encodeToRawFormat3(uint8_t* data_buffer, const ruuvi_sensor_t* const data)
if(data->humidity == HUMIDITY_INVALID) { humidity = 0; }
data_buffer[1] = humidity / 512;
int32_t temperature = data->temperature;
// RAWv1 uses 1-complement negative numbers
if(temperature < 0) { temperature = 0 - temperature; }
if(data->temperature == TEMPERATURE_INVALID) { temperature = 0; }
bool negative = ((data->temperature < 0) && data->temperature != TEMPERATURE_INVALID);
data_buffer[2] = temperature / 100;
data_buffer[2] |= (negative<<7 & 0x80);
data_buffer[3] = temperature % 100;
uint32_t pressure = data->pressure;
if(data->pressure == PRESSURE_INVALID) { pressure = 50000<<8; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#define APP_DEVICE_NAME APPLICATION_DEVICE_NAME /**< TODO: Refactoring **/
#define APP_DEVICE_NAME_LENGTH APPLICATION_DEVICE_NAME_LENGTH
#define APP_TX_POWER 4 /**< dBm **/
#define INIT_FWREV "2.5.7" /**< Github tag. Do not include specifiers such as "alpha" so you can accept ready binaries as they are **/
#define INIT_FWREV "2.5.9" /**< Github tag. Do not include specifiers such as "alpha" so you can accept ready binaries as they are **/
#define INIT_SWREV INIT_FWREV /**< FW and SW are same thing in this context **/

// milliseconds until main loop timer function is called. Other timers can bring
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
nrfutil settings generate --family NRF52 --application _build/ruuvi_firmware.hex --application-version 1 --bootloader-version 1 --bl-settings-version 1 settings.hex
mergehex -m ~/git/s132_nrf52_3.1.0_softdevice.hex ~/git/ruuvitag_b_bootloader_1.0.0.hex settings.hex -o sbc.hex
mergehex -m sbc.hex _build/ruuvi_firmware.hex -o packet.hex

nrfutil pkg generate --debug-mode --application _build/ruuvi_firmware.hex --hw-version 3 --sd-req 0x91 --key-file ~/git/ruuvitag_fw/keys/ruuvi_open_private.pem ruuvi_firmware_dfu.zip
mv packet.hex ruuvi_firmware_full.hex

0 comments on commit f637cb8

Please sign in to comment.