gfps.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #include "include.h"
  2. #include "gfps.h"
  3. #if GFPS_EN
  4. const uint8_t sdp_gfps_spp_service_record[] = {
  5. 0x36, 0x00, 0x62, 0x09, 0x00, 0x00, 0x0a, 0x50, 0x01, 0x00, 0x01, 0x09, 0x00, 0x01, 0x36, 0x00,
  6. 0x11, 0x1C, 0xdf, 0x21, 0xfe, 0x2c, 0x25, 0x15, 0x4f, 0xdb, 0x88, 0x86, 0xf1, 0x2c, 0x4d, 0x67,
  7. 0x92, 0x7c, 0x09, 0x00, 0x04, 0x36, 0x00, 0x0e, 0x36, 0x00, 0x03, 0x19, 0x01, 0x00, 0x36, 0x00,
  8. 0x05, 0x19, 0x00, 0x03, 0x08, 0x05, 0x09, 0x00, 0x05, 0x36, 0x00, 0x03, 0x19, 0x10, 0x02, 0x09,
  9. 0x00, 0x06, 0x36, 0x00, 0x09, 0x09, 0x65, 0x6e, 0x09, 0x00, 0x6a, 0x09, 0x01, 0x00, 0x09, 0x00,
  10. 0x09, 0x36, 0x00, 0x09, 0x36, 0x00, 0x06, 0x19, 0x11, 0x01, 0x09, 0x11, 0x02, 0x09, 0x01, 0x00,
  11. 0x25, 0x03, 0x53, 0x50, 0x50,
  12. };
  13. #if !AB_MATE_APP_EN
  14. // ---------------------------------------------------------------------------
  15. const uint8_t adv_data_const[] = {
  16. // Flags general discoverable, BR/EDR not supported
  17. 0x02, 0x01, 0x06,
  18. // GFPS, Tx Power, -20dBm
  19. 0x02, 0x0A, 0xF5,
  20. };
  21. const uint8_t scan_data_const[] = {
  22. // Name
  23. 0x08, 0x09, 'B', 'L', 'E', '-', 'B', 'O', 'X',
  24. };
  25. u32 ble_get_scan_data(u8 *scan_buf, u32 buf_size)
  26. {
  27. memset(scan_buf, 0, buf_size);
  28. u32 data_len = sizeof(scan_data_const);
  29. memcpy(scan_buf, scan_data_const, data_len);
  30. //读取BLE配置的蓝牙名称
  31. int len;
  32. len = strlen(xcfg_cb.le_name);
  33. if (len > 0) {
  34. memcpy(&scan_buf[2], xcfg_cb.le_name, len);
  35. data_len = 2 + len;
  36. scan_buf[0] = len + 1;
  37. }
  38. return data_len;
  39. }
  40. u32 ble_get_adv_data(u8 *adv_buf, u32 buf_size)
  41. {
  42. memset(adv_buf, 0, buf_size);
  43. u32 data_len = sizeof(adv_data_const);
  44. memcpy(adv_buf, adv_data_const, data_len);
  45. return data_len;
  46. }
  47. ///////////////////////////////////////////////////////////////////////////
  48. #define MAX_NOTIFY_NUM 8
  49. #define MAX_NOTIFY_LEN 256 //max=256
  50. #define NOTIFY_POOL_SIZE (MAX_NOTIFY_LEN + sizeof(struct txbuf_tag)) * MAX_NOTIFY_NUM
  51. AT(.gfps.ble_att)
  52. uint8_t notify_tx_pool[NOTIFY_POOL_SIZE];
  53. void ble_txpkt_init(void)
  54. {
  55. txpkt_init(&notify_tx, notify_tx_pool, MAX_NOTIFY_NUM, MAX_NOTIFY_LEN);
  56. notify_tx.send_kick = ble_send_kick;
  57. }
  58. #endif
  59. #endif