Jelle Bakker
/
mbed-os-example-ble-LEDBlinker_2
working observer
Fork of mbed-os-example-ble-LEDBlinker by
Revision 50:a45dd75fbe11, committed 2017-12-12
- Comitter:
- john111222333
- Date:
- Tue Dec 12 09:49:30 2017 +0000
- Parent:
- 49:2fe76892ad76
- Commit message:
- working observer
Changed in this revision
--- a/mbed_app.json Tue Dec 05 15:30:30 2017 +0000 +++ b/mbed_app.json Tue Dec 12 09:49:30 2017 +0000 @@ -1,16 +1,8 @@ { "target_overrides": { - "K64F": { - "target.features_add": ["BLE"], - "target.extra_labels_add": ["ST_BLUENRG"] - }, - "NUCLEO_F401RE": { - "target.features_add": ["BLE"], - "target.extra_labels_add": ["ST_BLUENRG"] - }, - "DISCO_L475VG_IOT01A": { - "target.features_add": ["BLE"], - "target.extra_labels_add": ["ST_BLUENRG"] + "NRF52_DK": { + "target.uart_hwfc": 0 } } } +
--- a/shields/TARGET_ST_BLUENRG.lib Tue Dec 05 15:30:30 2017 +0000 +++ b/shields/TARGET_ST_BLUENRG.lib Tue Dec 12 09:49:30 2017 +0000 @@ -1,1 +1,1 @@ -https://github.com/ARMmbed/ble-x-nucleo-idb0xa1/#b630517008bbe47592927cc8e5dfcd2e5b9de968 +https://github.com/ARMmbed/ble-x-nucleo-idb0xa1/#bcef7fa68b2deaa8ae7b2dbbe2648fdc8bae290b
--- a/source/main.cpp Tue Dec 05 15:30:30 2017 +0000 +++ b/source/main.cpp Tue Dec 12 09:49:30 2017 +0000 @@ -23,7 +23,7 @@ DigitalOut alivenessLED(LED1, 1); static DiscoveredCharacteristic ledCharacteristic; static bool triggerLedCharacteristic; -static const char PEER_NAME[] = "LED"; +static const char PEER_NAME[] = "Jelle"; static EventQueue eventQueue(/* event count */ 16 * EVENTS_EVENT_SIZE); @@ -37,6 +37,7 @@ // byte 0: length of the record excluding this byte // byte 1: The key, it is the type of the data // byte [2..N] The value. N is equal to byte0 - 1 + bool isTrustedDevice = false; for (uint8_t i = 0; i < params->advertisingDataLen; ++i) { const uint8_t record_length = params->advertisingData[i]; @@ -54,10 +55,19 @@ params->peerAddr[5], params->peerAddr[4], params->peerAddr[3], params->peerAddr[2], params->peerAddr[1], params->peerAddr[0], params->rssi, params->isScanResponse, params->type ); - BLE::Instance().gap().connect(params->peerAddr, Gap::ADDR_TYPE_RANDOM_STATIC, NULL, NULL); - break; + isTrustedDevice = true; + printf("isTrustedDevice %s\n\r", isTrustedDevice); + // BLE::Instance().gap().connect(params->peerAddr, Gap::ADDR_TYPE_RANDOM_STATIC, NULL, NULL); } } + + if(type == GapAdvertisingData::SERVICE_DATA && isTrustedDevice) { + printf("adv number = %d\n\r", *value); + } + if(type == GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA && isTrustedDevice) { + printf("adv counter = %d\n\r",*value); + } + i += record_length; } } @@ -109,6 +119,7 @@ if (response->handle == ledCharacteristic.getValueHandle()) { printf("triggerToggledWrite: handle %u, offset %u, len %u\r\n", response->handle, response->offset, response->len); for (unsigned index = 0; index < response->len; index++) { + printf("test %d", index); printf("%c[%02x]", response->data[index], response->data[index]); } printf("\r\n");