コード例 #1
0
uint32_t sd_ble_gap_device_name_get(adapter_t *adapter, uint8_t *const p_dev_name,
                                    uint16_t *const p_len)
{
    encode_function_t encode_function = [&](uint8_t *buffer, uint32_t *length) -> uint32_t {
        return ble_gap_device_name_get_req_enc(p_dev_name, p_len, buffer, length);
    };

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

    return gap_encode_decode(adapter, encode_function, decode_function);
}
コード例 #2
0
ファイル: app_mw_ble_gap.c プロジェクト: BLEHexapod/nrf_sdk
uint32_t sd_ble_gap_device_name_get(uint8_t * const p_dev_name, uint16_t * const p_len)
{
    uint8_t * p_buffer;
    uint32_t  buffer_length = 0;

    tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length);
    m_output_params.gap_device_name_get_out_params.p_dev_name = p_dev_name;
    m_output_params.gap_device_name_get_out_params.p_len      = p_len;

    const uint32_t err_code = ble_gap_device_name_get_req_enc(p_dev_name,
                                                              p_len,
                                                              &(p_buffer[1]),
                                                              &buffer_length);
    //@note: Should never fail.
    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),
                                      gap_device_name_get_rsp_dec);
}