123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113 |
- /**
- * Copyright (c) 2013 - 2020, Nordic Semiconductor ASA
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form, except as embedded into a Nordic
- * Semiconductor ASA integrated circuit in a product or a software update for
- * such product, must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *
- * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * 4. This software, with or without modification, must only be used with a
- * Nordic Semiconductor ASA integrated circuit.
- *
- * 5. Any software provided in binary form under this license must not be reverse
- * engineered, decompiled, modified and/or disassembled.
- *
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
- #include "ble_gap_conn.h"
- #include <string.h>
- #include "ble_serialization.h"
- #include "cond_field_serialization.h"
- #include "ble_gap_struct_serialization.h"
- #include "ble_struct_serialization.h"
- #include "app_util.h"
- #if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 6
- uint32_t ble_gap_adv_data_set_req_dec(uint8_t const * const p_buf,
- uint32_t packet_len,
- uint8_t * * const pp_data,
- uint8_t * p_dlen,
- uint8_t * * const pp_sr_data,
- uint8_t * p_srdlen)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_ADV_DATA_SET);
- SER_ASSERT_NOT_NULL(p_dlen);
- SER_ASSERT_NOT_NULL(p_srdlen);
- SER_PULL_len8data(pp_data, p_dlen);
- SER_PULL_len8data(pp_sr_data, p_srdlen);
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_adv_data_set_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len)
- {
- SER_RSP_ENC_RESULT_ONLY(SD_BLE_GAP_ADV_DATA_SET);
- }
- #endif
- uint32_t ble_gap_adv_start_req_dec(uint8_t const * const p_buf,
- uint32_t packet_len,
- #if NRF_SD_BLE_API_VERSION > 5
- uint8_t * p_adv_handle
- #else
- ble_gap_adv_params_t * * const pp_adv_params
- #endif
- #if NRF_SD_BLE_API_VERSION >= 4
- ,uint8_t * p_conn_cfg_tag
- #endif
- )
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_ADV_START);
- #if NRF_SD_BLE_API_VERSION > 5
- SER_PULL_uint8(p_adv_handle);
- #else
- SER_ASSERT_NOT_NULL(pp_adv_params);
- SER_ASSERT_NOT_NULL(*pp_adv_params);
- SER_ASSERT_NOT_NULL((*pp_adv_params)->p_peer_addr);
- SER_PULL_COND(pp_adv_params, ble_gap_adv_params_t_dec);
- #endif
- #if NRF_SD_BLE_API_VERSION >= 4
- SER_PULL_uint8(p_conn_cfg_tag);
- #endif
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_adv_start_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len
- )
- {
- SER_RSP_ENC_RESULT_ONLY(SD_BLE_GAP_ADV_START);
- }
- #if NRF_SD_BLE_API_VERSION > 5
- uint32_t ble_gap_adv_stop_req_dec(uint8_t const * const p_buf,
- uint16_t packet_len,
- uint8_t * p_adv_handle)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_ADV_STOP);
- SER_PULL_uint8(p_adv_handle);
- SER_REQ_DEC_END;
- }
- #endif
- uint32_t ble_gap_adv_stop_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len)
- {
- SER_RSP_ENC_RESULT_ONLY(SD_BLE_GAP_ADV_STOP);
- }
- uint32_t ble_gap_appearance_get_req_dec(uint8_t const * const p_buf,
- uint16_t packet_len,
- uint16_t * * const pp_appearance)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_APPEARANCE_GET);
- SER_ASSERT_NOT_NULL(pp_appearance);
- SER_ASSERT_NOT_NULL(*pp_appearance);
- SER_PULL_COND(pp_appearance, NULL);
- SER_REQ_DEC_END;
- }
- 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_RSP_ENC_BEGIN(SD_BLE_GAP_APPEARANCE_GET);
- SER_PUSH_COND(p_appearance, uint16_t_enc);
- SER_RSP_ENC_END;
- }
- uint32_t ble_gap_appearance_set_req_dec(uint8_t const * const p_buf,
- uint32_t packet_len,
- uint16_t * const p_appearance)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_APPEARANCE_SET);
- SER_ASSERT_NOT_NULL(p_appearance);
- SER_PULL_uint16(p_appearance);
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_appearance_set_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len)
- {
- SER_RSP_ENC_RESULT_ONLY(SD_BLE_GAP_APPEARANCE_SET);
- }
- uint32_t ble_gap_auth_key_reply_req_dec(uint8_t const * const p_buf,
- uint16_t packet_len,
- uint16_t * p_conn_handle,
- uint8_t * p_key_type,
- uint8_t * * const pp_key)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_AUTH_KEY_REPLY);
- SER_ASSERT_NOT_NULL(p_conn_handle);
- SER_ASSERT_NOT_NULL(p_key_type);
- SER_PULL_uint16(p_conn_handle);
- SER_PULL_uint8(p_key_type);
- uint8_t key_len;
- switch (*p_key_type)
- {
- case BLE_GAP_AUTH_KEY_TYPE_NONE:
- key_len = 0;
- break;
- case BLE_GAP_AUTH_KEY_TYPE_PASSKEY:
- key_len = 6;
- break;
- case BLE_GAP_AUTH_KEY_TYPE_OOB:
- key_len = 16;
- break;
- default:
- return NRF_ERROR_INVALID_PARAM;
- }
- SER_PULL_buf(pp_key, key_len, key_len);
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_auth_key_reply_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len)
- {
- SER_RSP_ENC_RESULT_ONLY(SD_BLE_GAP_AUTH_KEY_REPLY);
- }
- uint32_t ble_gap_authenticate_req_dec(uint8_t const * const p_buf,
- uint32_t packet_len,
- uint16_t * const p_conn_handle,
- ble_gap_sec_params_t * * const pp_sec_params)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_AUTHENTICATE);
- SER_ASSERT_NOT_NULL(p_conn_handle);
- SER_ASSERT_NOT_NULL(pp_sec_params);
- SER_ASSERT_NOT_NULL(*pp_sec_params);
- SER_PULL_uint16(p_conn_handle);
- SER_PULL_COND(pp_sec_params, ble_gap_sec_params_t_dec);
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_authenticate_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len)
- {
- SER_RSP_ENC_RESULT_ONLY(SD_BLE_GAP_AUTHENTICATE);
- }
- uint32_t ble_gap_conn_param_update_req_dec(uint8_t const * const p_buf,
- uint32_t packet_len,
- uint16_t * p_conn_handle,
- ble_gap_conn_params_t * * const pp_conn_params)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_CONN_PARAM_UPDATE);
- SER_ASSERT_NOT_NULL(p_conn_handle);
- SER_ASSERT_NOT_NULL(pp_conn_params);
- SER_ASSERT_NOT_NULL(*pp_conn_params);
- SER_PULL_uint16(p_conn_handle);
- SER_PULL_COND(pp_conn_params, ble_gap_conn_params_t_dec);
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_conn_param_update_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len)
- {
- SER_RSP_ENC_RESULT_ONLY(SD_BLE_GAP_CONN_PARAM_UPDATE);
- }
- uint32_t ble_gap_conn_sec_get_req_dec(uint8_t const * const p_buf,
- uint32_t packet_len,
- uint16_t * p_conn_handle,
- ble_gap_conn_sec_t * * const pp_conn_sec)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_CONN_SEC_GET);
- SER_ASSERT_NOT_NULL(p_conn_handle);
- SER_PULL_uint16(p_conn_handle);
- SER_PULL_COND(pp_conn_sec, NULL);
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_conn_sec_get_rsp_enc(uint32_t return_code,
- ble_gap_conn_sec_t * const p_conn_sec,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len)
- {
- SER_RSP_ENC_BEGIN(SD_BLE_GAP_CONN_SEC_GET);
- SER_PUSH_COND(p_conn_sec, ble_gap_conn_sec_t_enc);
- SER_RSP_ENC_END;
- }
- uint32_t ble_gap_device_name_get_req_dec(uint8_t const * const p_buf,
- uint32_t packet_len,
- uint8_t * * pp_name,
- uint16_t * * pp_name_len)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_DEVICE_NAME_GET);
- SER_ASSERT_NOT_NULL(pp_name_len);
- SER_PULL_COND(pp_name_len, uint16_t_dec);
- SER_PULL_COND(pp_name, NULL);
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_device_name_get_rsp_enc(uint32_t return_code,
- uint8_t const * const p_dev_name,
- uint16_t * p_dev_name_len,
- uint16_t cpy_len,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len)
- {
- SER_RSP_ENC_BEGIN(SD_BLE_GAP_DEVICE_NAME_GET);
- SER_PUSH_COND(p_dev_name_len, uint16_t_enc);
- SER_PUSH_len16data(p_dev_name, cpy_len);
- SER_RSP_ENC_END;
- }
- uint32_t ble_gap_device_name_set_req_dec(uint8_t const * const p_buf,
- uint32_t packet_len,
- ble_gap_conn_sec_mode_t * * const pp_write_perm,
- uint8_t * * const pp_dev_name,
- uint16_t * const p_dev_name_len)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_DEVICE_NAME_SET);
- SER_ASSERT_NOT_NULL(pp_write_perm);
- SER_ASSERT_NOT_NULL(pp_dev_name);
- SER_ASSERT_NOT_NULL(p_dev_name_len);
- SER_PULL_COND(pp_write_perm, ble_gap_conn_sec_mode_t_dec);
- SER_PULL_len16data(pp_dev_name, p_dev_name_len);
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_device_name_set_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len)
- {
- SER_RSP_ENC_RESULT_ONLY(SD_BLE_GAP_DEVICE_NAME_SET);
- }
- uint32_t ble_gap_disconnect_req_dec(uint8_t const * const p_buf,
- uint32_t packet_len,
- uint16_t * const p_conn_handle,
- uint8_t * const p_hci_status)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_DISCONNECT);
- SER_ASSERT_NOT_NULL(p_conn_handle);
- SER_ASSERT_NOT_NULL(p_hci_status);
- SER_PULL_uint16(p_conn_handle);
- SER_PULL_uint8(p_hci_status);
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_disconnect_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len)
- {
- SER_RSP_ENC_RESULT_ONLY(SD_BLE_GAP_DISCONNECT);
- }
- #ifndef S112
- uint32_t ble_gap_encrypt_req_dec(uint8_t const * const p_buf,
- uint16_t packet_len,
- uint16_t * const p_conn_handle,
- ble_gap_master_id_t ** const pp_master_id,
- ble_gap_enc_info_t ** const pp_enc_info)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_ENCRYPT);
- SER_ASSERT_NOT_NULL(p_conn_handle);
- SER_ASSERT_NOT_NULL(pp_enc_info);
- SER_ASSERT_NOT_NULL(pp_master_id);
- SER_ASSERT_NOT_NULL(*pp_enc_info);
- SER_ASSERT_NOT_NULL(*pp_master_id);
- SER_PULL_uint16(p_conn_handle);
- SER_PULL_COND(pp_master_id, ble_gap_master_id_t_dec);
- SER_PULL_COND(pp_enc_info, ble_gap_enc_info_t_dec);
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_encrypt_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len)
- {
- SER_RSP_ENC_RESULT_ONLY(SD_BLE_GAP_ENCRYPT);
- }
- #endif
- uint32_t ble_gap_keypress_notify_req_dec(uint8_t const * const p_buf,
- uint32_t packet_len,
- uint16_t * p_conn_handle,
- uint8_t * p_kp_not)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_KEYPRESS_NOTIFY);
- SER_ASSERT_NOT_NULL(p_conn_handle);
- SER_ASSERT_NOT_NULL(p_kp_not);
- SER_PULL_uint16(p_conn_handle);
- SER_PULL_uint8(p_kp_not);
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_keypress_notify_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len)
- {
- SER_RSP_ENC_RESULT_ONLY(SD_BLE_GAP_KEYPRESS_NOTIFY);
- }
- uint32_t ble_gap_lesc_dhkey_reply_req_dec(uint8_t const * const p_buf,
- uint32_t packet_len,
- uint16_t * p_conn_handle,
- ble_gap_lesc_dhkey_t * * pp_dhkey)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_LESC_DHKEY_REPLY);
- SER_ASSERT_NOT_NULL(p_conn_handle);
- SER_ASSERT_NOT_NULL(pp_dhkey);
- SER_PULL_uint16(p_conn_handle);
- SER_PULL_COND(pp_dhkey, ble_gap_lesc_dhkey_t_dec);
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_lesc_dhkey_reply_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len)
- {
- SER_RSP_ENC_RESULT_ONLY(SD_BLE_GAP_LESC_DHKEY_REPLY);
- }
- uint32_t ble_gap_lesc_oob_data_get_req_dec(uint8_t const * const p_buf,
- uint32_t packet_len,
- uint16_t * p_conn_handle,
- ble_gap_lesc_p256_pk_t * * pp_pk_own,
- ble_gap_lesc_oob_data_t * * pp_oobd_own)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_LESC_OOB_DATA_GET);
- SER_ASSERT_NOT_NULL(p_conn_handle);
- SER_ASSERT_NOT_NULL(pp_oobd_own);
- SER_ASSERT_NOT_NULL(pp_pk_own);
- SER_PULL_uint16(p_conn_handle);
- SER_PULL_COND(pp_pk_own, ble_gap_lesc_p256_pk_t_dec);
- SER_PULL_COND(pp_oobd_own, NULL);
- SER_REQ_DEC_END;
- }
- 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_RSP_ENC_BEGIN(SD_BLE_GAP_LESC_OOB_DATA_GET);
- SER_PUSH_COND(p_oobd_own, ble_gap_lesc_oob_data_t_enc);
- SER_RSP_ENC_END;
- }
- uint32_t ble_gap_lesc_oob_data_set_req_dec(uint8_t const * const p_buf,
- uint32_t packet_len,
- uint16_t * p_conn_handle,
- ble_gap_lesc_oob_data_t * * pp_oobd_own,
- ble_gap_lesc_oob_data_t * * pp_oobd_peer)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_LESC_OOB_DATA_SET);
- SER_ASSERT_NOT_NULL(p_conn_handle);
- SER_ASSERT_NOT_NULL(pp_oobd_own);
- SER_ASSERT_NOT_NULL(pp_oobd_peer);
- SER_PULL_uint16(p_conn_handle);
- SER_PULL_COND(pp_oobd_own, ble_gap_lesc_oob_data_t_dec);
- SER_PULL_COND(pp_oobd_peer, ble_gap_lesc_oob_data_t_dec);
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_lesc_oob_data_set_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len)
- {
- SER_RSP_ENC_RESULT_ONLY(SD_BLE_GAP_LESC_OOB_DATA_SET);
- }
- uint32_t ble_gap_ppcp_get_req_dec(uint8_t const * const p_buf,
- uint16_t packet_len,
- ble_gap_conn_params_t * * const pp_conn_params)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_PPCP_GET);
- SER_ASSERT_NOT_NULL(pp_conn_params);
- SER_ASSERT_NOT_NULL(*pp_conn_params);
- SER_ASSERT_LENGTH_LEQ(2, packet_len);
- SER_PULL_COND(pp_conn_params, NULL);
- SER_REQ_DEC_END;
- }
- 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_RSP_ENC_BEGIN(SD_BLE_GAP_PPCP_GET);
- SER_PUSH_COND(p_conn_params, ble_gap_conn_params_t_enc);
- SER_RSP_ENC_END;
- }
- uint32_t ble_gap_ppcp_set_req_dec(uint8_t const * const p_buf,
- uint32_t packet_len,
- ble_gap_conn_params_t * * const pp_conn_params)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_PPCP_SET);
- SER_ASSERT_NOT_NULL(pp_conn_params);
- SER_PULL_COND(pp_conn_params, ble_gap_conn_params_t_dec);
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_ppcp_set_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len)
- {
- SER_RSP_ENC_RESULT_ONLY(SD_BLE_GAP_PPCP_SET);
- }
- uint32_t ble_gap_rssi_get_req_dec(uint8_t const * const p_buf,
- uint16_t packet_len,
- uint16_t * p_conn_handle,
- int8_t * * const pp_rssi
- #if NRF_SD_BLE_API_VERSION > 5
- ,uint8_t * * const pp_ch_index
- #endif
- )
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_RSSI_GET);
- SER_ASSERT_NOT_NULL(p_conn_handle);
- SER_ASSERT_NOT_NULL(pp_rssi);
- SER_ASSERT_NOT_NULL(*pp_rssi);
- SER_PULL_uint16(p_conn_handle);
- SER_PULL_COND(pp_rssi, NULL);
- #if NRF_SD_BLE_API_VERSION > 5
- SER_ASSERT_NOT_NULL(pp_ch_index);
- SER_ASSERT_NOT_NULL(*pp_ch_index);
- SER_PULL_COND(pp_ch_index, NULL);
- #endif
- SER_REQ_DEC_END;
- }
- 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 * p_rssi
- #if NRF_SD_BLE_API_VERSION > 5
- ,uint8_t * p_ch_index
- #endif
- )
- {
- SER_RSP_ENC_BEGIN(SD_BLE_GAP_RSSI_GET);
- SER_PUSH_COND(p_rssi, uint8_t_enc);
- #if NRF_SD_BLE_API_VERSION > 5
- SER_PUSH_COND(p_ch_index, uint8_t_enc);
- #endif
- SER_RSP_ENC_END;
- }
- uint32_t ble_gap_rssi_start_req_dec(uint8_t const * const p_buf,
- uint32_t packet_len,
- uint16_t * p_conn_handle,
- uint8_t * p_threshold_dbm,
- uint8_t * p_skip_count)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_RSSI_START);
- SER_ASSERT_NOT_NULL(p_conn_handle);
- SER_ASSERT_NOT_NULL(p_threshold_dbm);
- SER_ASSERT_NOT_NULL(p_skip_count);
- SER_PULL_uint16(p_conn_handle);
- SER_PULL_uint8(p_threshold_dbm);
- SER_PULL_uint8(p_skip_count);
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_rssi_start_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len)
- {
- SER_RSP_ENC_RESULT_ONLY(SD_BLE_GAP_RSSI_START);
- }
- uint32_t ble_gap_rssi_stop_req_dec(uint8_t const * const p_buf,
- uint32_t packet_len,
- uint16_t * p_conn_handle)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_RSSI_STOP);
- SER_ASSERT_NOT_NULL(p_conn_handle);
- SER_PULL_uint16(p_conn_handle);
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_rssi_stop_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len)
- {
- SER_RSP_ENC_RESULT_ONLY(SD_BLE_GAP_RSSI_STOP);
- }
- #ifndef S112
- uint32_t ble_gap_scan_start_req_dec(uint8_t const * const p_buf,
- uint32_t packet_len,
- ble_gap_scan_params_t * * const pp_scan_params
- #if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION > 5
- ,ble_data_t * * const pp_adv_report_buffer
- #endif
- )
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_SCAN_START);
- SER_ASSERT_NOT_NULL(pp_scan_params);
- SER_ASSERT_NOT_NULL(*pp_scan_params);
- SER_PULL_COND(pp_scan_params, ble_gap_scan_params_t_dec);
- #if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION > 5
- SER_PULL_COND(pp_adv_report_buffer, ble_data_t_dec);
- #endif
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_scan_start_rsp_enc(uint32_t return_code,
- #if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION > 5
- ble_data_t *p_ble_data,
- #endif
- uint8_t * const p_buf,
- uint32_t * const p_buf_len)
- {
- SER_RSP_ENC_RESULT_ONLY(SD_BLE_GAP_SCAN_START);
- }
- uint32_t ble_gap_scan_stop_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len)
- {
- SER_RSP_ENC_RESULT_ONLY(SD_BLE_GAP_SCAN_STOP);
- }
- uint32_t ble_gap_connect_req_dec(uint8_t const * const p_buf,
- uint32_t packet_len,
- ble_gap_addr_t * * const pp_addr,
- ble_gap_scan_params_t * * const pp_scan_params,
- ble_gap_conn_params_t * * const pp_conn_params
- #if NRF_SD_BLE_API_VERSION >= 4
- ,uint8_t * p_conn_cfg_tag
- #endif
- )
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_CONNECT);
- SER_ASSERT_NOT_NULL(pp_addr);
- SER_ASSERT_NOT_NULL(*pp_addr);
- SER_ASSERT_NOT_NULL(pp_scan_params);
- SER_ASSERT_NOT_NULL(*pp_scan_params);
- SER_ASSERT_NOT_NULL(pp_conn_params);
- SER_ASSERT_NOT_NULL(*pp_conn_params);
- SER_PULL_COND(pp_addr, ble_gap_addr_t_dec);
- SER_PULL_COND(pp_scan_params, ble_gap_scan_params_t_dec);
- SER_PULL_COND(pp_conn_params, ble_gap_conn_params_t_dec);
- #if NRF_SD_BLE_API_VERSION >= 4
- SER_PULL_uint8(p_conn_cfg_tag);
- #endif
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_connect_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len)
- {
- SER_RSP_ENC_RESULT_ONLY(SD_BLE_GAP_CONNECT);
- }
- uint32_t ble_gap_connect_cancel_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len)
- {
- SER_RSP_ENC_RESULT_ONLY(SD_BLE_GAP_CONNECT_CANCEL);
- }
- #endif //S112
- uint32_t ble_gap_sec_info_reply_req_dec(uint8_t const * const p_buf,
- uint16_t packet_len,
- uint16_t * p_conn_handle,
- ble_gap_enc_info_t * * const pp_enc_info,
- ble_gap_irk_t * * const pp_id_info,
- ble_gap_sign_info_t * * const pp_sign_info)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_SEC_INFO_REPLY);
- SER_ASSERT_NOT_NULL(p_conn_handle);
- SER_ASSERT_NOT_NULL(pp_enc_info);
- SER_ASSERT_NOT_NULL(pp_id_info);
- SER_ASSERT_NOT_NULL(pp_sign_info);
- SER_ASSERT_NOT_NULL(*pp_enc_info);
- SER_ASSERT_NOT_NULL(*pp_id_info);
- SER_ASSERT_NOT_NULL(*pp_sign_info);
- SER_PULL_uint16(p_conn_handle);
- SER_PULL_COND(pp_enc_info, ble_gap_enc_info_t_dec);
- SER_PULL_COND(pp_id_info, ble_gap_irk_t_dec);
- SER_PULL_COND(pp_sign_info, ble_gap_sign_info_t_dec);
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_sec_info_reply_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len)
- {
- SER_RSP_ENC_RESULT_ONLY(SD_BLE_GAP_SEC_INFO_REPLY);
- }
- uint32_t ble_gap_sec_params_reply_req_dec(uint8_t const * const p_buf,
- uint32_t packet_len,
- uint16_t * p_conn_handle,
- uint8_t * p_sec_status,
- ble_gap_sec_params_t * * const pp_sec_params,
- ble_gap_sec_keyset_t * * const pp_sec_keyset)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_SEC_PARAMS_REPLY);
- SER_ASSERT_NOT_NULL(p_conn_handle);
- SER_ASSERT_NOT_NULL(p_sec_status);
- SER_ASSERT_NOT_NULL(pp_sec_params);
- SER_ASSERT_NOT_NULL(*pp_sec_params);
- SER_ASSERT_NOT_NULL(pp_sec_keyset);
- SER_ASSERT_NOT_NULL(*pp_sec_keyset);
- SER_PULL_uint16(p_conn_handle);
- SER_PULL_uint8(p_sec_status);
- SER_PULL_COND(pp_sec_params, ble_gap_sec_params_t_dec);
- SER_PULL_COND(pp_sec_keyset, ble_gap_sec_keyset_t_dec);
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_sec_params_reply_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len,
- ble_gap_sec_keyset_t * const p_sec_keyset)
- {
- SER_RSP_ENC_BEGIN(SD_BLE_GAP_SEC_PARAMS_REPLY);
- SER_PUSH_COND(p_sec_keyset, ble_gap_sec_keyset_t_enc);
- SER_RSP_ENC_END;
- }
- uint32_t ble_gap_tx_power_set_req_dec(uint8_t const * const p_buf,
- uint32_t packet_len,
- #if NRF_SD_BLE_API_VERSION > 5
- uint8_t * p_role, uint16_t * p_handle,
- #endif
- int8_t * p_tx_power)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_TX_POWER_SET);
- SER_ASSERT_NOT_NULL(p_tx_power);
- #if NRF_SD_BLE_API_VERSION > 5
- SER_PULL_uint8(p_role);
- SER_PULL_uint16(p_handle);
- #endif
- SER_PULL_int8(p_tx_power);
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_tx_power_set_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len)
- {
- SER_RSP_ENC_RESULT_ONLY(SD_BLE_GAP_TX_POWER_SET);
- }
- uint32_t ble_gap_addr_get_req_dec(uint8_t const * const p_buf,
- uint16_t packet_len,
- ble_gap_addr_t * * const pp_address)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_ADDR_GET);
- SER_PULL_COND(pp_address, NULL);
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_addr_get_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len,
- ble_gap_addr_t const * const p_address)
- {
- SER_RSP_ENC_BEGIN(SD_BLE_GAP_ADDR_GET);
- SER_PUSH_FIELD(p_address, ble_gap_addr_t_enc);
- SER_RSP_ENC_END;
- }
- uint32_t ble_gap_addr_set_req_dec(uint8_t const * const p_buf,
- uint32_t packet_len,
- ble_gap_addr_t * * const pp_addr)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_ADDR_SET);
- SER_PULL_COND(pp_addr, ble_gap_addr_t_dec);
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_addr_set_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len)
- {
- SER_RSP_ENC_RESULT_ONLY(SD_BLE_GAP_ADDR_SET);
- }
- uint32_t ble_gap_privacy_set_req_dec(uint8_t const * const p_buf,
- uint32_t packet_len,
- ble_gap_privacy_params_t * * const pp_privacy_params)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_PRIVACY_SET);
- SER_PULL_COND(pp_privacy_params, ble_gap_privacy_params_t_dec);
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_privacy_set_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len)
- {
- SER_RSP_ENC_RESULT_ONLY(SD_BLE_GAP_PRIVACY_SET);
- }
- uint32_t ble_gap_privacy_get_req_dec(uint8_t const * const p_buf,
- uint16_t packet_len,
- ble_gap_privacy_params_t * * const pp_privacy_params)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_PRIVACY_GET);
- SER_PULL_COND(pp_privacy_params, ble_gap_privacy_params_t_dec);
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_privacy_get_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len,
- ble_gap_privacy_params_t const * const p_privacy_params)
- {
- SER_RSP_ENC_BEGIN(SD_BLE_GAP_PRIVACY_GET);
- SER_PUSH_COND(p_privacy_params, ble_gap_privacy_params_t_enc);
- SER_RSP_ENC_END;
- }
- uint32_t ble_gap_whitelist_set_req_dec(uint8_t const * const p_buf,
- uint32_t packet_len,
- ble_gap_addr_t * * * const ppp_wl_addrs,
- uint8_t * const p_len)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_WHITELIST_SET);
- SER_ASSERT_NOT_NULL(ppp_wl_addrs);
- SER_ASSERT_NOT_NULL(*ppp_wl_addrs);
- SER_ASSERT_NOT_NULL(**ppp_wl_addrs);
- uint8_t presence;
- SER_PULL_uint8(p_len);
- SER_PULL_uint8(&presence);
- if (presence == SER_FIELD_PRESENT)
- {
- ble_gap_addr_t * * const pp_wl_addrs = *ppp_wl_addrs;
- for (uint32_t i = 0; i < *p_len; ++i)
- {
- SER_PULL_COND(&(pp_wl_addrs[i]), ble_gap_addr_t_dec);
- }
- }
- else
- {
- *ppp_wl_addrs = NULL;
- }
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_whitelist_set_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len)
- {
- SER_RSP_ENC_RESULT_ONLY(SD_BLE_GAP_WHITELIST_SET);
- }
- uint32_t ble_gap_device_identities_set_req_dec(uint8_t const * const p_buf,
- uint32_t packet_len,
- ble_gap_id_key_t * * * const ppp_id_keys,
- ble_gap_irk_t * * * const ppp_local_irks,
- uint8_t * const p_len)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_DEVICE_IDENTITIES_SET);
- SER_ASSERT_NOT_NULL(ppp_id_keys);
- SER_ASSERT_NOT_NULL(*ppp_id_keys);
- SER_ASSERT_NOT_NULL(**ppp_id_keys);
- SER_ASSERT_NOT_NULL(ppp_local_irks);
- SER_ASSERT_NOT_NULL(*ppp_local_irks);
- SER_ASSERT_NOT_NULL(**ppp_local_irks);
- uint8_t presence;
- SER_PULL_uint8(p_len);
- SER_PULL_uint8(&presence);
- if (presence == SER_FIELD_PRESENT)
- {
- ble_gap_id_key_t * * const pp_id_keys = *ppp_id_keys;
- for (uint32_t i = 0; i < *p_len; ++i)
- {
- SER_PULL_COND(&(pp_id_keys[i]), ble_gap_id_key_t_dec);
- }
- }
- else
- {
- *ppp_id_keys = NULL;
- }
- SER_PULL_uint8(&presence);
- if (presence == SER_FIELD_PRESENT)
- {
- ble_gap_irk_t * * const pp_local_irks = *ppp_local_irks;
- for (uint32_t i = 0; i < *p_len; ++i)
- {
- SER_PULL_COND(&(pp_local_irks[i]), ble_gap_irk_t_dec);
- }
- }
- else
- {
- *ppp_local_irks = NULL;
- }
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_device_identities_set_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len)
- {
- SER_RSP_ENC_RESULT_ONLY(SD_BLE_GAP_DEVICE_IDENTITIES_SET);
- }
- #if NRF_SD_BLE_API_VERSION >= 4 && !defined(S112)
- uint32_t ble_gap_data_length_update_req_dec(uint8_t const * const p_buf,
- uint16_t packet_len,
- uint16_t * p_conn_handle,
- ble_gap_data_length_params_t * * const pp_dl_params,
- ble_gap_data_length_limitation_t * * const pp_dl_limitation)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_DATA_LENGTH_UPDATE);
- SER_PULL_uint16(p_conn_handle);
- SER_PULL_COND(pp_dl_params, ble_gap_data_length_params_t_dec);
- SER_PULL_COND(pp_dl_limitation, NULL);
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_data_length_update_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len,
- ble_gap_data_length_limitation_t const * const p_dl_limitation)
- {
- SER_RSP_ENC_BEGIN(SD_BLE_GAP_DATA_LENGTH_UPDATE);
- SER_PUSH_COND(p_dl_limitation, ble_gap_data_length_limitation_t_enc);
- SER_RSP_ENC_END;
- }
- #endif //NRF_SD_BLE_API_VERSION >= 4 && !defined(S112)
- #if NRF_SD_BLE_API_VERSION >= 5
- uint32_t ble_gap_phy_update_req_dec(uint8_t const * const p_buf,
- uint32_t packet_len,
- uint16_t * const p_conn_handle,
- ble_gap_phys_t * * const pp_gap_phys)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_PHY_UPDATE);
- SER_ASSERT_NOT_NULL(p_conn_handle);
- SER_ASSERT_NOT_NULL(pp_gap_phys);
- SER_ASSERT_NOT_NULL(*pp_gap_phys);
- SER_PULL_uint16(p_conn_handle);
- SER_PULL_COND(pp_gap_phys, ble_gap_phys_t_dec);
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_phy_update_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len)
- {
- SER_RSP_ENC_RESULT_ONLY(SD_BLE_GAP_PHY_UPDATE);
- }
- #endif //RF_SD_BLE_API_VERSION >= 5
- #if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION > 5
- uint32_t ble_gap_adv_set_configure_req_dec(uint8_t const * const p_buf,
- uint16_t packet_len,
- uint8_t * * const pp_adv_handle,
- ble_gap_adv_data_t **const pp_adv_data,
- ble_gap_adv_params_t **const pp_adv_params)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_ADV_SET_CONFIGURE);
- SER_ASSERT_NOT_NULL(pp_adv_handle);
- SER_ASSERT_NOT_NULL(*pp_adv_handle);
- SER_ASSERT_NOT_NULL(pp_adv_data);
- SER_ASSERT_NOT_NULL(*pp_adv_data);
- SER_ASSERT_NOT_NULL(pp_adv_params);
- SER_ASSERT_NOT_NULL(*pp_adv_params);
- SER_PULL_COND(pp_adv_handle, uint8_t_dec);
- SER_PULL_COND(pp_adv_data, ble_gap_adv_data_t_dec);
- SER_PULL_COND(pp_adv_params, ble_gap_adv_params_t_dec);
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_adv_set_configure_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len,
- ble_gap_adv_data_t * p_ble_adv_data,
- uint8_t const * const p_adv_handle)
- {
- SER_RSP_ENC_BEGIN(SD_BLE_GAP_ADV_SET_CONFIGURE);
- SER_PUSH_COND(p_adv_handle, uint8_t_enc);
- SER_RSP_ENC_END;
- }
- #ifndef S112
- uint32_t ble_gap_qos_channel_survey_start_req_dec(uint8_t const * const p_buf,
- uint32_t packet_len,
- uint32_t * const p_interval_us)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_QOS_CHANNEL_SURVEY_START);
- SER_ASSERT_NOT_NULL(p_interval_us);
- SER_PULL_uint32(p_interval_us);
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_qos_channel_survey_start_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len)
- {
- SER_RSP_ENC_RESULT_ONLY(SD_BLE_GAP_QOS_CHANNEL_SURVEY_START);
- }
- uint32_t ble_gap_qos_channel_survey_stop_req_dec(uint8_t const * const p_buf,
- uint32_t packet_len)
- {
- SER_REQ_DEC_BEGIN(SD_BLE_GAP_QOS_CHANNEL_SURVEY_STOP);
- SER_REQ_DEC_END;
- }
- uint32_t ble_gap_qos_channel_survey_stop_rsp_enc(uint32_t return_code,
- uint8_t * const p_buf,
- uint32_t * const p_buf_len)
- {
- SER_RSP_ENC_RESULT_ONLY(SD_BLE_GAP_QOS_CHANNEL_SURVEY_STOP);
- }
- #endif
- #endif
|