![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
aidanReceiver
Dependencies: mbed BLE_API nRF51822
Diff: receiver_main.cpp
- Revision:
- 2:89b8aef35194
- Parent:
- 1:3ad5b46f9abc
- Child:
- 3:ca23d318cb12
--- a/receiver_main.cpp Wed Apr 17 20:09:51 2019 +0000 +++ b/receiver_main.cpp Wed Apr 17 20:35:33 2019 +0000 @@ -1,17 +1,23 @@ #include "mbed.h" #include "ble/BLE.h" + #define LED_RED p21 #define LED_GREEN p22 #define LED_BLUE p23 #define BUTTON_PIN p17 #define BATTERY_PIN p1 + DigitalOut led1(LED_RED); DigitalOut blueLed(LED_BLUE); + const static char DEVICE_NAME[] = "Joe-Aidan"; -// TEST COMMENT +struct Data { + uint32_t seqNum; +}; // void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params) + void scanCallback(const Gap::AdvertisementCallbackParams_t *params) { if (*(params->Gap::AdvertisementCallbackParams_t::peerAddr) == (std::uint8_t)0xF34F887FED4E) { @@ -33,23 +39,30 @@ } // ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME)); + return; } + + void bleInitComplete(BLE::InitializationCompleteCallbackContext *params) { BLE &ble = params->ble; ble_error_t error = params->error; + if (error != BLE_ERROR_NONE) { return; } led1 = 1; blueLed = 1; + /* Set up scanning prodedure */ ble.gap().setScanParams(GapScanningParams::SCAN_INTERVAL_MAX, GapScanningParams::SCAN_WINDOW_MAX, 0, false); ble.gap().startScan(scanCallback); } + + int main(void) { BLE& ble = BLE::Instance(BLE::DEFAULT_INSTANCE); @@ -62,4 +75,4 @@ while (1) { ble.waitForEvent(); // low power wait for event } -} \ No newline at end of file +}