1. 程式人生 > >CSR867x — 如何新增一個GATT Server

CSR867x — 如何新增一個GATT Server

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XX  作       者:ZHS(文化人)

XX  聯絡方式:文章末尾Chat快問(或進群:471144274

XX  要說的話:作者水平有限,難免有不足之處,懇請指正!

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

1、tools\include\profiles\BlueLab-7.0.3-Release路徑下,編寫.dbi和.h

2、

.h檔案

#define UUID_EXAMPLE_SERVER FF00

#define UUID_EXAMPLE_SERVER_TO_CLIENT FF01

.dbi檔案

#ifndef __GATT_EXAMPLE_SERVER_DB_DBI__

#define __GATT_EXAMPLE_SERVER_DB_DBI__

#include "gatt_example_server_uuids.h"

/*Primary service declaration of example service*/

primary_service{

           uuid:UUID_EXAMPLE_SERVER,

           name:"EXAMPLE_SERVER",

           /*example level characteristic*/

           characteristic{

                      uuid :UUID_EXAMPLE_SERVER_TO_CLIENT,

                      name :"EXAMPLE_SERVER_TO_CLIENT",

                      properties :[read, write, notify],

                      flags :[FLAG_IRQ],

                      value :0x3,

                      client_config

                      {

                                 name : "EXAMPLE_SERVER_TO_CLIENT_CHAR_CFG",

                                 flags : [ FLAG_IRQ ]

                      }

           }

},

#endif /*__GATT_EXAMPLE_SERVER_DB_DBI__*/

3、在sink_gatt_db.db中新增 #include "gatt_example_server_db.dbi";

4、編譯即可,會生成sink_gatt_db.c和sink_gatt_db.h。

5、連線時,會訪問CCC等介面顯示資訊,協議棧上報事件GATT_MANAGER_SERVER_ACCESS_IND會進入sinkGattManagerMsgHandler,原生程式碼通用GATT這裡是不處理的,如下圖,要修改為:gatt_status_success

6、GATT傳送資料的介面為: