uint32_t ble_gatts_hvx_rsp_dec(uint8_t const * const p_buf, uint32_t packet_len, uint32_t * const p_result_code, uint16_t * * const pp_bytes_written) { SER_ASSERT_NOT_NULL(p_buf); SER_ASSERT_NOT_NULL(p_result_code); uint32_t err_code; uint32_t index = 0; uint32_t decode_result = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len, SD_BLE_GATTS_HVX, p_result_code); if (decode_result != NRF_SUCCESS) { return decode_result; } if (*p_result_code != NRF_SUCCESS) { SER_ASSERT_LENGTH_EQ(index, packet_len); return NRF_SUCCESS; } err_code = cond_field_dec(p_buf, packet_len, &index, (void * *)pp_bytes_written, uint16_t_dec); SER_ASSERT(err_code == NRF_SUCCESS, err_code); SER_ASSERT_LENGTH_EQ(index, packet_len); return NRF_SUCCESS; }
uint32_t ant_channel_radio_freq_get_rsp_dec(uint8_t const * const p_buf, uint32_t packet_len, void * const p_r_freq, uint32_t * const p_result_code) { SER_ASSERT_NOT_NULL(p_buf); SER_ASSERT_NOT_NULL(p_result_code); uint32_t index = 0; uint32_t err_code = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len, SVC_ANT_CHANNEL_RADIO_FREQ_GET, p_result_code); SER_ASSERT(err_code == NRF_SUCCESS, err_code); if (*p_result_code != NRF_SUCCESS) { SER_ASSERT_LENGTH_EQ(index, packet_len); return NRF_SUCCESS; } err_code = uint8_t_dec(p_buf, packet_len, &index, p_r_freq); SER_ASSERT(err_code == NRF_SUCCESS, err_code); SER_ASSERT_LENGTH_EQ(index, packet_len); return NRF_SUCCESS; }
uint32_t ble_tx_buffer_count_get_rsp_dec(uint8_t const * const p_buf, uint32_t packet_len, uint8_t * * const pp_count, uint32_t * const p_result_code) { SER_ASSERT_NOT_NULL(p_buf); SER_ASSERT_NOT_NULL(p_result_code); uint32_t index = 0; uint32_t err_code = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len, SD_BLE_TX_BUFFER_COUNT_GET, p_result_code); SER_ASSERT(err_code == NRF_SUCCESS, err_code); if (*p_result_code != NRF_SUCCESS) { SER_ASSERT_LENGTH_EQ(index, packet_len); return NRF_SUCCESS; } err_code = cond_field_dec(p_buf, packet_len, &index, (void * *)pp_count, uint8_t_dec); SER_ASSERT(err_code == NRF_SUCCESS, err_code); SER_ASSERT_LENGTH_EQ(index, packet_len); return NRF_SUCCESS; }
uint32_t ble_gap_sec_params_reply_rsp_dec(uint8_t const * const p_buf, uint32_t packet_len, ble_gap_sec_keyset_t const * const p_sec_keyset, uint32_t * const p_result_code) { SER_ASSERT_NOT_NULL(p_buf); SER_ASSERT_NOT_NULL(p_result_code); uint32_t err_code = NRF_SUCCESS; uint32_t index = 0; err_code = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len, SD_BLE_GAP_SEC_PARAMS_REPLY, p_result_code); if (err_code != NRF_SUCCESS) { return err_code; } if (*p_result_code != NRF_SUCCESS) { SER_ASSERT_LENGTH_EQ(index, packet_len); return NRF_SUCCESS; } //SER_ASSERT_NOT_NULL(p_sec_keyset); // Removed after input from KC 2016-03-11 err_code = cond_field_dec(p_buf, packet_len, &index, (void **)&p_sec_keyset, ble_gap_sec_keyset_t_dec); SER_ASSERT(err_code == NRF_SUCCESS, err_code); SER_ASSERT_LENGTH_EQ(index, packet_len); return err_code; }
uint32_t ble_opt_set_rsp_dec(uint8_t const * const p_buf, uint32_t packet_len, uint32_t * const p_result_code) { uint32_t index = 0; uint32_t error_code; error_code = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len, SD_BLE_OPT_SET, p_result_code); if (error_code != NRF_SUCCESS) { return error_code; } if (*p_result_code != NRF_SUCCESS) { SER_ASSERT_LENGTH_EQ(index, packet_len); return NRF_SUCCESS; } SER_ASSERT_LENGTH_EQ(index, packet_len); return NRF_SUCCESS; }
uint32_t temp_get_rsp_dec(uint8_t const * const p_buf, uint32_t packet_len, uint32_t * const p_result_code, int32_t * const p_temp) { SER_ASSERT_NOT_NULL(p_buf); SER_ASSERT_NOT_NULL(p_result_code); SER_ASSERT_NOT_NULL(p_temp); uint32_t index = 0; uint32_t err_code = NRF_SUCCESS; err_code = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len, SD_TEMP_GET, p_result_code); SER_ASSERT(err_code == NRF_SUCCESS, err_code); if (*p_result_code != NRF_SUCCESS) { return NRF_SUCCESS; } err_code = uint32_t_dec(p_buf, packet_len, &index, p_temp); SER_ASSERT(err_code == NRF_SUCCESS, err_code); SER_ASSERT_LENGTH_EQ(index, packet_len); return err_code; }
uint32_t ant_channel_id_get_rsp_dec(uint8_t const * const p_buf, uint32_t packet_len, void * const p_device_number, void * const p_device_type, void * const p_transmit_type, uint32_t * const p_result_code) { SER_ASSERT_NOT_NULL(p_buf); SER_ASSERT_NOT_NULL(p_result_code); uint32_t index = 0; uint32_t err_code = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len, SVC_ANT_CHANNEL_ID_GET, p_result_code); SER_ASSERT(err_code == NRF_SUCCESS, err_code); if (*p_result_code != NRF_SUCCESS) { SER_ASSERT_LENGTH_EQ(index, packet_len); return NRF_SUCCESS; } err_code = uint16_t_dec(p_buf, packet_len, &index, p_device_number); SER_ASSERT(err_code == NRF_SUCCESS, err_code); err_code = uint8_t_dec(p_buf, packet_len, &index, p_device_type); SER_ASSERT(err_code == NRF_SUCCESS, err_code); err_code = uint8_t_dec(p_buf, packet_len, &index, p_transmit_type); SER_ASSERT(err_code == NRF_SUCCESS, err_code); SER_ASSERT_LENGTH_EQ(index, packet_len); return NRF_SUCCESS; }
uint32_t ble_gatts_service_add_rsp_dec(uint8_t const * const p_buf, uint32_t packet_len, uint16_t * const p_conn_handle, uint32_t * const p_result_code) { uint32_t index = 0; uint32_t decode_result = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len, SD_BLE_GATTS_SERVICE_ADD, p_result_code); if (decode_result != NRF_SUCCESS) { return decode_result; } if (*p_result_code != NRF_SUCCESS) { SER_ASSERT_LENGTH_EQ(index, packet_len); return NRF_SUCCESS; } SER_ASSERT_NOT_NULL(p_conn_handle); SER_ASSERT_LENGTH_LEQ(index + 2, packet_len); uint16_dec(p_buf, packet_len, &index, p_conn_handle); SER_ASSERT_LENGTH_EQ(index, packet_len); return decode_result; }
uint32_t ble_uuid_decode_rsp_dec(uint8_t const * const p_buf, uint32_t buf_len, ble_uuid_t * * const pp_uuid, uint32_t * const p_result_code) { SER_ASSERT_NOT_NULL(p_buf); SER_ASSERT_NOT_NULL(p_result_code); uint32_t err_code; uint32_t index = 0; uint32_t decode_result = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, buf_len, SD_BLE_UUID_DECODE, p_result_code); if (decode_result != NRF_SUCCESS) { return decode_result; } if (*p_result_code != NRF_SUCCESS) { SER_ASSERT_LENGTH_EQ(index, buf_len); return NRF_SUCCESS; } err_code = cond_field_dec(p_buf, buf_len, &index, (void * *)pp_uuid, ble_uuid_t_dec); SER_ASSERT(err_code == NRF_SUCCESS, err_code); SER_ASSERT_LENGTH_EQ(index, buf_len); return err_code; }
uint32_t ble_gatts_initial_user_handle_get_rsp_dec(uint8_t const * const p_buf, uint32_t packet_len, uint16_t ** pp_handle, uint32_t * const p_result_code) { SER_ASSERT_NOT_NULL(p_buf); SER_ASSERT_NOT_NULL(p_result_code); uint32_t err_code; uint32_t index = 0; uint32_t decode_result = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len, SD_BLE_GATTS_INITIAL_USER_HANDLE_GET, p_result_code); if (decode_result != NRF_SUCCESS) { return decode_result; } if (*p_result_code != NRF_SUCCESS) { SER_ASSERT_LENGTH_EQ(index, packet_len); return NRF_SUCCESS; } err_code = cond_field_dec(p_buf, packet_len, &index, (void * *)pp_handle, uint16_t_dec); SER_ASSERT(err_code == NRF_SUCCESS, err_code); SER_ASSERT_LENGTH_EQ(index, packet_len); return NRF_SUCCESS; }
uint32_t ble_version_get_rsp_dec(uint8_t const * const p_buf, uint32_t packet_len, ble_version_t * p_version, uint32_t * const p_result_code) { uint32_t index = 0; SER_ASSERT_NOT_NULL(p_buf); SER_ASSERT_NOT_NULL(p_result_code); uint32_t status_code = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len, SD_BLE_VERSION_GET, p_result_code); if (status_code != NRF_SUCCESS) { return status_code; } if (*p_result_code != NRF_SUCCESS) { SER_ASSERT_LENGTH_EQ(index, packet_len); return NRF_SUCCESS; } uint8_dec(p_buf, packet_len, &index, &(p_version->version_number)); uint16_dec(p_buf, packet_len, &index, &(p_version->company_id)); uint16_dec(p_buf, packet_len, &index, &p_version->subversion_number); SER_ASSERT_LENGTH_EQ(index, packet_len); return status_code; }
uint32_t ecb_block_encrypt_rsp_dec(uint8_t const * const p_buf, uint32_t packet_len, nrf_ecb_hal_data_t * p_ecb_data, uint32_t * const p_result_code) { SER_ASSERT_NOT_NULL(p_buf); SER_ASSERT_NOT_NULL(p_result_code); uint32_t index = 0; uint32_t decode_result = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len, SD_ECB_BLOCK_ENCRYPT, p_result_code); if (decode_result != NRF_SUCCESS) { return decode_result; } if (*p_result_code != NRF_SUCCESS) { SER_ASSERT_LENGTH_EQ(index, packet_len); return NRF_SUCCESS; } uint32_t err_code = cond_field_dec(p_buf, packet_len, &index, (void **)&p_ecb_data, nrf_ecb_hal_data_t_out_dec); SER_ASSERT(err_code == NRF_SUCCESS, err_code); SER_ASSERT_LENGTH_EQ(index, packet_len); return NRF_SUCCESS; }
uint32_t ble_opt_get_rsp_dec(uint8_t const * const p_buf, uint32_t packet_len, uint32_t * const p_opt_id, ble_opt_t * const p_opt, uint32_t * const p_result_code) { uint32_t index = 0; SER_ASSERT_NOT_NULL(p_buf); SER_ASSERT_NOT_NULL(p_opt_id); SER_ASSERT_NOT_NULL(p_opt); SER_ASSERT_NOT_NULL(p_result_code); uint32_t err_code = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len, SD_BLE_OPT_GET, p_result_code); if (err_code != NRF_SUCCESS) { return err_code; } if (*p_result_code != NRF_SUCCESS) { SER_ASSERT_LENGTH_EQ(index, packet_len); return NRF_SUCCESS; } (void) uint32_t_dec(p_buf, packet_len, &index, p_opt_id); SER_ASSERT(((*p_opt_id == BLE_GAP_OPT_LOCAL_CONN_LATENCY) || (*p_opt_id == BLE_GAP_OPT_PASSKEY) || (*p_opt_id == BLE_GAP_OPT_PRIVACY)), NRF_ERROR_INVALID_PARAM); switch (*p_opt_id) { case BLE_GAP_OPT_LOCAL_CONN_LATENCY: err_code = ble_gap_opt_local_conn_latency_t_dec( p_buf, packet_len, &index, (void *)&(p_opt->gap.local_conn_latency)); break; case BLE_GAP_OPT_PASSKEY: err_code = ble_gap_opt_passkey_t_dec( p_buf, packet_len, &index, (void *)&(p_opt->gap.passkey) ); break; case BLE_GAP_OPT_PRIVACY: err_code = ble_gap_opt_privacy_t_dec( p_buf, packet_len, &index, (void *)&(p_opt->gap.privacy) ); break; } if (err_code != NRF_SUCCESS) { return err_code; } SER_ASSERT_LENGTH_EQ(index, packet_len); return err_code; }
uint32_t ble_uuid_encode_rsp_dec(uint8_t const * const p_buf, uint32_t packet_len, uint8_t * const p_uuid_le_len, uint8_t * const p_uuid_le, uint32_t * const p_result_code) { uint32_t index = 0; uint32_t error_code; error_code = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len, SD_BLE_UUID_ENCODE, p_result_code); if (error_code != NRF_SUCCESS) { return error_code; } if (*p_result_code != NRF_SUCCESS) { SER_ASSERT_LENGTH_EQ(index, packet_len); return NRF_SUCCESS; } SER_ASSERT_LENGTH_LEQ(index + 1, packet_len); uint8_t uuid_le_len = p_buf[index++]; if (p_uuid_le_len != NULL) { if (p_uuid_le != NULL) { SER_ASSERT_LENGTH_LEQ(index + uuid_le_len, packet_len); memcpy(p_uuid_le, &(p_buf[index]), uuid_le_len); index += uuid_le_len; } *p_uuid_le_len = uuid_le_len; } SER_ASSERT_LENGTH_EQ(index, packet_len); return NRF_SUCCESS; }
uint32_t ble_gatts_value_get_rsp_dec(uint8_t const * const p_buf, uint32_t packet_len, uint8_t * * const pp_value, uint16_t * * const pp_value_len, uint32_t * const p_result_code) { SER_ASSERT_NOT_NULL(p_buf); SER_ASSERT_NOT_NULL(p_result_code); SER_ASSERT_NOT_NULL(pp_value); SER_ASSERT_NOT_NULL(pp_value_len); uint32_t err_code; uint32_t index = 0; uint32_t decode_result = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len, SD_BLE_GATTS_VALUE_GET, p_result_code); if (decode_result != NRF_SUCCESS) { return decode_result; } if (*p_result_code != NRF_SUCCESS) { SER_ASSERT_LENGTH_EQ(index, packet_len); return NRF_SUCCESS; } uint16_t value_buffer_size = *(*pp_value_len); err_code = cond_field_dec(p_buf, packet_len, &index, (void * *)pp_value_len, uint16_t_dec); SER_ASSERT(err_code == NRF_SUCCESS, err_code); uint16_t value_len = (*pp_value_len) ? *(*pp_value_len) : 0; err_code = buf_dec(p_buf, packet_len, &index, pp_value, value_buffer_size, value_len); SER_ASSERT(err_code == NRF_SUCCESS, err_code); SER_ASSERT_LENGTH_EQ(index, packet_len); return NRF_SUCCESS; }
uint32_t ser_ble_cmd_rsp_dec(uint8_t const * const p_buf, uint32_t packet_len, uint8_t op_code, uint32_t * const p_result_code) { uint32_t index = 0; uint32_t result_code = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len, op_code, p_result_code); if (result_code != NRF_SUCCESS) { return result_code; } if (index != packet_len) { return NRF_ERROR_DATA_SIZE; } return NRF_SUCCESS; }
uint32_t ble_gatts_include_add_rsp_dec(uint8_t const * const p_buf, uint32_t packet_len, uint16_t * const p_include_handle, uint32_t * const p_result_code) { uint32_t index = 0; uint32_t err_code; err_code = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len, SD_BLE_GATTS_INCLUDE_ADD, p_result_code); SER_ASSERT(err_code == NRF_SUCCESS, err_code); if (*p_result_code != NRF_SUCCESS) { SER_ASSERT_LENGTH_EQ(index, packet_len); return NRF_SUCCESS; } SER_ASSERT_NOT_NULL(p_include_handle); SER_ASSERT_LENGTH_LEQ(index + 2, packet_len); err_code = uint16_t_dec(p_buf, packet_len, &index, p_include_handle); SER_ASSERT_LENGTH_EQ(index, packet_len); return err_code; }
uint32_t ble_opt_get_rsp_dec(uint8_t const * const p_buf, uint32_t packet_len, uint32_t * const p_opt_id, ble_opt_t * const p_opt, uint32_t * const p_result_code) { uint32_t index = 0; SER_ASSERT_NOT_NULL(p_buf); SER_ASSERT_NOT_NULL(p_opt_id); SER_ASSERT_NOT_NULL(p_opt); SER_ASSERT_NOT_NULL(p_result_code); uint32_t err_code = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len, SD_BLE_OPT_GET, p_result_code); if (err_code != NRF_SUCCESS) { return err_code; } if (*p_result_code != NRF_SUCCESS) { SER_ASSERT_LENGTH_EQ(index, packet_len); return NRF_SUCCESS; } (void) uint32_t_dec(p_buf, packet_len, &index, p_opt_id); SER_ASSERT(((*p_opt_id == BLE_COMMON_OPT_RADIO_CPU_MUTEX) || (*p_opt_id == BLE_GAP_OPT_CH_MAP) || (*p_opt_id == BLE_GAP_OPT_LOCAL_CONN_LATENCY) || (*p_opt_id == BLE_GAP_OPT_PASSKEY) || (*p_opt_id == BLE_GAP_OPT_PRIVACY) || (*p_opt_id == BLE_GAP_OPT_SCAN_REQ_REPORT) || (*p_opt_id == BLE_GAP_OPT_COMPAT_MODE)), NRF_ERROR_INVALID_PARAM); switch (*p_opt_id) { case BLE_COMMON_OPT_RADIO_CPU_MUTEX: err_code = ble_common_opt_radio_cpu_mutex_t_dec( p_buf, packet_len, &index, (void *)&(p_opt->common_opt.radio_cpu_mutex)); break; case BLE_GAP_OPT_CH_MAP: err_code = ble_gap_opt_ch_map_t_dec( p_buf, packet_len, &index, (void *)&(p_opt->gap_opt.ch_map)); break; case BLE_GAP_OPT_LOCAL_CONN_LATENCY: err_code = ble_gap_opt_local_conn_latency_t_dec( p_buf, packet_len, &index, (void *)&(p_opt->gap_opt.local_conn_latency)); break; case BLE_GAP_OPT_PASSKEY: err_code = ble_gap_opt_passkey_t_dec( p_buf, packet_len, &index, (void *)&(p_opt->gap_opt.passkey)); break; case BLE_GAP_OPT_PRIVACY: err_code = ble_gap_opt_privacy_t_dec( p_buf, packet_len, &index, (void *)&(p_opt->gap_opt.privacy)); break; case BLE_GAP_OPT_SCAN_REQ_REPORT: err_code = ble_gap_opt_scan_req_report_t_dec( p_buf, packet_len, &index, (void *)&(p_opt->gap_opt.scan_req_report)); break; case BLE_GAP_OPT_COMPAT_MODE: err_code = ble_gap_opt_compat_mode_t_dec( p_buf, packet_len, &index, (void *)&(p_opt->gap_opt.compat_mode)); break; } if (err_code != NRF_SUCCESS) { return err_code; } SER_ASSERT_LENGTH_EQ(index, packet_len); return err_code; }