project for nrf51822 qfab
Dependencies: eddystone_URL mbed
Fork of eddystone_URL by
main.cpp@5:267bdacf5508, 2017-11-23 (annotated)
- Committer:
- tridung141196
- Date:
- Thu Nov 23 15:38:48 2017 +0000
- Revision:
- 5:267bdacf5508
- Parent:
- 4:2386637c9c7c
ibeacon
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 | const static uint8_t beaconPayload_url[] = { |
tridung141196 | 5:267bdacf5508 | 6 | 0x4C, 0x00, //ID Company |
tridung141196 | 5:267bdacf5508 | 7 | 0x02, //Type |
tridung141196 | 5:267bdacf5508 | 8 | 0x15, //Length of data |
tridung141196 | 5:267bdacf5508 | 9 | 0xE2, 0x0A, 0x39, 0xF4, 0x73, 0xF5, 0x4B, 0xC4, //UUID |
tridung141196 | 5:267bdacf5508 | 10 | 0xA1, 0x2F, 0x17, 0xD1, 0xAD, 0x07, 0xA9, 0x61, // |
tridung141196 | 5:267bdacf5508 | 11 | 0x04, 0x62, //Major |
tridung141196 | 5:267bdacf5508 | 12 | 0x0D, 0x10, //Mirnor |
tridung141196 | 5:267bdacf5508 | 13 | 0xC8, //Txpower |
tridung141196 | 5:267bdacf5508 | 14 | |
tridung141196 | 5:267bdacf5508 | 15 | |
tridung141196 | 4:2386637c9c7c | 16 | }; |
jksoft | 0:76dfa9657d9d | 17 | int main(void) |
jksoft | 0:76dfa9657d9d | 18 | { |
tridung141196 | 4:2386637c9c7c | 19 | ble.init(); |
tridung141196 | 5:267bdacf5508 | 20 | |
tridung141196 | 5:267bdacf5508 | 21 | ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE ); |
tridung141196 | 5:267bdacf5508 | 22 | |
tridung141196 | 5:267bdacf5508 | 23 | ble.accumulateAdvertisingPayload(GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA, beaconPayload_url, sizeof(beaconPayload_url)); |
tridung141196 | 5:267bdacf5508 | 24 | |
tridung141196 | 4:2386637c9c7c | 25 | ble.setAdvertisingType(GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED); |
tridung141196 | 4:2386637c9c7c | 26 | |
tridung141196 | 4:2386637c9c7c | 27 | ble.setAdvertisingInterval(160); |
jksoft | 0:76dfa9657d9d | 28 | |
jksoft | 0:76dfa9657d9d | 29 | ble.startAdvertising(); |
tridung141196 | 4:2386637c9c7c | 30 | |
tridung141196 | 4:2386637c9c7c | 31 | while(true) { |
jksoft | 0:76dfa9657d9d | 32 | ble.waitForEvent(); |
jksoft | 0:76dfa9657d9d | 33 | } |
jksoft | 0:76dfa9657d9d | 34 | } |