I am trying to read temperature values from a BLE Temperature sensor (bluemaestro tempo disc)
I am developing in c++ using intel's tinyb library which requires bluez.
Relevant code snippet:
Code:
using Iter = std::vector<std::unique_ptr<tinyb::BluetoothDevice>>::const_iterator;
while (true)
{
for (Iter it = sensor_tag_array.begin(); it != sensor_tag_array.end(); ++it)
{
std::string address_ = (*it)->get_address();
std::map<uint16_t, std::vector<uint8_t>> mfg__ = (*it)->get_manufacturer_data();
for (auto it : mfg__)
{
if (it.second.empty())
logger_->error("{}, {} :Empty mfg for : {}", __FILENAME__, __func__, bleMap[address_].sensor_name);
else
{
if (it.second.front() == 23)
{
battery_lvl = it.second[1];
first_byte = it.second[6];
second_byte = it.second[7];
temperature = convert_to_actual(first_byte, second_byte) / 10.0;
std::cout << "\nTemperature is for : " << bleMap[address_].sensor_name << " : " << temperature << "\n";
}
}
}
}
This was properly giving the correct relatime values until now. But suddenly it started printing a single constant reading each time the application is restarted. Whatever temperature value is first read at application startup is repeated throughout the application runtime. I used the tempo utility app to verify that the sensor is actually reporting the correct realtime values.
I tried re-installing the OS (Ubuntu 18.04.1), tried multple version of bluez ( 5.48 which is pre-installed,5.39 and 5.37) but the issue is still there.
I also changed the advertisement frequency in the bluemaestro device.
How to resolve this ?