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