Locator beacon firmware
Dependencies: BLE_API mbed nRF51822
Fork of WeatherStation by
main.cpp
- Committer:
- sycorax
- Date:
- 2017-04-29
- Revision:
- 9:dd7ba1fdae47
- Parent:
- 8:2aa1fc734e13
File content as of revision 9:dd7ba1fdae47:
#include "mbed.h" #include "BLE.h" #include "BatteryService.h" #include "LocatorService.h" BLE ble; const static char DEVICE_NAME[] = "Locator RedBear"; static const uint16_t serviceList[] = { 0x1821 }; void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params) { /* Restart Advertising on disconnection*/ ble.gap().startAdvertising(); } int main(void) { printf("Starting locator\n"); ble.init(); ble.gap().onDisconnection(disconnectionCallback); /* Setup weather service. */ LocatorService locatorService(ble); + /* setup advertising */ ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE); ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)serviceList, sizeof(serviceList)); ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME)); ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED); ble.gap().setAdvertisingInterval(100); /* 1000ms */ ble.gap().startAdvertising(); while (true) { ble.waitForEvent(); } }