Hello, I'm using the Arduino BLUE library. I'm writing a central program, and subscribing to a characteristic. That all works fine, BUT it's not clear how to use
powerChar.valueUpdated()
I mean, it clearly goes true at some point when it gets some data. But does it ever get cleared again? The docs don't say, and if I just poll it like so (powerChar is the characteristic that I subscribed to)
while (true) {
if (powerChar.valueUpdated()) {
// Get the value from the characteristic
int length = powerChar.valueLength();
uint8_t data[length];
powerChar.readValue(data, length);
I clearly get duplicates. It seems like you would really need to either have a callback that you install to handle new data, or at least have valueUpdated() return an int32_t, that increments with each update, so you can do something like:
uint32_t lastUpdate = 0;
while (true) {
uint32_t currentUpdate = powerChar.valueUpdated();
if (currentUpdate != lastUpdate) {
lastUpdate = currentUpdate;
// Get the value from the characteristic
int length = powerChar.valueLength();
uint8_t data[length];
powerChar.readValue(data, length);
Does anyone know, Is this addressed somehow, or should I try asking on the github for that library?