Exemplo n.º 1
0
uint32_t sd_ble_gatts_service_add(adapter_t *adapter, uint8_t type, ble_uuid_t const *p_uuid, uint16_t *p_handle)
{
    encode_function_t encode_function = [&] (uint8_t *buffer, uint32_t *length) -> uint32_t {
        return ble_gatts_service_add_req_enc(type, p_uuid, p_handle, buffer, length);
    };

    decode_function_t decode_function = [&] (uint8_t *buffer, uint32_t length, uint32_t *result) -> uint32_t {
        return ble_gatts_service_add_rsp_dec(buffer, length, p_handle, result);
    };

    return encode_decode(adapter, encode_function, decode_function);
}
Exemplo n.º 2
0
uint32_t sd_ble_gatts_service_add(uint8_t                  type,
                                  ble_uuid_t const * const p_uuid,
                                  uint16_t * const         p_handle)
{
    uint8_t * p_buffer;
    uint32_t  buffer_length = 0;

    tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length);
    mp_out_params[0] = p_handle;

    const uint32_t err_code = ble_gatts_service_add_req_enc(type,
                              p_uuid,
                              p_handle,
                              &(p_buffer[1]),
                              &buffer_length);
    APP_ERROR_CHECK(err_code);

    //@note: Increment buffer length as internally managed packet type field must be included.
    return ser_sd_transport_cmd_write(p_buffer,
                                      (++buffer_length),
                                      gatts_service_add_rsp_dec);
}