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

How to display more number of bits on the nrfcloud?

I have set up an environment to upload data to the nrfcloud using nrfconnect and the nrf52 dk.I can only upload data upto ff and then it resets to zero .The value which i am uploading is an integer value, so i want to display numbers from 0 to atleast 32000 on the cloud.Here is an image of the cloud so far.I have used the code in this page to upload data using notification to the cloud.How must i increase the number of bits which is 00 to 0000 on the service where maximum value will be 65585.Do i have to do changes in the code?please help

here is the notification handler code.

static void notification_timeout_handler(void * p_context)
{
UNUSED_PARAMETER(p_context);
ret_code_t err_code;

// Increment the value of m_custom_value before nortifing it.
m_custom_value=pulses;                                                         ///where pulses is of type integer

err_code = ble_cus_custom_value_update(&m_cus, m_custom_value);
APP_ERROR_CHECK(err_code);
}

and the ble_cus_custom_value_update() code is

uint32_t ble_cus_custom_value_update(ble_cus_t * p_cus, uint8_t custom_value)

{
if (p_cus == NULL)
{
return NRF_ERROR_NULL;
}
/* This code belongs in ble_cus_custom_value_update() in ble_cus.c*/

uint32_t err_code = NRF_SUCCESS;
ble_gatts_value_t gatts_value;

// Initialize value struct.
memset(&gatts_value, 0, sizeof(gatts_value));

gatts_value.len = sizeof(uint8_t);
gatts_value.offset = 0;
gatts_value.p_value = &custom_value;

// Update database.
err_code = sd_ble_gatts_value_set(p_cus->conn_handle,
p_cus->custom_value_handles.value_handle,
&gatts_value);
if (err_code != NRF_SUCCESS)
{
return err_code;
}
/* This code belongs in ble_cus_custom_value_update() in ble_cus.c*/

// Send value if connected and notifying.
if ((p_cus->conn_handle != BLE_CONN_HANDLE_INVALID))
{
ble_gatts_hvx_params_t hvx_params;

memset(&hvx_params, 0, sizeof(hvx_params));

hvx_params.handle = p_cus->custom_value_handles.value_handle;
hvx_params.type = BLE_GATT_HVX_NOTIFICATION;
hvx_params.offset = gatts_value.offset;
hvx_params.p_len = &gatts_value.len;
hvx_params.p_data = gatts_value.p_value;

err_code = sd_ble_gatts_hvx(p_cus->conn_handle, &hvx_params);
}
else
{
err_code = NRF_ERROR_INVALID_STATE;
}

return err_code;

}

Parents Reply Children
No Data
Related