Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-os-example-ble-LED by
Revision 48:684526d07191, committed 2017-12-05
- Comitter:
- john111222333
- Date:
- Tue Dec 05 15:32:44 2017 +0000
- Parent:
- 47:913bdb3e235d
- Commit message:
- set the adverticement
Changed in this revision
--- a/mbed_app.json Thu Nov 23 14:00:24 2017 +0000 +++ b/mbed_app.json Tue Dec 05 15:32:44 2017 +0000 @@ -1,16 +1,7 @@ { "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 Thu Nov 23 14:00:24 2017 +0000 +++ b/shields/TARGET_ST_BLUENRG.lib Tue Dec 05 15:32:44 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 Thu Nov 23 14:00:24 2017 +0000 +++ b/source/main.cpp Tue Dec 05 15:32:44 2017 +0000 @@ -22,22 +22,25 @@ DigitalOut alivenessLED(LED1, 0); DigitalOut actuatedLED(LED2, 0); -const static char DEVICE_NAME[] = "LED"; +const static char DEVICE_NAME[] = "Jelle"; +uint8_t NUMBER = 3; +uint8_t COUNTER = 0; static const uint16_t uuid16_list[] = {LEDService::LED_SERVICE_UUID}; static EventQueue eventQueue(/* event count */ 10 * EVENTS_EVENT_SIZE); LEDService *ledServicePtr; - + void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params) { (void) params; BLE::Instance().gap().startAdvertising(); } -void blinkCallback(void) +void blinkCallback() { alivenessLED = !alivenessLED; /* Do blinky on LED1 to indicate system aliveness. */ + } /** @@ -49,6 +52,20 @@ void onDataWrittenCallback(const GattWriteCallbackParams *params) { if ((params->handle == ledServicePtr->getValueHandle()) && (params->len == 1)) { actuatedLED = *(params->data); + printf("Led state %d\n\r",*(params->data)); + printf("NUMBER before change %d\n\r",NUMBER); + printf("counter before change %d\n\r",COUNTER); + COUNTER++; + NUMBER = *(params->data); + + BLE &ble = BLE::Instance(); + + ble.gap().updateAdvertisingPayload(GapAdvertisingData::SERVICE_DATA , &NUMBER, sizeof(NUMBER)); + ble.gap().updateAdvertisingPayload(GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA , &COUNTER, sizeof(COUNTER)); + + printf("NUMBER before change %d\n\r",NUMBER); + printf("counter before change %d\n\r",COUNTER); + } } @@ -66,11 +83,15 @@ Gap::AddressType_t addr_type; Gap::Address_t address; BLE::Instance().gap().getAddress(&addr_type, address); - printf("DEVICE MAC ADDRESS: "); + printf("TEST1\n\r"); + + printf("DEVICE MAC ADDRESS asdfasdf: "); for (int i = 5; i >= 1; i--){ printf("%02x:", address[i]); } printf("%02x\r\n", address[0]); + + } /** @@ -102,6 +123,10 @@ ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE); ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list)); ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME)); + ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::SERVICE_DATA , &NUMBER, sizeof(NUMBER)); + ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA , &COUNTER, sizeof(COUNTER)); + + ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED); ble.gap().setAdvertisingInterval(1000); /* 1000ms. */ ble.gap().startAdvertising();