yc11xx_bt_interface.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * Copyright 2016, yichip Semiconductor(shenzhen office)
  3. * All Rights Reserved.
  4. *
  5. * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Yichip Semiconductor;
  6. * the contents of this file may not be disclosed to third parties, copied
  7. * or duplicated in any form, in whole or in part, without the prior
  8. * written permission of Yichip Semiconductor.
  9. */
  10. /**
  11. *@file yc11xx_bt_interface
  12. *@brief bt support for application.
  13. */
  14. #ifndef _YC_BT_INTERFACE_H
  15. #define _YC_BT_INTERFACE_H
  16. #include "yc11xx.h"
  17. #include "ipc.h"
  18. #include "ycdef.h"
  19. #include <stdbool.h>
  20. #include <string.h>
  21. #define MAX_MTU_SIZE 200
  22. #define MIN_MTU_SIZE 23
  23. #define LE_ADV_DATA_MAX_LENGTH 31
  24. #define LE_SCAN_RSP_MAX_LENGTH 31
  25. #define LE_MAX_PATCKET_LENGTH HREAD(mem_mtu_size)
  26. #define Adv_Type_Flags 0x01
  27. #define Adv_Type_CompleteLocalName 0x09
  28. typedef struct
  29. {
  30. uint8_t topState;
  31. uint8_t secondState;
  32. uint8_t thirdlyState;
  33. }BR_STATE;
  34. //ble state enumration
  35. typedef enum
  36. {
  37. BLE_STATE_INVALID,
  38. BLE_IDLE,
  39. BLE_ADV,
  40. BLE_CONNECTING,
  41. BLE_CONNECTED,
  42. BLE_PAIRED,
  43. BLE_FAST_PAIRED,
  44. BLE_DIRECT_ADV,
  45. }BLE_STATE_TYPE;
  46. typedef struct
  47. {
  48. uint8_t topState;
  49. uint8_t secondState;
  50. }BLE_STATE;
  51. //adv type enumration
  52. typedef enum {
  53. ADV_TYPE_NOMAL,
  54. ADV_TYPE_DIRECT,
  55. ADV_TYPE_NOCONNECT,
  56. SCAN_REQ,
  57. SCAN_RSP,
  58. CONNECT_REQ,
  59. ADV_TYPE_SCAN,
  60. }advType;
  61. //scan type enumration
  62. typedef enum {
  63. SCAN_TYPE_PASSIVE,
  64. SCAN_TYPE_ACTIVE,
  65. }scanType;
  66. //adv state enumration
  67. typedef enum
  68. {
  69. ADV_DISABLE=0x00,
  70. ADV_ENABLE=0x01,
  71. }ADV_STATE;
  72. typedef struct
  73. {
  74. uint16_t min_interval; /*Defines minimum value for the conntection event interval in the following manner.
  75. *min_interval range: 6 to 800.
  76. *Time = min_interval * 1.25ms;
  77. *min_interval shall be less than or equal to max_interval.
  78. */
  79. uint16_t max_interval; /* maximum value for the conntection event interval.
  80. *max_interval range: 6 to 800.
  81. *Time = max_interval * 1.25ms;
  82. *max_interval shall be greater than or equal to min_interval.
  83. */
  84. uint16_t latency; /* slave latency for the conntection in number of connection events.
  85. *range: 0 to 499.
  86. */
  87. uint16_t timeout; /* Supervision timeout for the LE link.
  88. *range: 10 to 3200.
  89. *Time = timeout * 10 ms.
  90. *timeout >( (1+latency) * max_interval ).
  91. */
  92. }BLE_Conn_param;
  93. void Bt_SndCmdSppStartDiscovery(void);
  94. void Bt_SndCmdSppStopDiscovery(void);
  95. void Bt_GetSppMac(uint8_t *adr);
  96. void Bt_SetSppAddr(uint8_t *adr);
  97. bool Bt_SetSppName(uint8_t *name,int len);
  98. bool Bt_SndSppData(uint8_t *data,uint8_t len);
  99. void Bt_SndCmdLeStartAdv(void);
  100. void Bt_SndCmdLeStopAdv(void);
  101. void Bt_SndCmdLeStartDirectAdv(void);
  102. void Bt_SndCmdLeStopDirectAdv(void);
  103. void Bt_SndCmdLeStartScanAdv(void);
  104. void Bt_SndCmdLeDisconnect(void);
  105. void Bt_SndCmdLeUpdateConn(BLE_Conn_param* param);
  106. void Bt_SetLocalMtuSize(uint16_t size);
  107. void Bt_SndCmdLeUpdateAttMTU(void);
  108. void Bt_GetLeMac(uint8_t *adr);
  109. void Bt_SetLeMac(uint8_t *adr);
  110. uint8_t Bt_Re_LeAdvName(uint8_t *name,uint8_t len);
  111. void Bt_Re_LeDeivcename(uint8_t *name,uint8_t len);
  112. bool Bt_Renew_Le_AdvData(uint8_t *data,uint8_t len);
  113. bool Bt_Renew_Le_ScanRsp(uint8_t *data,uint8_t len);
  114. void Bt_SetLeAdvType(advType Type);
  115. void Bt_SetLeScanRspType(scanType Type);
  116. void Bt_SetLeAdvInterval(uint16_t gap);
  117. bool Bt_SndBleData(uint16_t BLE_WRITE_HANDLE, uint8_t *data, uint8_t len);
  118. void Bt_SndCmdStartScan(void);
  119. void Bt_SndCmdStopScan(void);
  120. void Bt_SndCmdPwroff(void);
  121. #endif