uint32_t ble_gatts_evt_write_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_WRITE, gatts, write); SER_PULL_uint16(&p_event->evt.gatts_evt.conn_handle); SER_PULL_FIELD_EXTENDED(&p_event->evt.gatts_evt.params.write, ble_gatts_evt_write_t_dec); if (p_event != NULL) { if (p_event->evt.gatts_evt.params.write.op == BLE_GATTS_OP_EXEC_WRITE_REQ_NOW) { uint32_t conn_index; if (app_ble_user_mem_context_find(p_event->evt.gatts_evt.conn_handle, &conn_index) != NRF_ERROR_NOT_FOUND) { SER_PULL_len16data(&m_app_user_mem_table[conn_index].mem_block.p_mem, &m_app_user_mem_table[conn_index].mem_block.len); SER_ASSERT(err_code == NRF_SUCCESS, err_code); } } } SER_EVT_DEC_END; }
uint32_t ble_evt_user_mem_release_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_USER_MEM_RELEASE, common, user_mem_release); SER_PULL_uint16(&p_event->evt.common_evt.conn_handle); SER_PULL_uint8(&p_event->evt.common_evt.params.user_mem_release.type); SER_PULL_uint16(&p_event->evt.common_evt.params.user_mem_release.mem_block.len); //Set the memory pointer to not-null value. p_event->evt.common_evt.params.user_mem_release.mem_block.p_mem = (uint8_t *)~0; SER_PULL_COND(&p_event->evt.common_evt.params.user_mem_release.mem_block.p_mem, NULL); if (p_event->evt.common_evt.params.user_mem_release.mem_block.p_mem) { // Using connection handle find which mem block to release in Application Processor uint32_t user_mem_table_index; err_code = app_ble_user_mem_context_find(p_event->evt.common_evt.conn_handle, &user_mem_table_index); SER_ASSERT(err_code == NRF_SUCCESS, err_code); p_event->evt.common_evt.params.user_mem_release.mem_block.p_mem = m_app_user_mem_table[user_mem_table_index].mem_block.p_mem; } // Now user memory context can be released err_code = app_ble_user_mem_context_destroy(p_event->evt.common_evt.conn_handle); SER_ASSERT(err_code == NRF_SUCCESS, err_code); SER_EVT_DEC_END; }
uint32_t ble_gatts_evt_rw_authorize_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_HVC, gatts, rw_authorize_request); SER_PULL_uint16(&p_event->evt.gatts_evt.conn_handle); SER_PULL_FIELD_EXTENDED(&p_event->evt.gatts_evt.params.authorize_request, ble_gatts_evt_rw_authorize_request_t_dec); //Correct event length / memory sync. if (p_event->evt.gatts_evt.params.authorize_request.type == BLE_GATTS_AUTHORIZE_TYPE_READ) { evt_struct_len = offsetof(ble_evt_t, evt.gatts_evt.params.authorize_request.request.read) - offsetof(ble_evt_t, evt) + sizeof(ble_gatts_evt_read_t); } else if ((p_event->evt.gatts_evt.params.authorize_request.type == BLE_GATTS_AUTHORIZE_TYPE_WRITE) && ( (p_event->evt.gatts_evt.params.authorize_request.request.write.op == BLE_GATTS_OP_EXEC_WRITE_REQ_NOW) || (p_event->evt.gatts_evt.params.authorize_request.request.write.op == BLE_GATTS_OP_PREP_WRITE_REQ))) { uint32_t conn_index; if (app_ble_user_mem_context_find(p_event->evt.gatts_evt.conn_handle, &conn_index) != NRF_ERROR_NOT_FOUND) { SER_PULL_len16data(&m_app_user_mem_table[conn_index].mem_block.p_mem, &m_app_user_mem_table[conn_index].mem_block.len); } } 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_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_GAP_EVT_TIMEOUT, gap, timeout); SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); SER_PULL_uint8(&p_event->evt.gap_evt.params.timeout.src); 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_gap_evt_rssi_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_GAP_EVT_RSSI_CHANGED, gap, rssi_changed); SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); SER_PULL_int8(&p_event->evt.gap_evt.params.rssi_changed.rssi); SER_EVT_DEC_END; }
uint32_t ble_gap_evt_key_pressed_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_KEY_PRESSED, gap, key_pressed); SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); SER_PULL_uint8(&p_event->evt.gap_evt.params.key_pressed.kp_not); SER_EVT_DEC_END; }
uint32_t ble_gap_evt_auth_key_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_AUTH_KEY_REQUEST, gap, auth_key_request); SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); SER_PULL_uint8(&p_event->evt.gap_evt.params.auth_key_request.key_type); SER_EVT_DEC_END; }
uint32_t ble_evt_tx_complete_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_TX_COMPLETE, common, tx_complete); SER_PULL_uint16(&p_event->evt.common_evt.conn_handle); SER_PULL_uint8(&p_event->evt.common_evt.params.tx_complete.count); SER_EVT_DEC_END; }
uint32_t ble_l2cap_evt_rx_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_L2CAP_EVT_RX, l2cap, rx); SER_PULL_uint16(&p_event->evt.l2cap_evt.conn_handle); SER_PULL_FIELD_EXTENDED(&p_event->evt.l2cap_evt.params.rx, ble_l2cap_evt_rx_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_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_evt_user_mem_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_EVT_USER_MEM_REQUEST, common, user_mem_request); SER_PULL_uint16(&p_event->evt.common_evt.conn_handle); SER_PULL_uint8(&p_event->evt.common_evt.params.user_mem_request.type); SER_EVT_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_gatts_evt_hvn_tx_complete_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_HVN_TX_COMPLETE, gatts, hvn_tx_complete); SER_PULL_uint16(&p_event->evt.gatts_evt.conn_handle); SER_PULL_uint8(&p_event->evt.gatts_evt.params.hvn_tx_complete.count); 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_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_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_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_gattc_evt_write_cmd_tx_complete_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_WRITE_CMD_TX_COMPLETE, gattc, write_cmd_tx_complete); 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_uint8(&p_event->evt.gattc_evt.params.write_cmd_tx_complete.count); SER_EVT_DEC_END; }
uint32_t ble_gattc_evt_char_vals_read_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_CHAR_VALS_READ_RSP, gattc, char_vals_read_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_EXTENDED(&p_event->evt.gattc_evt.params.char_vals_read_rsp, ble_gattc_evt_char_vals_read_rsp_t_dec); SER_EVT_DEC_END; }
uint32_t ble_gattc_evt_attr_info_disc_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_ATTR_INFO_DISC_RSP, gattc, attr_info_disc_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_EXTENDED(&p_event->evt.gattc_evt.params.attr_info_disc_rsp, ble_gattc_evt_attr_info_disc_rsp_t_dec); 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_gattc_evt_write_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_WRITE_RSP, gattc, write_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_EXTENDED(&p_event->evt.gattc_evt.params.write_rsp, ble_gattc_evt_write_rsp_t_dec); SER_EVT_DEC_END; }
uint32_t ble_gattc_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_GATTC_EVT_TIMEOUT, gattc, timeout); 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.timeout, ble_gattc_evt_timeout_t_dec); SER_EVT_DEC_END; }
uint32_t ble_gattc_evt_hvx_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_HVX, gattc, hvx); 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_EXTENDED(&p_event->evt.gattc_evt.params.hvx, ble_gattc_evt_hvx_t_dec); SER_EVT_DEC_END; }
uint32_t ble_gap_evt_passkey_display_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_PASSKEY_DISPLAY, gap, passkey_display); uint8_t ser_data; SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); SER_PULL_uint8array(p_event->evt.gap_evt.params.passkey_display.passkey, BLE_GAP_PASSKEY_LEN); SER_PULL_uint8(&ser_data); p_event->evt.gap_evt.params.passkey_display.match_request = (ser_data & 0x01); SER_EVT_DEC_END; }
uint32_t ble_gap_evt_lesc_dhkey_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_LESC_DHKEY_REQUEST, gap, lesc_dhkey_request); uint8_t ser_data; SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); // 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); SER_ASSERT(err_code == NRF_SUCCESS, err_code); p_event->evt.gap_evt.params.lesc_dhkey_request.p_pk_peer = m_app_keys_table[conn_index].keyset.keys_peer.p_pk; SER_PULL_COND(&p_event->evt.gap_evt.params.lesc_dhkey_request.p_pk_peer, ble_gap_lesc_p256_pk_t_dec); SER_PULL_uint8(&ser_data); p_event->evt.gap_evt.params.lesc_dhkey_request.oobd_req = ser_data & 0x01; SER_EVT_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; }