This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Disable BLE on mbed with nRF51822

Hi,

I use an nRF51822 QFAC A1 and my goal is to disable BLE in a powerdown mode, then when I press the pushbutton I want to restart BLE. Tried using BLEDevice::shutdown() function but when I restart BLE with BLEDevice::init(), the device can be scanned from the central but I am not able to see any service.

Here is the portion of code with the defined function :

BLEDevice ble;   
void BLE_Init()
    {
    	ble.init();
    	ble.onConnection(BLE_OnConnectionCb);
    	ble.onDisconnection(BLE_OnDisconnectionCb);


	//DeviceInformationService deviceInfo(ble, "WBT", "Model1", "SN1", "hw-rev1", "fw-rev1", "soft-rev1");

	ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
	ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t*)BLE_UUID_LIST, sizeof(BLE_UUID_LIST));
	ble.accumulateAdvertisingPayload(GapAdvertisingData::GENERIC_HEART_RATE_SENSOR);
	ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t*)BLE_FRIENDLY_NAME, sizeof(BLE_FRIENDLY_NAME));
	ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
	ble.setAdvertisingInterval(Gap::MSEC_TO_ADVERTISEMENT_DURATION_UNITS(1000));
	ble.startAdvertising();

	SensorService_Init(&ble);
}

void BLE_Shutdown()
{
	ble.shutdown();
}

Then in the main file we have this in the button interrupt callback :

switch(state)
	{
		case 0 :
			BLE_Shutdown();
			state = 0xFF;
			break;
         case 0xFF :
			BLE_Init();
            state = 0;
            break;
}

And finally in the main loop we have this :

switch(state){
           case 0: //Wait for Event state
				//Wait for measurement callback or sending buffer through BLE
				next_state = 0;
				BLE_WaitForEvent();
				break;
           case 0xFF : //Power down state
				deepsleep();
				break;
}

Could you tell me what is the origin of the problem and how to solve it ?

PS : I use mbed with SoftDevice S110 7.3.0

Best regards,

Guillaume

Parents Reply Children
No Data
Related