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

Reset chip on write

Hi,

How to reset the system whenever a particular write event is received from the BLE stack. I made some changes on the ble_app_hrs sample code as follows,

void ble_hrs_on_ble_evt(ble_hrs_t * p_hrs, ble_evt_t * p_ble_evt)

case BLE_GATTS_EVT_WRITE:

			led_start();
			on_write(p_hrs, p_ble_evt);
		        **sd_nvic_SystemReset();**
		         break;

Actually my idea is to blink the led when the write event occurs, and also do system reset when the write completed.

but when i call sd_nvic_SystemReset the error will be,

._build\ble_app_hrs.axf: Error: L6218E: Undefined symbol sd_nvic_SystemReset (referred from ble_hrs.o).

How to differentiate the write characteristics received by BLE stack?

In our project we are going to use lot of proprietary write characterisctics

device name, device settings, device firmware update, etc..

we need the device firmware update characteristics write event should rest the device and enter in to DFU (device firmware update) mode

how to modify the bootloader sample application to enter into the bootloader mode without pressing any button when the system reset occurs?

Regards, Balaji

  • The sd_nvic_SystemReset() method is defined in nrf_soc.h, so if you want to use it from ble_hrs.c, you have to include that header file in the top of the source code file.

    To know which characteristic was written, you must look at the handle of the write event structure. This could for example look something like this, although it doesn't make much sense as is:

    
        ble_gatts_evt_write_t * p_evt_write = &p_ble_evt->evt.gatts_evt.params.write;
        
        if ((p_evt_write->handle == p_your_service->your_characteristic.value_handle) &&
                 (p_evt_write->data[0] == YOUR_SERVICE_RESET_COMMAND))
        {
            sd_nvic_SystemReset();
        }
    
    

    The handle used here should be the handle returned in the last parameter of sd_ble_gatts_characteristic_add().

    Edit: I also edited your question title to make it more clear what it is about. For information on how to modify the bootloader as you want, take a look at this question.

Related