Introduced fixes to Eddystone implementation
Fixed wrong memcpy arguments that caused the wrong number of bytes to be copied and merged energy saving changes.
This commit is contained in:
parent
78ec806379
commit
976bcd4e61
2 changed files with 10 additions and 12 deletions
|
@ -285,7 +285,7 @@ public:
|
|||
ble.setTxPower(radioPowerLevels[params.txPowerMode]);
|
||||
ble.setDeviceName(reinterpret_cast<const uint8_t *>(&DEVICE_NAME));
|
||||
ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
|
||||
ble.setAdvertisingInterval(GapAdvertisingParams::MSEC_TO_ADVERTISEMENT_DURATION_UNITS(ADVERTISING_INTERVAL_MSEC));
|
||||
ble.setAdvertisingInterval(ADVERTISING_INTERVAL_MSEC);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -340,7 +340,7 @@ private:
|
|||
} else if (handle == uriDataChar.getValueHandle()) {
|
||||
params.uriDataLength = writeParams->len;
|
||||
memset(params.uriData, 0x00, URI_DATA_MAX); // clear URI string
|
||||
memcpy(params.uriData, writeParams->data, params.uriDataLength); // set URI string
|
||||
memcpy(params.uriData, writeParams->data, writeParams->len); // set URI string
|
||||
params.uriEnabled = true;
|
||||
INFO("URI = %s, URILen = %d", writeParams->data, writeParams->len);
|
||||
} else if (handle == flagsChar.getValueHandle()) {
|
||||
|
|
|
@ -260,6 +260,10 @@ public:
|
|||
* @return number of bytes used. negative number indicates error message.
|
||||
*/
|
||||
int constructTLMFrame(uint8_t *Data, uint8_t maxSize) {
|
||||
uint32_t now = timeSinceBootTimer.read_ms();
|
||||
TlmTimeSinceBoot += (now - lastBootTimerRead) / 100;
|
||||
lastBootTimerRead = now;
|
||||
|
||||
int index = 0;
|
||||
Data[index++] = FRAME_TYPE_TLM; // Eddystone frame type = Telemetry
|
||||
Data[index++] = TlmVersion; // TLM Version Number
|
||||
|
@ -315,14 +319,6 @@ public:
|
|||
TlmTimeSinceBoot = timeSinceBoot;
|
||||
}
|
||||
|
||||
/*
|
||||
* callback function, called every 0.1s, incriments the TimeSinceBoot field in the TLM frame
|
||||
* @return nothing
|
||||
*/
|
||||
void tsbCallback(void) {
|
||||
TlmTimeSinceBoot++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Update advertising data
|
||||
* @return true on success, false on failure
|
||||
|
@ -524,7 +520,8 @@ public:
|
|||
// Make double sure the PDUCount and TimeSinceBoot fields are set to zero at reset
|
||||
updateTlmPduCount(0);
|
||||
updateTlmTimeSinceBoot(0);
|
||||
timeSinceBootTick.attach(this, &EddystoneService::tsbCallback, 0.1); // incriment the TimeSinceBoot ticker every 0.1s
|
||||
lastBootTimerRead = 0;
|
||||
timeSinceBootTimer.start();
|
||||
tlmTicker.attach(this, &EddystoneService::tlmCallback, TlmAdvPeriod);
|
||||
DBG("attached tlmCallback every %d seconds", TlmAdvPeriod);
|
||||
}
|
||||
|
@ -543,7 +540,8 @@ private:
|
|||
BLEDevice &ble;
|
||||
uint16_t advPeriodus;
|
||||
uint8_t txPower;
|
||||
Ticker timeSinceBootTick; // counter that counts time since boot
|
||||
Timer timeSinceBootTimer;
|
||||
volatile uint32_t lastBootTimerRead;
|
||||
volatile bool advLock;
|
||||
volatile FrameTypes frameIndex;
|
||||
Timeout stopAdv;
|
||||
|
|
Loading…
Reference in a new issue