vo dung
/
eddystone_URL
first commit
Fork of BLE_WallbotBLE_Challenge by
main.cpp@5:984cc7e96073, 2017-12-21 (annotated)
- Committer:
- tridung141196
- Date:
- Thu Dec 21 03:40:35 2017 +0000
- Revision:
- 5:984cc7e96073
- Parent:
- 4:2386637c9c7c
eddystone url
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jksoft | 0:76dfa9657d9d | 1 | #include "mbed.h" |
tridung141196 | 5:984cc7e96073 | 2 | |
jksoft | 0:76dfa9657d9d | 3 | #include "BLEDevice.h" |
jksoft | 0:76dfa9657d9d | 4 | |
jksoft | 0:76dfa9657d9d | 5 | BLEDevice ble; |
tridung141196 | 5:984cc7e96073 | 6 | |
tridung141196 | 5:984cc7e96073 | 7 | void bleUploadUrl() |
jksoft | 0:76dfa9657d9d | 8 | { |
tridung141196 | 5:984cc7e96073 | 9 | static const uint16_t uuid16_list[] = {0xFEAA}; |
tridung141196 | 5:984cc7e96073 | 10 | const static uint8_t beaconPayload_url[] = { |
tridung141196 | 5:984cc7e96073 | 11 | 0xaa,0xfe, |
tridung141196 | 5:984cc7e96073 | 12 | // URL |
tridung141196 | 5:984cc7e96073 | 13 | 0x10, // Frame Type |
tridung141196 | 5:984cc7e96073 | 14 | 0x20, // Ranging Data |
tridung141196 | 5:984cc7e96073 | 15 | 0x01, // URL Scheme (https:// = 0x02) |
tridung141196 | 5:984cc7e96073 | 16 | 'e','s','p','3','2','.','v','n'}; |
tridung141196 | 5:984cc7e96073 | 17 | |
tridung141196 | 4:2386637c9c7c | 18 | ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED|GapAdvertisingData::LE_GENERAL_DISCOVERABLE); |
tridung141196 | 4:2386637c9c7c | 19 | |
tridung141196 | 4:2386637c9c7c | 20 | ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list)); |
tridung141196 | 4:2386637c9c7c | 21 | |
tridung141196 | 4:2386637c9c7c | 22 | ble.accumulateAdvertisingPayload(GapAdvertisingData::SERVICE_DATA,beaconPayload_url, sizeof(beaconPayload_url)); |
tridung141196 | 4:2386637c9c7c | 23 | |
tridung141196 | 4:2386637c9c7c | 24 | ble.setAdvertisingType(GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED); |
tridung141196 | 5:984cc7e96073 | 25 | |
tridung141196 | 4:2386637c9c7c | 26 | ble.setAdvertisingInterval(160); |
jksoft | 0:76dfa9657d9d | 27 | |
tridung141196 | 5:984cc7e96073 | 28 | ble.setTxPower(200); |
tridung141196 | 5:984cc7e96073 | 29 | |
jksoft | 0:76dfa9657d9d | 30 | ble.startAdvertising(); |
tridung141196 | 5:984cc7e96073 | 31 | |
tridung141196 | 5:984cc7e96073 | 32 | } |
tridung141196 | 5:984cc7e96073 | 33 | |
tridung141196 | 5:984cc7e96073 | 34 | int main(void) |
tridung141196 | 5:984cc7e96073 | 35 | { |
tridung141196 | 5:984cc7e96073 | 36 | ble.init(); |
tridung141196 | 5:984cc7e96073 | 37 | |
tridung141196 | 5:984cc7e96073 | 38 | bleUploadUrl(); |
tridung141196 | 5:984cc7e96073 | 39 | |
tridung141196 | 4:2386637c9c7c | 40 | while(true) { |
jksoft | 0:76dfa9657d9d | 41 | ble.waitForEvent(); |
jksoft | 0:76dfa9657d9d | 42 | } |
jksoft | 0:76dfa9657d9d | 43 | } |