conn_mw_items.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /**
  2. * Copyright (c) 2014 - 2020, Nordic Semiconductor ASA
  3. *
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without modification,
  7. * are permitted provided that the following conditions are met:
  8. *
  9. * 1. Redistributions of source code must retain the above copyright notice, this
  10. * list of conditions and the following disclaimer.
  11. *
  12. * 2. Redistributions in binary form, except as embedded into a Nordic
  13. * Semiconductor ASA integrated circuit in a product or a software update for
  14. * such product, must reproduce the above copyright notice, this list of
  15. * conditions and the following disclaimer in the documentation and/or other
  16. * materials provided with the distribution.
  17. *
  18. * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * 4. This software, with or without modification, must only be used with a
  23. * Nordic Semiconductor ASA integrated circuit.
  24. *
  25. * 5. Any software provided in binary form under this license must not be reverse
  26. * engineered, decompiled, modified and/or disassembled.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
  29. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  30. * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
  31. * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
  32. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  33. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  34. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  36. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  37. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  38. *
  39. */
  40. #include "conn_mw_nrf_soc.h"
  41. #if defined(BLE_STACK_SUPPORT_REQD)
  42. #include "ble.h"
  43. #include "ble_gap.h"
  44. #include "ble_gattc.h"
  45. #include "ble_gatts.h"
  46. #ifndef S112
  47. #include "ble_l2cap.h"
  48. #endif //!S112
  49. #include "conn_mw_ble.h"
  50. #include "conn_mw_ble_l2cap.h"
  51. #include "conn_mw_ble_gap.h"
  52. #include "conn_mw_ble_gatts.h"
  53. #include "conn_mw_ble_gattc.h"
  54. #endif // defined(BLE_STACK_SUPPORT_REQD)
  55. #if defined(ANT_STACK_SUPPORT_REQD)
  56. #include "conn_mw_ant.h"
  57. #include "ant_interface.h"
  58. #endif // defined(ANT_STACK_SUPPORT_REQD)
  59. /**@brief Connectivity middleware handlers table. */
  60. static const conn_mw_item_t conn_mw_item[] = {
  61. //Functions from nrf_soc.h
  62. {SD_POWER_SYSTEM_OFF, conn_mw_power_system_off},
  63. {SD_TEMP_GET, conn_mw_temp_get},
  64. {SD_ECB_BLOCK_ENCRYPT, conn_mw_ecb_block_encrypt},
  65. #if defined(BLE_STACK_SUPPORT_REQD)
  66. //Functions from ble.h
  67. #if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4
  68. {SD_BLE_TX_PACKET_COUNT_GET, conn_mw_ble_tx_packet_count_get},
  69. #endif
  70. {SD_BLE_UUID_VS_ADD, conn_mw_ble_uuid_vs_add},
  71. {SD_BLE_UUID_DECODE, conn_mw_ble_uuid_decode},
  72. {SD_BLE_UUID_ENCODE, conn_mw_ble_uuid_encode},
  73. {SD_BLE_VERSION_GET, conn_mw_ble_version_get},
  74. {SD_BLE_OPT_GET, conn_mw_ble_opt_get},
  75. {SD_BLE_OPT_SET, conn_mw_ble_opt_set},
  76. {SD_BLE_ENABLE, conn_mw_ble_enable},
  77. {SD_BLE_USER_MEM_REPLY, conn_mw_ble_user_mem_reply},
  78. #if NRF_SD_BLE_API_VERSION >= 4
  79. {SD_BLE_CFG_SET, conn_mw_ble_cfg_set},
  80. #endif
  81. //Functions from ble_l2cap.h
  82. #ifndef S112
  83. #if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4
  84. {SD_BLE_L2CAP_CID_REGISTER, conn_mw_ble_l2cap_cid_register},
  85. {SD_BLE_L2CAP_CID_UNREGISTER, conn_mw_ble_l2cap_cid_unregister},
  86. {SD_BLE_L2CAP_TX, conn_mw_ble_l2cap_tx},
  87. #elif defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION >= 5
  88. {SD_BLE_L2CAP_CH_SETUP, conn_mw_l2cap_ch_setup},
  89. {SD_BLE_L2CAP_CH_RELEASE, conn_mw_l2cap_ch_release},
  90. {SD_BLE_L2CAP_CH_RX, conn_mw_l2cap_ch_rx},
  91. {SD_BLE_L2CAP_CH_TX, conn_mw_l2cap_ch_tx},
  92. {SD_BLE_L2CAP_CH_FLOW_CONTROL, conn_mw_l2cap_ch_flow_control},
  93. #endif
  94. #endif //!S112
  95. //Functions from ble_gap.h
  96. {SD_BLE_GAP_ADDR_SET, conn_mw_ble_gap_addr_set},
  97. {SD_BLE_GAP_ADDR_GET, conn_mw_ble_gap_addr_get},
  98. {SD_BLE_GAP_PRIVACY_SET, conn_mw_ble_gap_privacy_set},
  99. {SD_BLE_GAP_PRIVACY_GET, conn_mw_ble_gap_privacy_get},
  100. {SD_BLE_GAP_WHITELIST_SET, conn_mw_ble_gap_whitelist_set},
  101. {SD_BLE_GAP_DEVICE_IDENTITIES_SET, conn_mw_ble_gap_device_identities_set},
  102. #ifndef S112
  103. {SD_BLE_GAP_SCAN_START, conn_mw_ble_gap_scan_start},
  104. {SD_BLE_GAP_SCAN_STOP, conn_mw_ble_gap_scan_stop},
  105. {SD_BLE_GAP_CONNECT, conn_mw_ble_gap_connect},
  106. {SD_BLE_GAP_CONNECT_CANCEL, conn_mw_ble_gap_connect_cancel},
  107. {SD_BLE_GAP_ENCRYPT, conn_mw_ble_gap_encrypt},
  108. #endif
  109. {SD_BLE_GAP_SEC_INFO_REPLY, conn_mw_ble_gap_sec_info_reply},
  110. #if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 6
  111. {SD_BLE_GAP_ADV_DATA_SET, conn_mw_ble_gap_adv_data_set},
  112. #endif
  113. {SD_BLE_GAP_ADV_START, conn_mw_ble_gap_adv_start},
  114. {SD_BLE_GAP_ADV_STOP, conn_mw_ble_gap_adv_stop},
  115. {SD_BLE_GAP_CONN_PARAM_UPDATE, conn_mw_ble_gap_conn_param_update},
  116. {SD_BLE_GAP_DISCONNECT, conn_mw_ble_gap_disconnect},
  117. {SD_BLE_GAP_TX_POWER_SET, conn_mw_ble_gap_tx_power_set},
  118. {SD_BLE_GAP_APPEARANCE_SET, conn_mw_ble_gap_appearance_set},
  119. {SD_BLE_GAP_APPEARANCE_GET, conn_mw_ble_gap_appearance_get},
  120. {SD_BLE_GAP_PPCP_SET, conn_mw_ble_gap_ppcp_set},
  121. {SD_BLE_GAP_PPCP_GET, conn_mw_ble_gap_ppcp_get},
  122. {SD_BLE_GAP_DEVICE_NAME_SET, conn_mw_ble_gap_device_name_set},
  123. {SD_BLE_GAP_DEVICE_NAME_GET, conn_mw_ble_gap_device_name_get},
  124. {SD_BLE_GAP_AUTHENTICATE, conn_mw_ble_gap_authenticate},
  125. {SD_BLE_GAP_SEC_PARAMS_REPLY, conn_mw_ble_gap_sec_params_reply},
  126. {SD_BLE_GAP_AUTH_KEY_REPLY, conn_mw_ble_gap_auth_key_reply},
  127. {SD_BLE_GAP_SEC_INFO_REPLY, conn_mw_ble_gap_sec_info_reply},
  128. {SD_BLE_GAP_CONN_SEC_GET, conn_mw_ble_gap_conn_sec_get},
  129. {SD_BLE_GAP_RSSI_START, conn_mw_ble_gap_rssi_start},
  130. {SD_BLE_GAP_RSSI_STOP, conn_mw_ble_gap_rssi_stop},
  131. {SD_BLE_GAP_KEYPRESS_NOTIFY, conn_mw_ble_gap_keypress_notify},
  132. {SD_BLE_GAP_LESC_DHKEY_REPLY, conn_mw_ble_gap_lesc_dhkey_reply},
  133. {SD_BLE_GAP_LESC_OOB_DATA_SET, conn_mw_ble_gap_lesc_oob_data_set},
  134. {SD_BLE_GAP_LESC_OOB_DATA_GET, conn_mw_ble_gap_lesc_oob_data_get},
  135. {SD_BLE_GAP_RSSI_GET, conn_mw_ble_gap_rssi_get},
  136. #if NRF_SD_BLE_API_VERSION >= 5
  137. {SD_BLE_GAP_PHY_UPDATE, conn_mw_ble_gap_phy_update},
  138. #endif
  139. #if NRF_SD_BLE_API_VERSION >= 4 && !defined(S112)
  140. {SD_BLE_GAP_DATA_LENGTH_UPDATE, conn_mw_ble_gap_data_length_update},
  141. #endif
  142. #if NRF_SD_BLE_API_VERSION > 5
  143. {SD_BLE_GAP_ADV_SET_CONFIGURE, conn_mw_ble_gap_adv_set_configure},
  144. #ifndef S112
  145. {SD_BLE_GAP_QOS_CHANNEL_SURVEY_START, conn_mw_ble_gap_qos_channel_survey_start},
  146. {SD_BLE_GAP_QOS_CHANNEL_SURVEY_STOP, conn_mw_ble_gap_qos_channel_survey_stop},
  147. #endif //!S112
  148. #endif
  149. //Functions from ble_gattc.h
  150. {SD_BLE_GATTC_PRIMARY_SERVICES_DISCOVER, conn_mw_ble_gattc_primary_services_discover},
  151. {SD_BLE_GATTC_RELATIONSHIPS_DISCOVER, conn_mw_ble_gattc_relationships_discover},
  152. {SD_BLE_GATTC_CHARACTERISTICS_DISCOVER, conn_mw_ble_gattc_characteristics_discover},
  153. {SD_BLE_GATTC_DESCRIPTORS_DISCOVER, conn_mw_ble_gattc_descriptors_discover},
  154. {SD_BLE_GATTC_CHAR_VALUE_BY_UUID_READ, conn_mw_ble_gattc_char_value_by_uuid_read},
  155. {SD_BLE_GATTC_READ, conn_mw_ble_gattc_read},
  156. {SD_BLE_GATTC_CHAR_VALUES_READ, conn_mw_ble_gattc_char_values_read},
  157. {SD_BLE_GATTC_WRITE, conn_mw_ble_gattc_write},
  158. {SD_BLE_GATTC_HV_CONFIRM, conn_mw_ble_gattc_hv_confirm},
  159. {SD_BLE_GATTC_ATTR_INFO_DISCOVER, conn_mw_ble_gattc_attr_info_discover},
  160. {SD_BLE_GATTC_EXCHANGE_MTU_REQUEST, conn_mw_ble_gattc_exchange_mtu_request},
  161. //Functions from ble_gatts.h
  162. {SD_BLE_GATTS_SERVICE_ADD, conn_mw_ble_gatts_service_add},
  163. {SD_BLE_GATTS_INCLUDE_ADD, conn_mw_ble_gatts_include_add},
  164. {SD_BLE_GATTS_CHARACTERISTIC_ADD, conn_mw_ble_gatts_characteristic_add},
  165. {SD_BLE_GATTS_DESCRIPTOR_ADD, conn_mw_ble_gatts_descriptor_add},
  166. {SD_BLE_GATTS_VALUE_SET, conn_mw_ble_gatts_value_set},
  167. {SD_BLE_GATTS_VALUE_GET, conn_mw_ble_gatts_value_get},
  168. {SD_BLE_GATTS_HVX, conn_mw_ble_gatts_hvx},
  169. {SD_BLE_GATTS_SERVICE_CHANGED, conn_mw_ble_gatts_service_changed},
  170. {SD_BLE_GATTS_RW_AUTHORIZE_REPLY, conn_mw_ble_gatts_rw_authorize_reply},
  171. {SD_BLE_GATTS_SYS_ATTR_SET, conn_mw_ble_gatts_sys_attr_set},
  172. {SD_BLE_GATTS_SYS_ATTR_GET, conn_mw_ble_gatts_sys_attr_get},
  173. {SD_BLE_GATTS_INITIAL_USER_HANDLE_GET, conn_mw_ble_gatts_initial_user_handle_get},
  174. {SD_BLE_GATTS_ATTR_GET, conn_mw_ble_gatts_attr_get},
  175. {SD_BLE_GATTS_EXCHANGE_MTU_REPLY, conn_mw_ble_gatts_exchange_mtu_reply},
  176. #endif // // defined(BLE_STACK_SUPPORT_REQD)
  177. #if defined(ANT_STACK_SUPPORT_REQD)
  178. //Functions from ant_interface.h
  179. {SVC_ANT_ENABLE, conn_mw_ant_enable},
  180. {SVC_ANT_CHANNEL_ASSIGN, conn_ant_channel_assign},
  181. {SVC_ANT_CHANNEL_OPEN, conn_ant_channel_open_with_offset},
  182. {SVC_ANT_CHANNEL_ID_SET, conn_ant_channel_id_set},
  183. {SVC_ANT_CHANNEL_PERIOD_SET, conn_ant_channel_period_set},
  184. {SVC_ANT_CHANNEL_RADIO_FREQ_SET, conn_ant_channel_radio_freq_set},
  185. {SVC_ANT_TX_BROADCAST_MESSAGE, conn_ant_broadcast_message_tx},
  186. {SVC_ANT_TX_ACKNOWLEDGED_MESSAGE, conn_ant_acknowledge_message_tx},
  187. {SVC_ANT_CHANNEL_UNASSIGN, conn_ant_channel_unassign},
  188. {SVC_ANT_CHANNEL_CLOSE, conn_ant_channel_close},
  189. {SVC_ANT_NETWORK_KEY_SET, conn_ant_network_address_set},
  190. {SVC_ANT_CHANNEL_RADIO_TX_POWER_SET, conn_ant_channel_radio_tx_power_set},
  191. {SVC_ANT_CHANNEL_SEARCH_TIMEOUT_SET, conn_ant_channel_rx_search_timeout_set},
  192. {SVC_ANT_CHANNEL_LOW_PRIO_RX_SEARCH_TIMEOUT_SET, conn_ant_channel_low_priority_rx_search_timeout_set},
  193. {SVC_ANT_PROX_SEARCH_SET, conn_ant_prox_search_set},
  194. {SVC_ANT_SEARCH_WAVEFORM_SET, conn_ant_search_waveform_set},
  195. {SVC_ANT_CHANNEL_ID_GET, conn_ant_channel_id_get},
  196. {SVC_ANT_CHANNEL_RADIO_FREQ_GET, conn_ant_channel_radio_freq_get},
  197. {SVC_ANT_CHANNEL_PERIOD_GET, conn_ant_channel_period_get},
  198. {SVC_ANT_SEARCH_CHANNEL_PRIORITY_SET, conn_ant_search_channel_priority_set},
  199. {SVC_ANT_ACTIVE_SEARCH_SHARING_CYCLES_SET, conn_ant_active_search_sharing_cycles_set},
  200. {SVC_ANT_LIB_CONFIG_SET, conn_ant_lib_config_set},
  201. {SVC_ANT_ACTIVE_SEARCH_SHARING_CYCLES_GET, conn_ant_active_search_sharing_cycles_get},
  202. {SVC_ANT_LIB_CONFIG_GET, conn_ant_lib_config_get},
  203. {SVC_ANT_LIB_CONFIG_CLEAR, conn_ant_lib_config_clear},
  204. {SVC_ANT_STACK_INIT, conn_ant_stack_reset},
  205. {SVC_ANT_RX_SCAN_MODE_START, conn_ant_rx_scan_mode_start},
  206. {SVC_ANT_ID_LIST_ADD, conn_ant_id_list_add},
  207. {SVC_ANT_ID_LIST_CONFIG, conn_ant_id_list_config},
  208. {SVC_ANT_CHANNEL_STATUS_GET, conn_ant_channel_status_get},
  209. {SVC_ANT_INIT_CW_TEST_MODE, conn_ant_cw_test_mode_init},
  210. {SVC_ANT_CW_TEST_MODE, conn_ant_cw_test_mode},
  211. {SVC_ANT_VERSION, conn_ant_version_get},
  212. {SVC_ANT_CAPABILITIES, conn_ant_capabilities_get},
  213. {SVC_ANT_CRYPTO_CHANNEL_ENABLE, conn_ant_crypto_channel_enable},
  214. {SVC_ANT_ADV_BURST_CONFIG_SET, conn_ant_adv_burst_config_set},
  215. {SVC_ANT_CRYPTO_KEY_SET, conn_ant_crypto_key_set},
  216. {SVC_ANT_CRYPTO_INFO_SET, conn_ant_crypto_info_set},
  217. {SVC_ANT_CRYPTO_INFO_GET, conn_ant_crypto_info_get},
  218. {SVC_ANT_COEX_CONFIG_SET, conn_ant_coex_config_set},
  219. {SVC_ANT_COEX_CONFIG_GET, conn_ant_coex_config_get},
  220. #endif // // defined(ANT_STACK_SUPPORT_REQD)
  221. };