uint32_t ble_gap_lesc_oob_data_get_rsp_enc(uint32_t                     return_code,
                                           ble_gap_lesc_oob_data_t    * p_oobd_own,
                                           uint8_t * const              p_buf,
                                           uint32_t * const             p_buf_len)
{
    SER_ASSERT_NOT_NULL(p_buf);
    SER_ASSERT_NOT_NULL(p_buf_len);

    uint32_t buflen   = *p_buf_len;
    uint32_t err_code = ser_ble_cmd_rsp_status_code_enc(SD_BLE_GAP_LESC_OOB_DATA_GET, return_code,
                                                        p_buf, p_buf_len);
    SER_ASSERT(err_code == NRF_SUCCESS, err_code);

    uint32_t index = *p_buf_len;

    if (return_code != NRF_SUCCESS)
    {
        return NRF_SUCCESS;
    }

    err_code = cond_field_enc(p_oobd_own, p_buf, buflen, &index, ble_gap_lesc_oob_data_t_enc);
    SER_ASSERT(err_code == NRF_SUCCESS, err_code);

    *p_buf_len = index;

    return err_code;
}
Ejemplo n.º 2
0
uint32_t ant_crypto_info_get_rsp_enc(uint32_t               return_code,
                                     uint8_t * const        p_buf,
                                     uint32_t * const       p_buf_len,
                                     uint8_t                type,
                                     uint8_t const * const  p_info)
{
    SER_ASSERT_NOT_NULL(p_buf);
    SER_ASSERT_NOT_NULL(p_buf_len);

    uint32_t total_len = *p_buf_len;

    uint32_t err_code = ser_ble_cmd_rsp_status_code_enc(SVC_ANT_CRYPTO_INFO_GET, return_code,
                                                        p_buf, p_buf_len);
    SER_ASSERT(err_code == NRF_SUCCESS, err_code);

    if (return_code != NRF_SUCCESS)
    {
        return NRF_SUCCESS;
    }

    err_code = uint8_t_enc(&type, p_buf, total_len, p_buf_len);
    SER_ASSERT(err_code == NRF_SUCCESS, err_code);

    uint8_t crypto_info_size = (MESG_CONFIG_ENCRYPT_REQ_CONFIG_USER_DATA_SIZE -
                                MESG_CHANNEL_NUM_SIZE);

    err_code = uint8_vector_enc(p_info, crypto_info_size, p_buf, total_len, p_buf_len);
    SER_ASSERT(err_code == NRF_SUCCESS, err_code);

    return NRF_SUCCESS;
}
uint32_t ble_gattc_char_value_by_uuid_read_rsp_enc(uint32_t         return_code,
                                                   uint8_t * const  p_buf,
                                                   uint32_t * const p_buf_len)
{
    return ser_ble_cmd_rsp_status_code_enc(SD_BLE_GATTC_CHAR_VALUE_BY_UUID_READ, return_code,
                                           p_buf, p_buf_len);
}
Ejemplo n.º 4
0
uint32_t ecb_block_encrypt_rsp_enc(uint32_t         return_code,
                                   uint8_t * const  p_buf,
                                   uint32_t * const p_buf_len,
                                   nrf_ecb_hal_data_t * const  p_ecb_data)
{
    SER_ASSERT_NOT_NULL(p_buf);
    SER_ASSERT_NOT_NULL(p_buf_len);

    uint32_t index    = 0;
    uint32_t err_code = NRF_SUCCESS;

    uint32_t total_len = *p_buf_len;

    err_code = ser_ble_cmd_rsp_status_code_enc(SD_ECB_BLOCK_ENCRYPT,
                                               return_code,
                                               p_buf,
                                               p_buf_len);
    SER_ASSERT(err_code == NRF_SUCCESS, err_code);
    index += *p_buf_len;

    if (return_code == NRF_SUCCESS)
    {
        err_code = cond_field_enc(p_ecb_data, p_buf, total_len, &index,nrf_ecb_hal_data_t_out_enc);
         SER_ASSERT(err_code == NRF_SUCCESS, err_code);
    }

    *p_buf_len = index;

    return err_code;
}
Ejemplo n.º 5
0
uint32_t ble_gap_appearance_get_rsp_enc(uint32_t               return_code,
                                        uint8_t * const        p_buf,
                                        uint32_t * const       p_buf_len,
                                        uint16_t const * const p_appearance)
{
    SER_ASSERT_NOT_NULL(p_buf);
    SER_ASSERT_NOT_NULL(p_buf_len);

    uint32_t total_len = *p_buf_len;

    uint32_t err_code = ser_ble_cmd_rsp_status_code_enc(SD_BLE_GAP_APPEARANCE_GET, return_code,
                                                        p_buf, p_buf_len);

    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    if (return_code != NRF_SUCCESS)
    {
        return NRF_SUCCESS;
    }

    SER_ASSERT_NOT_NULL(p_appearance);
    uint32_t index = *p_buf_len;

    SER_ASSERT_LENGTH_LEQ(index + sizeof (uint16_t), total_len);
    index += uint16_encode(*p_appearance, &p_buf[index]);

    *p_buf_len = index;

    return NRF_SUCCESS;
}
Ejemplo n.º 6
0
uint32_t ble_l2cap_cid_register_rsp_enc(uint32_t         return_code,
                                        uint8_t * const  p_buf,
                                        uint32_t * const p_buf_len)
{
    return ser_ble_cmd_rsp_status_code_enc(SD_BLE_L2CAP_CID_REGISTER, return_code,
                                           p_buf, p_buf_len);
}
Ejemplo n.º 7
0
uint32_t ble_gap_rssi_get_rsp_enc(uint32_t         return_code,
                                  uint8_t * const  p_buf,
                                  uint32_t * const p_buf_len,
                                  int8_t           rssi)
{
    SER_ASSERT_NOT_NULL(p_buf);
    SER_ASSERT_NOT_NULL(p_buf_len);

    uint32_t total_len = *p_buf_len;

    uint32_t err_code = ser_ble_cmd_rsp_status_code_enc(SD_BLE_GAP_RSSI_GET, return_code,
                                                        p_buf, p_buf_len);

    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    if (return_code != NRF_SUCCESS)
    {
        return NRF_SUCCESS;
    }

    uint32_t index = *p_buf_len;

    err_code = uint8_t_enc((uint8_t *) &rssi, p_buf, total_len, &index);
    SER_ASSERT(err_code == NRF_SUCCESS, err_code);

    *p_buf_len = index;

    return err_code;
}
Ejemplo n.º 8
0
uint32_t ble_version_get_rsp_enc(uint32_t                    return_code,
                                 uint8_t * const             p_buf,
                                 uint32_t * const            p_buf_len,
                                 ble_version_t const * const p_version)
{
    SER_ASSERT_NOT_NULL(p_buf);
    SER_ASSERT_NOT_NULL(p_buf_len);

    uint32_t total_len = *p_buf_len;

    uint32_t err_code = ser_ble_cmd_rsp_status_code_enc(SD_BLE_VERSION_GET, return_code,
                                                        p_buf, p_buf_len);

    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    if (return_code != NRF_SUCCESS)
    {
        return NRF_SUCCESS;
    }

    SER_ASSERT_NOT_NULL(p_version);
    uint32_t index = *p_buf_len;

    SER_ASSERT_LENGTH_LEQ(index + 5, total_len);
    p_buf[index++] = p_version->version_number;
    index         += uint16_encode(p_version->company_id, &p_buf[index]);
    index         += uint16_encode(p_version->subversion_number, &p_buf[index]);

    *p_buf_len = index;

    return NRF_SUCCESS;
}
uint32_t ble_gattc_descriptors_discover_rsp_enc(uint32_t         return_code,
        uint8_t * const  p_buf,
        uint32_t * const p_buf_len)
{
    return ser_ble_cmd_rsp_status_code_enc(SD_BLE_GATTC_DESCRIPTORS_DISCOVER,
                                           return_code, p_buf, p_buf_len);
}
uint32_t ble_gattc_relationships_discover_rsp_enc(uint32_t         return_code,
                                                  uint8_t * const  p_buf,
                                                  uint32_t * const p_buf_len)
{
    return ser_ble_cmd_rsp_status_code_enc(SD_BLE_GATTC_RELATIONSHIPS_DISCOVER,
                                           return_code, p_buf, p_buf_len);
}
Ejemplo n.º 11
0
uint32_t ble_uuid_vs_add_rsp_enc(uint32_t              return_code,
                                 uint8_t * const       p_buf,
                                 uint32_t * const      p_buf_len,
                                 uint8_t const * const p_uuid_type)
{
    SER_ASSERT_NOT_NULL(p_buf);
    SER_ASSERT_NOT_NULL(p_buf_len);

    uint32_t total_len = *p_buf_len;
    uint32_t err_code  = ser_ble_cmd_rsp_status_code_enc(SD_BLE_UUID_VS_ADD, return_code,
                                                         p_buf, p_buf_len);
    SER_ASSERT(err_code == NRF_SUCCESS, err_code);

    uint32_t index = *p_buf_len;

    if (return_code != NRF_SUCCESS)
    {
        return NRF_SUCCESS;
    }

    err_code = cond_field_enc((void *)p_uuid_type, p_buf, total_len, &index, uint8_t_enc);
    SER_ASSERT(err_code == NRF_SUCCESS, err_code);

    *p_buf_len = index;

    return err_code;
}
Ejemplo n.º 12
0
uint32_t ble_gap_device_name_get_rsp_enc(uint32_t              return_code,
                                         uint8_t const * const p_dev_name,
                                         uint16_t              dev_name_len,
                                         uint8_t * const       p_buf,
                                         uint32_t * const      p_buflen)
{
    SER_ASSERT_NOT_NULL(p_buf);
    SER_ASSERT_NOT_NULL(p_buflen);

    uint32_t buflen   = *p_buflen;
    uint32_t err_code = ser_ble_cmd_rsp_status_code_enc(SD_BLE_GAP_DEVICE_NAME_GET, return_code,
                                                        p_buf, p_buflen);
    uint32_t index = *p_buflen;

    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    if (return_code != NRF_SUCCESS)
    {
        return NRF_SUCCESS;
    }

    err_code = len16data_enc(p_dev_name, dev_name_len, p_buf, buflen, &index);

    *p_buflen = index;

    return err_code;
}
Ejemplo n.º 13
0
uint32_t temp_get_rsp_enc(uint32_t         return_code,
                          uint8_t * const  p_buf,
                          uint32_t * const p_buf_len,
                          int32_t * const  p_temp)
{
    SER_ASSERT_NOT_NULL(p_buf);
    SER_ASSERT_NOT_NULL(p_temp);
    SER_ASSERT_NOT_NULL(p_buf_len);

    uint32_t index    = 0;
    uint32_t err_code = NRF_SUCCESS;

    uint32_t total_len = *p_buf_len;

    err_code = ser_ble_cmd_rsp_status_code_enc(SD_TEMP_GET,
                                               return_code,
                                               p_buf,
                                               p_buf_len);
    SER_ASSERT(err_code == NRF_SUCCESS, err_code);
    index += *p_buf_len;

    if (return_code == NRF_SUCCESS)
    {
        err_code = uint32_t_enc(p_temp, p_buf, total_len, &index);
        SER_ASSERT(err_code == NRF_SUCCESS, err_code);
    }

    *p_buf_len = index;

    return err_code;
}
uint32_t ble_gap_device_name_set_rsp_enc(uint32_t         return_code,
                                         uint8_t * const  p_buf,
                                         uint32_t * const p_buf_len)
{
    return ser_ble_cmd_rsp_status_code_enc(SD_BLE_GAP_DEVICE_NAME_SET,
                                           return_code,
                                           p_buf,
                                           p_buf_len);
}
uint32_t ble_gattc_primary_services_discover_rsp_enc(uint32_t         return_code,
                                                     uint8_t * const  p_buf,
                                                     uint32_t * const p_buf_len)
{
    return ser_ble_cmd_rsp_status_code_enc(SD_BLE_GATTC_PRIMARY_SERVICES_DISCOVER,
                                           return_code,
                                           p_buf,
                                           p_buf_len);
}
Ejemplo n.º 16
0
uint32_t ble_opt_get_rsp_enc(uint32_t                return_code,
                             uint8_t * const         p_buf,
                             uint32_t * const        p_buf_len,
                             uint32_t 				       opt_id,
                             ble_opt_t const * const p_opt)
{
    SER_ASSERT_NOT_NULL(p_buf);
    SER_ASSERT_NOT_NULL(p_buf_len);
    uint32_t total_len = *p_buf_len;

    uint32_t err_code = ser_ble_cmd_rsp_status_code_enc(SD_BLE_OPT_GET, return_code,
                                                        p_buf, p_buf_len);

    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    if (return_code != NRF_SUCCESS)
    {
        return NRF_SUCCESS;
    }

    SER_ASSERT_NOT_NULL(p_opt);
    SER_ASSERT(((opt_id == BLE_GAP_OPT_LOCAL_CONN_LATENCY) ||
                (opt_id == BLE_GAP_OPT_PASSKEY) ||
                (opt_id == BLE_GAP_OPT_PRIVACY)), NRF_ERROR_INVALID_PARAM);

    uint32_t index = *p_buf_len;
    err_code = uint32_t_enc(&opt_id, p_buf, total_len, &index);
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    switch (opt_id)
    {
      case BLE_GAP_OPT_LOCAL_CONN_LATENCY:
         err_code = ble_gap_opt_local_conn_latency_t_enc((void *)&(p_opt->gap.local_conn_latency), p_buf, total_len, &index);
      break;
      case BLE_GAP_OPT_PASSKEY:
         err_code = ble_gap_opt_passkey_t_enc( (void *)&(p_opt->gap.passkey), p_buf, total_len, &index );
      break;
      case BLE_GAP_OPT_PRIVACY:
         err_code = ble_gap_opt_privacy_t_enc( (void *)&(p_opt->gap.privacy), p_buf, total_len, &index );
      break;
    }

    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    *p_buf_len = index;

    return NRF_SUCCESS;
}
Ejemplo n.º 17
0
uint32_t ble_gap_keypress_notify_rsp_enc(uint32_t                     return_code,
                                          uint8_t * const              p_buf,
                                          uint32_t * const             p_buf_len)
{
    uint32_t err_code = NRF_SUCCESS;

    err_code = ser_ble_cmd_rsp_status_code_enc(SD_BLE_GAP_KEYPRESS_NOTIFY,
                                               return_code,
                                               p_buf,
                                               p_buf_len);

    return err_code;
}
Ejemplo n.º 18
0
uint32_t ble_gap_lesc_dhkey_reply_rsp_enc(uint32_t                     return_code,
                                          uint8_t * const              p_buf,
                                          uint32_t * const             p_buf_len)
{
    uint32_t err_code = NRF_SUCCESS;

    err_code = ser_ble_cmd_rsp_status_code_enc(SD_BLE_GAP_LESC_DHKEY_REPLY,
                                               return_code,
                                               p_buf,
                                               p_buf_len);

    return err_code;
}
Ejemplo n.º 19
0
uint32_t ant_coex_config_get_rsp_enc(uint32_t               return_code,
                                     uint8_t * const        p_buf,
                                     uint32_t * const       p_buf_len,
                                     ANT_BUFFER_PTR * const p_coex_config,
                                     ANT_BUFFER_PTR * const p_adv_coex_config)
{
    SER_ASSERT_NOT_NULL(p_buf);
    SER_ASSERT_NOT_NULL(p_buf_len);

    uint32_t total_len = *p_buf_len;

    uint32_t err_code = ser_ble_cmd_rsp_status_code_enc(SVC_ANT_COEX_CONFIG_GET, return_code,
                                                        p_buf, p_buf_len);
    SER_ASSERT(err_code == NRF_SUCCESS, err_code);

    if (return_code != NRF_SUCCESS)
    {
        return NRF_SUCCESS;
    }

    err_code = uint8_t_enc(&(p_coex_config->ucBufferSize), p_buf, total_len, p_buf_len);
    SER_ASSERT(err_code == NRF_SUCCESS, err_code);

    err_code = uint8_vector_enc(p_coex_config->pucBuffer,
                                p_coex_config->ucBufferSize,
                                p_buf,
                                total_len,
                                p_buf_len);
    SER_ASSERT(err_code == NRF_SUCCESS, err_code);

    err_code = uint8_t_enc(&(p_adv_coex_config->ucBufferSize), p_buf, total_len, p_buf_len);
    SER_ASSERT(err_code == NRF_SUCCESS, err_code);

    err_code = uint8_vector_enc(p_adv_coex_config->pucBuffer,
                                p_adv_coex_config->ucBufferSize,
                                p_buf,
                                total_len,
                                p_buf_len);
    SER_ASSERT(err_code == NRF_SUCCESS, err_code);

    return NRF_SUCCESS;
}
Ejemplo n.º 20
0
uint32_t ble_gatts_value_get_rsp_enc(uint32_t         return_code,
                                     uint8_t * const  p_buf,
                                     uint32_t * const p_buf_len,
                                     uint8_t * const  p_value,
                                     uint16_t * const p_value_len)
{
    SER_ASSERT_NOT_NULL(p_buf);
    SER_ASSERT_NOT_NULL(p_buf_len);

    SER_ASSERT_LENGTH_LEQ(SER_CMD_RSP_HEADER_SIZE, *p_buf_len);

    uint32_t total_len = *p_buf_len;

    uint32_t err_code = ser_ble_cmd_rsp_status_code_enc(SD_BLE_GATTS_VALUE_GET,
                                                        return_code,
                                                        p_buf,
                                                        p_buf_len);

    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    uint32_t index = *p_buf_len;

    if (return_code == NRF_SUCCESS) /* Add value and it's length. */
    {
        err_code = cond_field_enc(p_value_len, p_buf, total_len, &index, uint16_t_enc);
        SER_ASSERT(err_code == NRF_SUCCESS, err_code);

        uint16_t value_len = (p_value_len) ? *p_value_len : 0;

        err_code = buf_enc(p_value, value_len, p_buf, total_len, &index);
        SER_ASSERT(err_code == NRF_SUCCESS, err_code);

    }

    *p_buf_len = index;

    return NRF_SUCCESS;
}
Ejemplo n.º 21
0
uint32_t ble_opt_set_rsp_enc(uint32_t                return_code,
                             uint8_t * const         p_buf,
                             uint32_t * const        p_buf_len)
{
    SER_ASSERT_NOT_NULL(p_buf);
    SER_ASSERT_NOT_NULL(p_buf_len);

    uint32_t err_code = ser_ble_cmd_rsp_status_code_enc(SD_BLE_OPT_SET, return_code,
                                                        p_buf, p_buf_len);

    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    if (return_code != NRF_SUCCESS)
    {
        return NRF_SUCCESS;
    }

    return NRF_SUCCESS;
}
Ejemplo n.º 22
0
uint32_t ble_gap_ppcp_get_rsp_enc(uint32_t                            return_code,
                                  uint8_t * const                     p_buf,
                                  uint32_t * const                    p_buf_len,
                                  ble_gap_conn_params_t const * const p_conn_params)
{
    SER_ASSERT_NOT_NULL(p_buf);
    SER_ASSERT_NOT_NULL(p_buf_len);

    uint32_t total_len = *p_buf_len;

    uint32_t err_code = ser_ble_cmd_rsp_status_code_enc(SD_BLE_GAP_PPCP_GET, return_code,
                                                        p_buf, p_buf_len);

    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    if (return_code != NRF_SUCCESS)
    {
        return NRF_SUCCESS;
    }

    SER_ASSERT_NOT_NULL(p_conn_params);
    uint32_t index = *p_buf_len;

    SER_ASSERT_LENGTH_LEQ(index + 8, total_len);

    index += uint16_encode(p_conn_params->min_conn_interval, &p_buf[index]);
    index += uint16_encode(p_conn_params->max_conn_interval, &p_buf[index]);
    index += uint16_encode(p_conn_params->slave_latency, &p_buf[index]);
    index += uint16_encode(p_conn_params->conn_sup_timeout, &p_buf[index]);

    *p_buf_len = index;

    return NRF_SUCCESS;
}
Ejemplo n.º 23
0
uint32_t ble_gatts_descriptor_add_rsp_enc(uint32_t         return_code,
                                          uint8_t * const  p_buf,
                                          uint32_t * const p_buf_len,
                                          uint16_t         handle)
{
    SER_ASSERT_NOT_NULL(p_buf);
    SER_ASSERT_NOT_NULL(p_buf_len);

    uint32_t total_len = *p_buf_len;

    SER_ASSERT_LENGTH_LEQ(SER_CMD_HEADER_SIZE + 4, total_len);
    uint32_t err_code = ser_ble_cmd_rsp_status_code_enc(SD_BLE_GATTS_DESCRIPTOR_ADD,
                                                        return_code,
                                                        p_buf,
                                                        p_buf_len);

    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    if (return_code != NRF_SUCCESS)
    {
        return NRF_SUCCESS;
    }

    uint32_t index = *p_buf_len;

    SER_ASSERT_LENGTH_LEQ(index + 2, total_len);

    err_code = uint16_t_enc(&handle, p_buf, total_len, &index);
    SER_ASSERT(err_code == NRF_SUCCESS, err_code);

    *p_buf_len = index;

    return err_code;
}
Ejemplo n.º 24
0
uint32_t ant_version_get_rsp_enc(uint32_t              return_code,
                                 uint8_t * const       p_buf,
                                 uint32_t * const      p_buf_len,
                                 uint8_t const * const p_version)
{
    SER_ASSERT_NOT_NULL(p_buf);
    SER_ASSERT_NOT_NULL(p_buf_len);

    uint32_t total_len = *p_buf_len;

    uint32_t err_code = ser_ble_cmd_rsp_status_code_enc(SVC_ANT_VERSION, return_code,
                                                        p_buf, p_buf_len);
    SER_ASSERT(err_code == NRF_SUCCESS, err_code);

    if (return_code != NRF_SUCCESS)
    {
        return NRF_SUCCESS;
    }

    err_code = uint8_vector_enc(p_version, MESG_BUFFER_SIZE, p_buf, total_len, p_buf_len);
    SER_ASSERT(err_code == NRF_SUCCESS, err_code);

    return NRF_SUCCESS;
}
Ejemplo n.º 25
0
uint32_t ant_channel_radio_freq_get_rsp_enc(uint32_t               return_code,
                                            uint8_t * const        p_buf,
                                            uint32_t * const       p_buf_len,
                                            uint8_t const * const  p_r_freq)
{
    SER_ASSERT_NOT_NULL(p_buf);
    SER_ASSERT_NOT_NULL(p_buf_len);

    uint32_t total_len = *p_buf_len;

    uint32_t err_code = ser_ble_cmd_rsp_status_code_enc(SVC_ANT_CHANNEL_RADIO_FREQ_GET, return_code,
                                                        p_buf, p_buf_len);
    SER_ASSERT(err_code == NRF_SUCCESS, err_code);

    if (return_code != NRF_SUCCESS)
    {
        return NRF_SUCCESS;
    }

    err_code = uint8_t_enc(p_r_freq, p_buf, total_len, p_buf_len);
    SER_ASSERT(err_code == NRF_SUCCESS, err_code);

    return NRF_SUCCESS;
}
Ejemplo n.º 26
0
uint32_t ant_capabilities_get_rsp_enc(uint32_t              return_code,
                                      uint8_t * const       p_buf,
                                      uint32_t * const      p_buf_len,
                                      uint8_t const * const p_capabilities)
{
    SER_ASSERT_NOT_NULL(p_buf);
    SER_ASSERT_NOT_NULL(p_buf_len);

    uint32_t total_len = *p_buf_len;

    uint32_t err_code = ser_ble_cmd_rsp_status_code_enc(SVC_ANT_CAPABILITIES, return_code,
                                                        p_buf, p_buf_len);
    SER_ASSERT(err_code == NRF_SUCCESS, err_code);

    if (return_code != NRF_SUCCESS)
    {
        return NRF_SUCCESS;
    }

    err_code = uint8_vector_enc(p_capabilities, MESG_CAPABILITIES_SIZE, p_buf, total_len, p_buf_len);
    SER_ASSERT(err_code == NRF_SUCCESS, err_code);

    return NRF_SUCCESS;
}
Ejemplo n.º 27
0
uint32_t ble_gatts_value_get_rsp_enc(uint32_t                   return_code,
                                     uint8_t * const            p_buf,
                                     uint32_t * const           p_buf_len,
                                     ble_gatts_value_t * const  p_value)
{
    SER_ASSERT_NOT_NULL(p_buf);
    SER_ASSERT_NOT_NULL(p_buf_len);

    SER_ASSERT_LENGTH_LEQ(SER_CMD_RSP_HEADER_SIZE, *p_buf_len);

    uint32_t total_len = *p_buf_len;

    uint32_t err_code = ser_ble_cmd_rsp_status_code_enc(SD_BLE_GATTS_VALUE_GET,
                                                        return_code,
                                                        p_buf,
                                                        p_buf_len);

    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    uint32_t index = *p_buf_len;

    if (return_code == NRF_SUCCESS)
    {
        SER_ASSERT_NOT_NULL(p_value);

        err_code = ble_gatts_value_t_enc(p_value, p_buf, total_len, &index);
        SER_ASSERT(err_code == NRF_SUCCESS, err_code);
    }

    *p_buf_len = index;

    return err_code;
}
Ejemplo n.º 28
0
uint32_t ble_gap_adv_start_rsp_enc(uint32_t         return_code,
                                   uint8_t * const  p_buf,
                                   uint32_t * const p_buf_len)
{
    return ser_ble_cmd_rsp_status_code_enc(SD_BLE_GAP_ADV_START, return_code, p_buf, p_buf_len);
}
uint32_t ble_gap_authenticate_rsp_enc(uint32_t         return_code,
                                      uint8_t * const  p_buf,
                                      uint32_t * const p_buf_len)
{
    return ser_ble_cmd_rsp_status_code_enc(SD_BLE_GAP_AUTHENTICATE, return_code, p_buf, p_buf_len);
}
uint32_t ble_gap_disconnect_rsp_enc(uint32_t         return_code,
                                    uint8_t * const  p_buf,
                                    uint32_t * const p_buf_len)
{
    return ser_ble_cmd_rsp_status_code_enc(SD_BLE_GAP_DISCONNECT, return_code, p_buf, p_buf_len);
}