
fork test
Dependencies: BLE_API WIFI_API_32kRAM mbed nRF51822
Fork of NNN40_CLI by
Diff: CLI_Source/ble_cli.cpp
- Revision:
- 6:1243f9e584f4
- Parent:
- 5:ee474e3133eb
- Child:
- 7:33214585c606
--- a/CLI_Source/ble_cli.cpp Wed Dec 09 11:31:59 2015 +0000 +++ b/CLI_Source/ble_cli.cpp Wed Jan 20 06:42:09 2016 +0000 @@ -10,7 +10,7 @@ #include <stdint.h> #include <string.h> #include "command-interpreter.h" -#include "simple_uart.h" +//#include "simple_uart.h" #include "mbed.h" #include "BLE.h" #include "Gap.h" @@ -41,7 +41,7 @@ #define CLI_CHAR_MAX_NUM 10 #define MAX_VALUE_LENGTH 20 -#define CLI_FWVERION "DELTA_CLI_V1.7" +#define CLI_FWVERION "DELTA_CLI_V1.8" #define MODULE_NAME "DFCM-NNN40-DT1R" #define ADVERTISING_LED_PIN_NO LED1 //#define BLE_DEBUG @@ -88,7 +88,7 @@ static uint8_t bleDevInd; //static Gap::GapState_t nowState; static char targetDevName[TARGET_DEVNAME_LEN]; -static char DEVICE_NAME[] = "nRF5x"; // default device name, same as defined in Gap.h +//static char DEVICE_NAME[] = "nRF5x"; // default device name, same as defined in Gap.h static bool conn_action = false; // Gill add 20151015 static GattCharacteristic *charAry[CLI_SERVICE_MAX_NUM][CLI_CHAR_MAX_NUM]; @@ -161,9 +161,6 @@ } void onDataWrittenCallback(const GattWriteCallbackParams *params) { - //if ((params->handle == ledServicePtr->getValueHandle()) && (params->len == 1)) { -// actuatedLED = *(params->data); -// } #ifdef BLE_DEBUG console.printf("onDataWritten\r\n"); #endif @@ -219,10 +216,17 @@ #ifdef BLE_DEBUG console.printf("advInterval:%d,advTimeout:%d",advInterval,advTimeout); #endif - //uint16_t uuid16_list[] = {0x0001}; + uint8_t bleName[BLE_GAP_DEVNAME_MAX_LEN] = {"\0"}; + uint16_t bleLen = BLE_GAP_DEVNAME_MAX_LEN - APP_ADV_DATA_OFFSET; + uint32_t err_code; + + err_code = sd_ble_gap_device_name_get(&bleName[APP_ADV_DATA_OFFSET], &bleLen); +#ifdef BLE_DEBUG + console.printf("%08X,%s\r\n",err_code,bleName+APP_ADV_DATA_OFFSET); +#endif deltaBLE.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE); //deltaBLE.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list)); - deltaBLE.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME)); + deltaBLE.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, bleName+APP_ADV_DATA_OFFSET, bleLen); deltaBLE.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED); deltaBLE.gap().setAdvertisingInterval(advInterval); /* minisecond. */ deltaBLE.gap().setAdvertisingTimeout(advTimeout); /* second. */ @@ -275,7 +279,7 @@ } else { console.printf("ERROR;%04X\r\n",err_code); } - APP_ERROR_CHECK(err_code); + //APP_ERROR_CHECK(err_code); //#ifdef BLE_DEBUG //console.printf("\r\nSet BLE Name: "); // uint8_t i = 0; @@ -293,7 +297,7 @@ uint32_t err_code; err_code = sd_ble_gap_device_name_get(&bleName[APP_ADV_DATA_OFFSET], &bleLen); - APP_ERROR_CHECK(err_code); + //APP_ERROR_CHECK(err_code); console.printf("\r\nOK;"); console.printf("%s",bleName+APP_ADV_DATA_OFFSET); @@ -340,7 +344,7 @@ for (i = 0; i < NUM_TXPOW; i++) { if (setValue == validTxPow[i]) { err_code = sd_ble_gap_tx_power_set(setValue); - APP_ERROR_CHECK(err_code); + //APP_ERROR_CHECK(err_code); inputSwitch = true; break; } @@ -380,7 +384,7 @@ } err_code = sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_NONE, &m_peer_addr); - APP_ERROR_CHECK(err_code); + //APP_ERROR_CHECK(err_code); } else { //argLen != 14 cyntecPrintError(CYNTEC_CMD_ERR_ARGUMENT_SYNTAX_ERROR); @@ -401,7 +405,7 @@ uint32_t err_code; err_code = sd_ble_gap_address_get(&m_peer_addr); - APP_ERROR_CHECK(err_code); + //APP_ERROR_CHECK(err_code); cyntecPrintOk();