Fixes humidity factor & removes illumminance

The reason for removing illuminance is to leave enough space for the
full name AD element "prst". There may be options for also sending the
illuminance (extended adv, scan response etc), with different power
consumption/overhead/complexity tradeoffs. For now let's keep it simple.
This commit is contained in:
rbaron 2022-08-29 21:17:17 +02:00
parent ce4c496f4d
commit 81f0af3cf2

View file

@ -48,7 +48,7 @@ prst_config.h.
#define SERVICE_DATA_LEN 18
#elif PRST_BLE_PROTOCOL == PRST_BLE_PROTOCOL_BTHOME
#define SERVICE_UUID 0x181c
#define SERVICE_DATA_LEN 21
#define SERVICE_DATA_LEN 16
#else
#error "PRST_BLE_PROTOCOL is not properly configured"
#endif
@ -233,8 +233,8 @@ static void set_service_data_bthome_protocol(
service_data[8] = (0b000 << 5) | 2;
// Type - humidity.
service_data[9] = 0x03;
// Value. Factor 0.01.
uint16_t humi_val = (100 * sensors->humi) / UINT16_MAX;
// Value. Factor 0.01, over 100%.
uint16_t humi_val = (10000 * sensors->humi) / UINT16_MAX;
service_data[10] = humi_val & 0xff;
service_data[11] = humi_val >> 8;
@ -247,17 +247,6 @@ static void set_service_data_bthome_protocol(
uint16_t batt_val = sensors->batt_mv;
service_data[14] = batt_val & 0xff;
service_data[15] = batt_val >> 8;
// // 5. Illuminance
// // uint24_t.
// service_data[16] = (0b000 << 5) | 2;
// // Type - illuminance.
// service_data[17] = 0x05;
// // Value. Factor 0.01.
// uint32_t illu_value = 100 * sensors->lux;
// service_data[18] = illu_value & 0xff;
// service_data[19] = (illu_value >> 8) & 0xff;
// service_data[20] = (illu_value >> 16) & 0xff;
}
#endif // PRST_BLE_PROTOCOL == PRST_BLE_PROTOCOL_BTHOME