Kris Scholte Lubberink
/
SSS_Ble
Ble for smart sOlutions
Diff: source/BleDeviceCentral.h
- Revision:
- 9:92d861703f96
- Parent:
- 8:369b80cef5ae
- Child:
- 10:d845189d146e
diff -r 369b80cef5ae -r 92d861703f96 source/BleDeviceCentral.h --- a/source/BleDeviceCentral.h Tue May 21 13:57:27 2019 +0200 +++ b/source/BleDeviceCentral.h Tue Jun 11 11:16:55 2019 +0200 @@ -13,7 +13,9 @@ class BleDeviceCentral : public BleDevice { public: BleDeviceCentral(BLE &ble, events::EventQueue &event_queue) - : BleDevice(ble, event_queue) {} + : BleDevice(ble, event_queue) { + + } std::list<ble::address_t::byte_array_t> addresses ; virtual void start() @@ -50,15 +52,13 @@ public: + /** Look at scan payload to find a peer device and connect to it */ - virtual void onAdvertisingReport(const ble::AdvertisingReportEvent &event) { + virtual void onAdvertisingReport(const ble::AdvertisingReportEvent &event) { /* don't bother with analysing scan result if we're already connecting */ if (_is_connecting) { return; } -// printf("found someone "); - /* parse the advertising payload, looking for a discoverable device */ - //TODO: Hier checken ofhet een andere SSS wearable is. Zo niet, gewoon tellen. bool found = false; ble::address_t::byte_array_t actualdata = event.getPeerAddress().data(); @@ -90,7 +90,7 @@ if (field.type == ble::adv_data_type_t::COMPLETE_LOCAL_NAME && field.value.size() == strlen("SSS BLE") && (memcmp(field.value.data(), "SSS BLE", field.value.size()) == 0)) { - printf("[PERIPHERAL]\t Found another wearable, let's try connecting to him.\r\n"); + printf("[CENTRAL]\t Found another wearable, let's try connecting to him.\r\n"); ble_error_t error = _ble.gap().stopScan(); @@ -99,25 +99,26 @@ print_error(error, "Error caused by Gap::stopScan"); return; } - printf("[PERIPHERAL]\t Stopped the scan.\r\n"); + printf("[CENTRAL]\t Stopped the scan.\r\n"); const ble::ConnectionParameters connection_params; - printf("[PERIPHERAL]\t Trying to connect.\r\n"); + printf("[CENTRAL]\t Trying to connect.\r\n"); error = _ble.gap().connect( event.getPeerAddressType(), event.getPeerAddress(), connection_params ); - printf("[PERIPHERAL]\t Trying to connect..\r\n"); + printf("[CENTRAL]\t Trying to connect..\r\n"); if (error) { _ble.gap().startScan(); return; } - printf("[PERIPHERAL]\t Trying to connect...\r\n"); - + printf("[CENTRAL]\t Looks like I'm connected...\r\n"); + //TODO: Break the event queue, but keep doing what im doing + _event_queue.dispatch_forever(); } char test[field.value.size()];