spp.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #include "include.h"
  2. #include "api.h"
  3. const uint8_t sdp_spp_service_record[] = {
  4. 0x36, 0x00, 0x54, 0x09, 0x00, 0x00, 0x0a, 0x00, 0x01, 0x00, 0x01, 0x09, 0x00, 0x01, 0x36, 0x00,
  5. 0x03, 0x19, 0x11, 0x01, 0x09, 0x00, 0x04, 0x36, 0x00, 0x0e, 0x36, 0x00, 0x03, 0x19, 0x01, 0x00,
  6. 0x36, 0x00, 0x05, 0x19, 0x00, 0x03, 0x08, SPP_RFCOMM_SERVER_CHANNEL0, 0x09, 0x00, 0x05, 0x36,
  7. 0x00, 0x03, 0x19, 0x10, 0x02, 0x09, 0x00, 0x06, 0x36, 0x00, 0x09, 0x09, 0x65, 0x6e, 0x09, 0x00,
  8. 0x6a, 0x09, 0x01, 0x00, 0x09, 0x00, 0x09, 0x36, 0x00, 0x09, 0x36, 0x00, 0x06, 0x19, 0x11, 0x01,
  9. 0x09, 0x01, 0x02, 0x09, 0x01, 0x00, 0x25, 0x03, 0x53, 0x50, 0x50,
  10. };
  11. #if BT_SPP_EN
  12. #if LE_DUEROS_DMA_EN
  13. #define SPP_TX_BUF_INX 3
  14. #define SPP_TX_BUF_LEN DUEROS_DMA_MTU_MAX_LEN //max=512
  15. #else
  16. #define SPP_TX_BUF_INX 4
  17. #define SPP_TX_BUF_LEN 400 //256 //max=512
  18. #endif
  19. #define SPP_POOL_SIZE (SPP_TX_BUF_LEN + sizeof(struct txbuf_tag)) * SPP_TX_BUF_INX
  20. AT(.ble_buf.stack.spp)
  21. uint8_t spp_tx_pool[SPP_POOL_SIZE];
  22. void spp_txpkt_init(void)
  23. {
  24. txpkt_init(&spp_tx_ch0, spp_tx_pool, SPP_TX_BUF_INX, SPP_TX_BUF_LEN);
  25. spp_tx_ch0.send_kick = spp_send_kick;
  26. }
  27. u16 get_spp_mtu_size(void)
  28. {
  29. return SPP_TX_BUF_LEN;
  30. }
  31. void spp_rx_callback(uint8_t *bd_addr, uint8_t ch, uint8_t *packet, uint16_t size)
  32. {
  33. if (ch == SPP_SERVICE_CH1) {
  34. #if GFPS_EN
  35. gfps_spp_recv_callback(packet, size);
  36. #endif
  37. }
  38. app_spp_rx_callback(ch, packet, size);
  39. }
  40. void spp_connect_callback(uint8_t *bd_addr, uint8_t ch)
  41. {
  42. printf("--->spp_connect_callback ch:%d\n",ch);
  43. if (ch == SPP_SERVICE_CH1) {
  44. #if GFPS_EN
  45. gfps_spp_connected_callback();
  46. #endif
  47. }
  48. app_spp_connect_callback(ch);
  49. #if ANC_TOOL_EN
  50. if (ch == SPP_SERVICE_CH0) {
  51. anc_tool_spp_connect_callback();
  52. }
  53. #endif // ANC_TOOL_EN
  54. }
  55. void spp_disconnect_callback(uint8_t *bd_addr, uint8_t ch)
  56. {
  57. printf("--->spp_disconnect_callback ch:%d\n",ch);
  58. app_spp_disconnect_callback(ch);
  59. #if ANC_TOOL_EN
  60. if (ch == SPP_SERVICE_CH0) {
  61. anc_tool_spp_disconnect_callback();
  62. }
  63. #endif // ANC_TOOL_EN
  64. }
  65. #endif