Example #1
0
uint32_t sd_ble_gatts_characteristic_add(adapter_t *adapter, uint16_t service_handle, ble_gatts_char_md_t const *p_char_md, ble_gatts_attr_t const *p_attr_char_value, ble_gatts_char_handles_t *p_handles)
{
    encode_function_t encode_function = [&] (uint8_t *buffer, uint32_t *length) -> uint32_t {
        return ble_gatts_characteristic_add_req_enc(service_handle, p_char_md, p_attr_char_value, p_handles, buffer, length);
    };

    decode_function_t decode_function = [&] (uint8_t *buffer, uint32_t length, uint32_t *result) -> uint32_t {
        uint16_t * handles = &p_handles->value_handle;
        return ble_gatts_characteristic_add_rsp_dec(buffer, length, &handles, result);
    };

    return encode_decode(adapter, encode_function, decode_function);
}
Example #2
0
/**@brief Command response callback function for @ref sd_ble_gatts_characteristic_add BLE command.
 *
 * Callback for decoding the output parameters and the command response return code.
 *
 * @param[in] p_buffer  Pointer to begin of command response buffer.
 * @param[in] length    Length of data in bytes.
 *
 * @return Decoded command response return code.
 */
static uint32_t gatts_characteristic_add_rsp_dec(const uint8_t * p_buffer, uint16_t length)
{
    uint32_t result_code;

    const uint32_t err_code = ble_gatts_characteristic_add_rsp_dec(
                                  p_buffer,
                                  length,
                                  (uint16_t * *)&mp_out_params[0],
                                  &result_code);

    APP_ERROR_CHECK(err_code);

    return result_code;
}