add "LE Device Address" 0x1B to advertising data types
Fork of BLE_API by
Diff: ble/services/EddystoneService.h
- Revision:
- 860:0d41e4eb3d0a
- Parent:
- 857:7f578be2d01d
- Child:
- 861:2afa79e3ed0a
--- a/ble/services/EddystoneService.h Mon Nov 02 09:09:07 2015 +0000 +++ b/ble/services/EddystoneService.h Mon Nov 02 09:09:07 2015 +0000 @@ -175,40 +175,16 @@ urlIsSet = false; return false; } + defaultUrlPower = power; encodeURL(urlIn, defaultUriData, defaultUriDataLength); // encode URL to URL Formatting if (defaultUriDataLength > URI_DATA_MAX) { return true; // error, URL is too big } - defaultUrlPower = power; urlAdvPeriod = urlAdvPeriodIn; urlIsSet = true; return false; } - /** - * Set Eddystone URL Frame information. - * @param[in] power TX Power in dB measured at 0 meters from the device. - * @param[in] encodedUrlIn Encoded URL - * @param[in] encodedUrlInLength Length of the encoded URL - * @param[in] urlAdvPeriodIn How long to advertise the URL frame (measured in # of adv periods) - * @return false on success, true on failure. - */ - bool setURLFrameEncodedData(int8_t power, const char *encodedUrlIn, uint8_t encodedUrlInLength, uint32_t urlAdvPeriodIn) { - if (0 == urlAdvPeriodIn) { - urlIsSet = false; - return false; - } - memcpy(defaultUriData, encodedUrlIn, encodedUrlInLength); - if (defaultUriDataLength > URI_DATA_MAX) { - return true; // error, URL is too big - } - defaultUrlPower = power; - defaultUriDataLength = encodedUrlInLength; - urlAdvPeriod = urlAdvPeriodIn; - urlIsSet = true; - return false; - } - /* * Construct URL frame from private variables * @param[in/out] Data pointer to array to store constructed frame in @@ -260,10 +236,6 @@ * @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 @@ -320,6 +292,14 @@ } /* + * 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 */ @@ -520,8 +500,7 @@ // Make double sure the PDUCount and TimeSinceBoot fields are set to zero at reset updateTlmPduCount(0); updateTlmTimeSinceBoot(0); - lastBootTimerRead = 0; - timeSinceBootTimer.start(); + timeSinceBootTick.attach(this, &EddystoneService::tsbCallback, 0.1); // incriment the TimeSinceBoot ticker every 0.1s tlmTicker.attach(this, &EddystoneService::tlmCallback, TlmAdvPeriod); DBG("attached tlmCallback every %d seconds", TlmAdvPeriod); } @@ -540,8 +519,7 @@ BLEDevice &ble; uint16_t advPeriodus; uint8_t txPower; - Timer timeSinceBootTimer; - volatile uint32_t lastBootTimerRead; + Ticker timeSinceBootTick; // counter that counts time since boot volatile bool advLock; volatile FrameTypes frameIndex; Timeout stopAdv;