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

Encoded time object record sent does not match what is received

Figure 1. Data encoded and sent (attached)

Figure 2. Screen shot of wrong Time data (attached)

Here is some code that seems to be correct, sending 10 bytes that look correct, but sniffer receiving it, shows otherwise.

The code is sending updates for a CTS Time Service, which should be 10 bytes, when I check the object before it is sent, it is 10 bytes. But sniffer shows more bytes, and is showing the handle 0x0d

As well as other stuff inserted into the time object. I am encoding the object but that did not help.

 

The code:

                len = cts_time_encode(&xtime, encoded_glm);

            hvx_len = len;

 

            ble_gatts_hvx_params_t hvx_params;

 

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

 

            hvx_params.handle = ctsserv_bas.current_time_handles.value_handle;

            hvx_params.type   = BLE_GATT_HVX_NOTIFICATION;

            hvx_params.offset = 0; //was: gatts_value.offset;

            hvx_params.p_len  = &hvx_len; //was: &gatts_value.len;

            hvx_params.p_data = encoded_glm; //was: gatts_value.p_value;

 

            err_code = sd_ble_gatts_hvx(ctsserv_bas.conn_handle, &hvx_params);

 

//encoding call

static uint8_t cts_time_encode(const current_time_char_t * p_time, uint8_t * p_encoded_buffer)

{

    uint8_t len = 0;

 

    len += ble_date_time_encode(&p_time->exact_time_256.day_date_time.date_time, &p_encoded_buffer[len]);

    p_encoded_buffer[len++] = (uint8_t) 0; //day of week unknown

    p_encoded_buffer[len++] = (uint8_t) 0; //256ths of a second

    p_encoded_buffer[len++] = (uint8_t) 2; //adjustment reason: external time source

 

    return len;

}

Parents Reply Children
No Data
Related