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

Sending 32 bit of data from nrf52 ble moble app onto nrf52833

swathi p

Hi,

I have used "write_handler(p_ble_evt->evt.gap_evt.conn_handle, p_rtc_service, p_evt_write->data[0]);" to send data to nrf52832 from nrfconnect mobile app but iam able to send  1 byte data as it is meant to be predefined in the gatts structure .

/*brief Event structure for @ref BLE_GATTS_EVT_WRITE. */
typedef struct
{
uint16_t handle; /**< Attribute Handle. */
ble_uuid_t uuid; /**< Attribute UUID. */
uint8_t op; /**< Type of write operation, see @ref BLE_GATTS_OPS. */
uint8_t auth_required; /**< Writing operation deferred due to authorization requirement. Application may use @ref sd_ble_gatts_value_set to finalize the writing operation. */
uint16_t offset; /**< Offset for the write operation. */
uint16_t len; /**< Length of the received data. */
uint8_t data[1]; /**< Received data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
 */
} ble_gatts_evt_write_t;

In many nordic forum told that  you have to split the 32 bit data into an array of uint8_t(s) and and set that array equal to ble_gatts_evt_write_t ->data. ble_gatts_evt_write_t ->len .

But my query is that when i putting the value in nrf connect app  in unknown characteristics and write the value there as in uint32_t form for eg:653655  and the recieving the data in nrf52833 as 

p_evt_write->data[0] which is uint8_t  data[0]  unable to receive the data properly.please give the example or what changes i have to do so that receive the data properly.

Parents
  • Hi,

    How did you Initialize this characteristic?

    What did you set add_char_params.max_len  / attr_char_value.max_len to ?

    Example snippet from LBS service:

        // Add LED characteristic.
        memset(&add_char_params, 0, sizeof(add_char_params));
        add_char_params.uuid             = LBS_UUID_LED_CHAR;
        add_char_params.uuid_type        = p_lbs->uuid_type;
        add_char_params.init_len         = sizeof(uint8_t);
        add_char_params.max_len          = sizeof(uint8_t);
        add_char_params.char_props.read  = 1;
        add_char_params.char_props.write = 1;
    
        add_char_params.read_access  = SEC_OPEN;
        add_char_params.write_access = SEC_OPEN;
    
        return characteristic_add(p_lbs->service_handle, &add_char_params, &p_lbs->led_char_handles);

Reply
  • Hi,

    How did you Initialize this characteristic?

    What did you set add_char_params.max_len  / attr_char_value.max_len to ?

    Example snippet from LBS service:

        // Add LED characteristic.
        memset(&add_char_params, 0, sizeof(add_char_params));
        add_char_params.uuid             = LBS_UUID_LED_CHAR;
        add_char_params.uuid_type        = p_lbs->uuid_type;
        add_char_params.init_len         = sizeof(uint8_t);
        add_char_params.max_len          = sizeof(uint8_t);
        add_char_params.char_props.read  = 1;
        add_char_params.char_props.write = 1;
    
        add_char_params.read_access  = SEC_OPEN;
        add_char_params.write_access = SEC_OPEN;
    
        return characteristic_add(p_lbs->service_handle, &add_char_params, &p_lbs->led_char_handles);

Children
Related