uint32_t ble_gatts_evt_rw_authorize_request_t_dec(uint8_t const * const p_buf, uint32_t buf_len, uint32_t * const p_index, uint32_t * const p_ext_len, void * const p_void_struct) { SER_STRUCT_DEC_BEGIN(ble_gatts_evt_rw_authorize_request_t); SER_PULL_uint8(&p_struct->type); switch (p_struct->type) { case BLE_GATTS_AUTHORIZE_TYPE_READ: SER_PULL_FIELD(&p_struct->request.read, ble_gatts_evt_read_t_dec); break; case BLE_GATTS_AUTHORIZE_TYPE_WRITE: err_code = ble_gatts_evt_write_t_dec(p_buf, buf_len, p_index, p_ext_len, &p_struct->request.write); SER_ASSERT(err_code == NRF_SUCCESS, err_code); break; default: case BLE_GATTS_AUTHORIZE_TYPE_INVALID: return NRF_ERROR_INVALID_DATA; } SER_STRUCT_ENC_END; }
uint32_t ble_gap_addr_get_rsp_dec(uint8_t const * const p_buf, uint32_t packet_len, ble_gap_addr_t * const p_address, uint32_t * const p_result_code) { SER_RSP_DEC_BEGIN(SD_BLE_GAP_ADDR_GET); SER_PULL_FIELD(p_address, ble_gap_addr_t_dec); SER_RSP_DEC_END; }
uint32_t ble_gatts_attr_md_t_dec(uint8_t const * const p_buf, uint32_t buf_len, uint32_t * const p_index, void * const p_void_struct) { SER_STRUCT_DEC_BEGIN(ble_gatts_attr_md_t); uint8_t ser_data; SER_PULL_FIELD(&p_struct->read_perm, ble_gap_conn_sec_mode_t_dec); SER_PULL_FIELD(&p_struct->write_perm, ble_gap_conn_sec_mode_t_dec); SER_PULL_uint8(&ser_data); p_struct->vlen = ser_data & 0x01; p_struct->vloc = (ser_data >> 1) & 0x03; p_struct->rd_auth = (ser_data >> 3) & 0x01; p_struct->wr_auth = (ser_data >> 4) & 0x01; SER_STRUCT_DEC_END; }
uint32_t ble_evt_data_length_changed_dec(uint8_t const * const p_buf, uint32_t packet_len, ble_evt_t * const p_event, uint32_t * const p_event_len) { SER_EVT_DEC_BEGIN(BLE_EVT_DATA_LENGTH_CHANGED, common, data_length_changed); SER_PULL_uint16(&p_event->evt.common_evt.conn_handle); SER_PULL_FIELD(&p_event->evt.common_evt.params.data_length_changed, ble_evt_data_length_changed_t_dec); SER_EVT_DEC_END; }
uint32_t ble_gap_evt_adv_report_dec(uint8_t const * const p_buf, uint32_t packet_len, ble_evt_t * const p_event, uint32_t * const p_event_len) { SER_EVT_DEC_BEGIN(BLE_GAP_EVT_ADV_REPORT, gap, adv_report); SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); SER_PULL_FIELD(&p_event->evt.gap_evt.params.adv_report, ble_gap_evt_adv_report_t_dec); SER_EVT_DEC_END; }
uint32_t ble_gap_evt_sec_request_dec(uint8_t const * const p_buf, uint32_t packet_len, ble_evt_t * const p_event, uint32_t * const p_event_len) { SER_EVT_DEC_BEGIN(BLE_GAP_EVT_SEC_REQUEST, gap, sec_request); SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); SER_PULL_FIELD(&p_event->evt.gap_evt.params.sec_request, ble_gap_evt_sec_request_t_dec); SER_EVT_DEC_END; }
uint32_t ble_gatts_evt_exchange_mtu_request_dec(uint8_t const * const p_buf, uint32_t packet_len, ble_evt_t * const p_event, uint32_t * const p_event_len) { SER_EVT_DEC_BEGIN(BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST, gatts, exchange_mtu_request); SER_PULL_uint16(&p_event->evt.gatts_evt.conn_handle); SER_PULL_FIELD(&p_event->evt.gatts_evt.params.exchange_mtu_request, ble_gatts_evt_exchange_mtu_request_t_dec); SER_EVT_DEC_END; }
uint32_t ble_gap_evt_conn_sec_update_dec(uint8_t const * const p_buf, uint32_t packet_len, ble_evt_t * const p_event, uint32_t * const p_event_len) { SER_EVT_DEC_BEGIN(BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST, gap, conn_sec_update); SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); SER_PULL_FIELD(&p_event->evt.gap_evt.params.conn_sec_update, ble_gap_evt_conn_sec_update_t_dec); SER_EVT_DEC_END; }
uint32_t ble_gap_evt_disconnected_dec(uint8_t const * const p_buf, uint32_t packet_len, ble_evt_t * const p_event, uint32_t * const p_event_len) { SER_EVT_DEC_BEGIN(BLE_GAP_EVT_DISCONNECTED, gap, disconnected); SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); SER_PULL_FIELD(&p_event->evt.gap_evt.params.disconnected, ble_gap_evt_disconnected_t_dec); SER_EVT_DEC_END; }
uint32_t ble_gap_evt_scan_req_report_dec(uint8_t const * const p_buf, uint32_t packet_len, ble_evt_t * const p_event, uint32_t * const p_event_len) { SER_EVT_DEC_BEGIN(BLE_GAP_EVT_SCAN_REQ_REPORT, gap, scan_req_report); SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); SER_PULL_FIELD(&p_event->evt.gap_evt.params.scan_req_report.peer_addr, ble_gap_addr_t_dec); SER_PULL_int8(&p_event->evt.gap_evt.params.scan_req_report.rssi); SER_EVT_DEC_END; }
uint32_t ble_gatts_evt_read_t_dec(uint8_t const * const p_buf, uint32_t buf_len, uint32_t * const p_index, void * const p_void_struct) { SER_STRUCT_DEC_BEGIN(ble_gatts_evt_read_t); SER_PULL_uint16(&p_struct->handle); SER_PULL_FIELD(&p_struct->uuid, ble_uuid_t_dec); SER_PULL_uint16(&p_struct->offset); SER_STRUCT_DEC_END; }
uint32_t ble_gatts_char_md_t_dec(uint8_t const * const p_buf, uint32_t buf_len, uint32_t * const p_index, void * const p_void_struct) { SER_STRUCT_DEC_BEGIN(ble_gatts_char_md_t); SER_PULL_FIELD(&p_struct->char_props, ble_gatt_char_props_t_dec); SER_PULL_FIELD(&p_struct->char_ext_props, ble_gatt_char_ext_props_t_dec); SER_PULL_uint16(&p_struct->char_user_desc_max_size); #if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 SER_PULL_len16data(&p_struct->p_char_user_desc, &p_struct->char_user_desc_size); #else SER_PULL_len16data((uint8_t * * )&p_struct->p_char_user_desc, &p_struct->char_user_desc_size); #endif SER_PULL_COND(&p_struct->p_char_pf, ble_gatts_char_pf_t_dec); SER_PULL_COND(&p_struct->p_user_desc_md, ble_gatts_attr_md_t_dec); SER_PULL_COND(&p_struct->p_cccd_md, ble_gatts_attr_md_t_dec); SER_PULL_COND(&p_struct->p_sccd_md, ble_gatts_attr_md_t_dec); SER_STRUCT_ENC_END; }
uint32_t ble_gatts_evt_hvc_dec(uint8_t const * const p_buf, uint32_t packet_len, ble_evt_t * const p_event, uint32_t * const p_event_len) { SER_EVT_DEC_BEGIN(BLE_GATTS_EVT_HVC, gatts, hvc); SER_PULL_uint16(&p_event->evt.gatts_evt.conn_handle); SER_PULL_FIELD(&p_event->evt.gatts_evt.params.hvc, ble_gatts_evt_hvc_t_dec); SER_EVT_DEC_END; }
uint32_t ble_gatts_evt_timeout_dec(uint8_t const * const p_buf, uint32_t packet_len, ble_evt_t * const p_event, uint32_t * const p_event_len) { SER_EVT_DEC_BEGIN(BLE_GATTS_EVT_TIMEOUT, gatts, timeout); SER_PULL_uint16(&p_event->evt.gatts_evt.conn_handle); SER_PULL_FIELD(&p_event->evt.gatts_evt.params.timeout, ble_gatts_evt_timeout_t_dec); SER_EVT_DEC_END; }
uint32_t ble_gatts_evt_sys_attr_missing_dec(uint8_t const * const p_buf, uint32_t packet_len, ble_evt_t * const p_event, uint32_t * const p_event_len) { SER_EVT_DEC_BEGIN(BLE_GATTS_EVT_SYS_ATTR_MISSING, gatts, sys_attr_missing); SER_PULL_uint16(&p_event->evt.gatts_evt.conn_handle); SER_PULL_FIELD(&p_event->evt.gatts_evt.params.sys_attr_missing, ble_gatts_evt_sys_attr_missing_t_dec); SER_EVT_DEC_END; }
uint32_t ble_gatts_rw_authorize_reply_params_t_dec(uint8_t const * const p_buf, uint32_t buf_len, uint32_t * const p_index, void * const p_void_struct) { SER_STRUCT_DEC_BEGIN(ble_gatts_rw_authorize_reply_params_t); SER_PULL_uint8(&p_struct->type); if (p_struct->type == BLE_GATTS_AUTHORIZE_TYPE_READ) { SER_PULL_FIELD(&p_struct->params.read, ble_gatts_authorize_params_t_dec); } else if (p_struct->type == BLE_GATTS_AUTHORIZE_TYPE_WRITE) { SER_PULL_FIELD(&p_struct->params.write, ble_gatts_authorize_params_t_dec); } else { return NRF_ERROR_INVALID_PARAM; } SER_STRUCT_DEC_END; }
uint32_t ble_gap_evt_auth_status_dec(uint8_t const * const p_buf, uint32_t packet_len, ble_evt_t * const p_event, uint32_t * const p_event_len) { SER_EVT_DEC_BEGIN(BLE_GAP_EVT_AUTH_STATUS, gap, auth_status); SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); SER_PULL_FIELD(&p_event->evt.gap_evt.params.auth_status, ble_gap_evt_auth_status_t_dec); // keyset is an extension of standard event data - used to synchronize keys at application uint32_t conn_index; err_code = app_ble_gap_sec_context_find(p_event->evt.gap_evt.conn_handle, &conn_index); if (err_code == NRF_SUCCESS) { SER_PULL_FIELD(&(m_app_keys_table[conn_index].keyset), ble_gap_sec_keyset_t_dec); err_code = app_ble_gap_sec_context_destroy(p_event->evt.gap_evt.conn_handle); SER_ASSERT(err_code == NRF_SUCCESS, err_code); } SER_EVT_DEC_END; }
uint32_t ble_gattc_evt_exchange_mtu_rsp_dec(uint8_t const * const p_buf, uint32_t packet_len, ble_evt_t * const p_event, uint32_t * const p_event_len) { SER_EVT_DEC_BEGIN(BLE_GATTC_EVT_EXCHANGE_MTU_RSP, gattc, exchange_mtu_rsp); SER_PULL_uint16(&p_event->evt.gattc_evt.conn_handle); SER_PULL_uint16(&p_event->evt.gattc_evt.gatt_status); SER_PULL_uint16(&p_event->evt.gattc_evt.error_handle); SER_PULL_FIELD(&p_event->evt.gattc_evt.params.exchange_mtu_rsp, ble_gattc_evt_exchange_mtu_rsp_t_dec); SER_EVT_DEC_END; }
uint32_t ble_gatts_evt_write_t_dec(uint8_t const * const p_buf, uint32_t buf_len, uint32_t * const p_index, uint32_t * const p_ext_len, void * const p_void_struct) { SER_STRUCT_DEC_BEGIN(ble_gatts_evt_write_t); SER_PULL_uint16(&p_struct->handle); SER_PULL_FIELD(&p_struct->uuid, ble_uuid_t_dec); SER_PULL_uint8(&p_struct->op); SER_PULL_uint8(&p_struct->auth_required); SER_PULL_uint16(&p_struct->offset); SER_PULL_uint16(&p_struct->len); // Data field is defined as 1-element array, so the first element // is always allocated in the structure. SER_ASSERT_LENGTH_LEQ(p_struct->len, *p_ext_len + 1); SER_PULL_uint8array(p_struct->data, p_struct->len); *p_ext_len = (p_struct->len > 1) ? p_struct->len - 1 : 0; SER_STRUCT_ENC_END; }
uint32_t ble_opt_set_req_dec(uint8_t const * const p_buf, uint16_t packet_len, uint32_t * const p_opt_id, ble_opt_t **const pp_opt ) { SER_REQ_DEC_BEGIN(SD_BLE_OPT_SET); SER_ASSERT_NOT_NULL(p_opt_id); SER_ASSERT_NOT_NULL(pp_opt); SER_ASSERT_NOT_NULL(*pp_opt); SER_PULL_uint32(p_opt_id); SER_ASSERT(((*p_opt_id == BLE_COMMON_OPT_CONN_BW) || (*p_opt_id == BLE_COMMON_OPT_PA_LNA) || (*p_opt_id == BLE_COMMON_OPT_CONN_EVT_EXT) || (*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_SCAN_REQ_REPORT) || (*p_opt_id == BLE_GAP_OPT_COMPAT_MODE) || (*p_opt_id == BLE_GAP_OPT_AUTH_PAYLOAD_TIMEOUT) || (*p_opt_id == BLE_GAP_OPT_EXT_LEN)), NRF_ERROR_INVALID_PARAM); SER_PULL_COND(pp_opt, NULL); if (*pp_opt) { field_decoder_handler_t fp_decoder = NULL; void * p_struct = NULL; switch(*p_opt_id) { case BLE_COMMON_OPT_CONN_BW: fp_decoder = ble_common_opt_conn_bw_t_dec; p_struct = &((*pp_opt)->common_opt.conn_bw); break; case BLE_COMMON_OPT_PA_LNA: fp_decoder = ble_common_opt_pa_lna_t_dec; p_struct = &((*pp_opt)->common_opt.pa_lna); break; case BLE_COMMON_OPT_CONN_EVT_EXT: fp_decoder = ble_common_opt_conn_evt_ext_t_dec; p_struct = &((*pp_opt)->common_opt.conn_evt_ext); break; case BLE_GAP_OPT_CH_MAP: fp_decoder = ble_gap_opt_ch_map_t_dec; p_struct = &((*pp_opt)->gap_opt.ch_map); break; case BLE_GAP_OPT_LOCAL_CONN_LATENCY: fp_decoder = ble_gap_opt_local_conn_latency_t_dec; p_struct = &((*pp_opt)->gap_opt.local_conn_latency); break; case BLE_GAP_OPT_PASSKEY: fp_decoder = ble_gap_opt_passkey_t_dec; p_struct = &((*pp_opt)->gap_opt.passkey); break; case BLE_GAP_OPT_AUTH_PAYLOAD_TIMEOUT: fp_decoder = ble_gap_opt_auth_payload_timeout_t_dec; p_struct = &((*pp_opt)->gap_opt.auth_payload_timeout); break; case BLE_GAP_OPT_EXT_LEN: fp_decoder = ble_gap_opt_ext_len_t_dec; p_struct = &((*pp_opt)->gap_opt.ext_len); break; case BLE_GAP_OPT_SCAN_REQ_REPORT: fp_decoder = ble_gap_opt_scan_req_report_t_dec; p_struct = &((*pp_opt)->gap_opt.scan_req_report); break; case BLE_GAP_OPT_COMPAT_MODE: fp_decoder = ble_gap_opt_compat_mode_t_dec; p_struct = &((*pp_opt)->gap_opt.compat_mode); break; default: SER_ASSERT(NRF_ERROR_INVALID_PARAM,NRF_ERROR_INVALID_PARAM); break; } SER_PULL_FIELD(p_struct, fp_decoder); } SER_REQ_DEC_END; }