fork microbit-dal
Dependencies: BLE_API mbed-dev-bin nRF51822
Fork of microbit-dal by
Diff: source/bluetooth/MicroBitEddystone.cpp
- Revision:
- 75:739b6a1c1b50
- Parent:
- 74:a8f5674a0079
--- a/source/bluetooth/MicroBitEddystone.cpp Wed Feb 08 07:49:17 2017 +0000 +++ b/source/bluetooth/MicroBitEddystone.cpp Mon Jul 17 20:49:56 2017 +0000 @@ -57,11 +57,7 @@ const uint8_t EDDYSTONE_URL_FRAME_TYPE = 0x10; #endif -#if CONFIG_ENABLED(MICROBIT_BLE_EDDYSTONE_UID) -const int EDDYSTONE_UID_NAMESPACE_MAX_LENGTH = 10; -const int EDDYSTONE_UID_INSTANCE_MAX_LENGTH = 6; -const uint8_t EDDYSTONE_UID_FRAME_TYPE = 0x00; -#endif + /** * Constructor. @@ -89,11 +85,8 @@ /** * Set the content of Eddystone URL frames - * * @param url The url to broadcast - * * @param calibratedPower the transmission range of the beacon (Defaults to: 0xF0 ~10m). - * * @note The calibratedPower value ranges from -100 to +20 to a resolution of 1. The calibrated power should be binary encoded. * More information can be found at https://github.com/google/eddystone/tree/master/eddystone-uid#tx-power */ @@ -157,11 +150,8 @@ /** * Set the content of Eddystone URL frames, but accepts a ManagedString as a url. - * * @param url The url to broadcast - * * @param calibratedPower the transmission range of the beacon (Defaults to: 0xF0 ~10m). - * * @note The calibratedPower value ranges from -100 to +20 to a resolution of 1. The calibrated power should be binary encoded. * More information can be found at https://github.com/google/eddystone/tree/master/eddystone-uid#tx-power */ @@ -171,45 +161,3 @@ } #endif -#if CONFIG_ENABLED(MICROBIT_BLE_EDDYSTONE_UID) - -/** - * Set the content of Eddystone UID frames - * - * @param uid_namespace the uid namespace. Must 10 bytes long. - * - * @param uid_instance the uid instance value. Must 6 bytes long. - * - * @param calibratedPower the transmission range of the beacon (Defaults to: 0xF0 ~10m). - * - * @note The calibratedPower value ranges from -100 to +20 to a resolution of 1. The calibrated power should be binary encoded. - * More information can be found at https://github.com/google/eddystone/tree/master/eddystone-uid#tx-power - */ -int MicroBitEddystone::setUID(BLEDevice* ble, const char* uid_namespace, const char* uid_instance, int8_t calibratedPower) -{ - if (uid_namespace == NULL || uid_instance == NULL) - return MICROBIT_INVALID_PARAMETER; - - char uidData[EDDYSTONE_UID_NAMESPACE_MAX_LENGTH + EDDYSTONE_UID_INSTANCE_MAX_LENGTH]; - - // UID namespace - memcpy(uidData, uid_namespace, EDDYSTONE_UID_NAMESPACE_MAX_LENGTH); - - // UID instance - memcpy(uidData + EDDYSTONE_UID_NAMESPACE_MAX_LENGTH, uid_instance, EDDYSTONE_UID_INSTANCE_MAX_LENGTH); - - uint8_t rawFrame[EDDYSTONE_UID_NAMESPACE_MAX_LENGTH + EDDYSTONE_UID_INSTANCE_MAX_LENGTH + 4]; - size_t index = 0; - rawFrame[index++] = EDDYSTONE_UUID[0]; - rawFrame[index++] = EDDYSTONE_UUID[1]; - rawFrame[index++] = EDDYSTONE_UID_FRAME_TYPE; - rawFrame[index++] = calibratedPower; - memcpy(rawFrame + index, uidData, EDDYSTONE_UID_NAMESPACE_MAX_LENGTH + EDDYSTONE_UID_INSTANCE_MAX_LENGTH); - - ble->accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, EDDYSTONE_UUID, sizeof(EDDYSTONE_UUID)); - ble->accumulateAdvertisingPayload(GapAdvertisingData::SERVICE_DATA, rawFrame, index + EDDYSTONE_UID_NAMESPACE_MAX_LENGTH + EDDYSTONE_UID_INSTANCE_MAX_LENGTH); - - return MICROBIT_OK; -} - -#endif