btc_spp.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #ifndef __BTC_SPP_H__
  14. #define __BTC_SPP_H__
  15. #include "btc/btc_task.h"
  16. #include "esp_bt_defs.h"
  17. #include "esp_spp_api.h"
  18. #include "common/bt_target.h"
  19. #include "bta/bta_jv_api.h"
  20. #if (defined BTC_SPP_INCLUDED && BTC_SPP_INCLUDED == TRUE)
  21. #define ESP_SPP_MAX_SESSION BTA_JV_MAX_RFC_SR_SESSION
  22. #define ESP_SPP_SERVER_NAME_MAX 32
  23. #define ESP_SPP_RINGBUF_SIZE 1000
  24. #define BTC_SPP_INVALID_SCN 0x00
  25. typedef enum {
  26. BTC_SPP_ACT_INIT = 0,
  27. BTC_SPP_ACT_UNINIT,
  28. BTC_SPP_ACT_START_DISCOVERY,
  29. BTC_SPP_ACT_CONNECT,
  30. BTC_SPP_ACT_DISCONNECT,
  31. BTC_SPP_ACT_START_SRV,
  32. BTC_SPP_ACT_STOP_SRV,
  33. BTC_SPP_ACT_WRITE,
  34. } btc_spp_act_t;
  35. /* btc_spp_args_t */
  36. typedef union {
  37. //BTC_SPP_ACT_INIT
  38. struct init_arg {
  39. esp_spp_mode_t mode;
  40. } init;
  41. //BTC_SPP_ACT_UNINIT
  42. struct uninit_arg {
  43. } uninit;
  44. //BTC_SPP_ACT_START_DISCOVERY
  45. struct start_discovery_arg {
  46. BD_ADDR bd_addr;
  47. UINT16 num_uuid;
  48. tSDP_UUID *p_uuid_list;
  49. } start_discovery;
  50. //BTC_SPP_ACT_CONNECT
  51. struct connect_arg {
  52. esp_spp_sec_t sec_mask;
  53. esp_spp_role_t role;
  54. UINT8 remote_scn;
  55. esp_bd_addr_t peer_bd_addr;
  56. } connect;
  57. //BTC_SPP_ACT_DISCONNECT
  58. struct disconnect_arg {
  59. UINT32 handle;
  60. } disconnect;
  61. //BTC_SPP_ACT_START_SRV
  62. struct start_srv_arg {
  63. esp_spp_sec_t sec_mask;
  64. esp_spp_role_t role;
  65. UINT8 local_scn;
  66. UINT8 max_session;
  67. char name[ESP_SPP_SERVER_NAME_MAX + 1];
  68. } start_srv;
  69. //BTC_SPP_ACT_STOP_SRV
  70. struct stop_srv_arg {
  71. UINT8 scn;
  72. } stop_srv;
  73. //BTC_SPP_ACT_WRITE
  74. struct write_arg {
  75. UINT32 handle;
  76. int len;
  77. UINT8 *p_data;
  78. } write;
  79. } btc_spp_args_t;
  80. void btc_spp_call_handler(btc_msg_t *msg);
  81. void btc_spp_cb_handler(btc_msg_t *msg);
  82. void btc_spp_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
  83. esp_err_t btc_spp_vfs_register(void);
  84. #endif ///defined BTC_SPP_INCLUDED && BTC_SPP_INCLUDED == TRUE
  85. #endif ///__BTC_SPP_H__