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

lis3dh Sensor on BLE Notify issues

Hey , I'm trying to implement a device that waits for the clicks from the user and sends it over ble as notifications. i have written the header files for sensor . and from the sensor header file i call this fuction when ever a click is detected.

	SEGGER_RTT_WriteString(0,"Click Detected\n");
	X = 1;
	 err_code = ble_mcs_on_click(&p_mcs,X);
	if (err_code != NRF_SUCCESS &&
                err_code != BLE_ERROR_INVALID_CONN_HANDLE &&
                err_code != NRF_ERROR_INVALID_STATE)
            {
                APP_ERROR_CHECK(err_code);
            }
	SEGGER_RTT_WriteString(0, "Written....\n");

and the ble_mcs_on_click() is below as follows:

uint32_t ble_mcs_on_click(ble_mcs_t * p_mcs, uint8_t button_state)

{

    ble_gatts_hvx_params_t params;
    uint16_t len = sizeof(button_state);
		char recieved_data[20];    
    memset(&params, 0, sizeof(params));
    params.type = BLE_GATT_HVX_NOTIFICATION;
    params.handle = p_mcs->click_char_handles.value_handle;
    params.p_data = &button_state;
    params.p_len = &len;
    sprintf(recieved_data,"Click:%d\n",*params.p_data);
    SEGGER_RTT_WriteString(0, recieved_data);
    return sd_ble_gatts_hvx(p_mcs->conn_handle, &params);

}

The problem is : after enabling notification in MCP , i dont receive any data on notification. Can anyone please tell where i'm going wrong? Thanks

Related