Okundu Omeni
/
wifi-https-ble-sm-uart-atcmd-5-13-1
this is using the mbed os version 5-13-1
Diff: source/BleManager.cpp
- Revision:
- 79:a2187bbfa407
- Parent:
- 78:07bb86e3ce14
- Child:
- 87:99b37d26ff2a
--- a/source/BleManager.cpp Sat Mar 16 13:05:52 2019 +0000 +++ b/source/BleManager.cpp Wed Mar 20 21:02:47 2019 +0000 @@ -194,8 +194,8 @@ error = _ble.securityManager().init( true, false, - SecurityManager::IO_CAPS_NONE, - NULL, + SecurityManager::IO_CAPS_DISPLAY_ONLY, // SecurityManager::IO_CAPS_NONE + ble_config.pairingKey, false, db_path ); @@ -251,6 +251,8 @@ _ble.gap().onConnection(this, &SMDevice::on_connect); _ble.gap().onDisconnection(this, &SMDevice::on_disconnect); _ble.gattServer().onDataWritten(this, &SMDevice::onDataWrittenCallback); + //_ble.securityManager().onPasskeyDisplay(this, &SMDevice::passkeyDisplayCallback); + //_ble.securityManager().onSecuritySetupCompleted(this, &SMDevice::securitySetupCompletedCallback); /* start test in 500 ms */ _event_queue.call_in(500, this, &SMDevice::start); @@ -294,8 +296,19 @@ } +/** Send data aynchronously using BLE */ +void SMDevice::sendBLEUartData(char * str) +{ + Gap::GapState_t gapState = _ble.gap().getState(); + if(gapState.connected){ + uart->writeString(str); + uart->writeString("\n"); //flushes uart output buffer and sends data + } +} + + /** - * This callback allows the LEDService to receive updates to the ledState Characteristic. + * This callback allows the UARTService to receive updates. * * @param[in] params * Information about the characterisitc being updated. @@ -326,6 +339,10 @@ } } + + + + /** Blink LED to show we're running */ void SMDevice::blink(void) { @@ -346,16 +363,6 @@ strncpy(connStr, " Connected ", 20); } printf("\n Advertising Status = %s\n Connection Status = %s\n", advStr, connStr); - unsigned nLen; - ble_error_t error; - error = _ble.gap().getDeviceName((uint8_t *) devName, &nLen); - if(error != BLE_ERROR_NONE) - { - printf("\n Error Reading BLE device Name \n"); - return; - } - devName[nLen] = NULL; - printf("\n BLE Device name = %s : Name Len %d\n", devName, nLen); } @@ -379,8 +386,8 @@ /* add device name */ advertising_data.addData( GapAdvertisingData::COMPLETE_LOCAL_NAME, - DEVICE_NAME, - sizeof(DEVICE_NAME) + (const uint8_t *)ble_config.deviceName, + sizeof(ble_config.deviceName) ); /* Setup primary service */ uart = new UARTService(_ble);