XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XX Author: ZHS (cultural person)
XX Contact: Chat at the end of the article ( or enter the group: 471144274 )
XX Copyright statement: Original article, welcome to comment and reprint~ It’s best to tell me when reprinting
What XX has to say: The author's level is limited, and it is inevitable that there are deficiencies. Please correct me!
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Reference link: https://blog.csdn.net/wzz4420381/article/details/78359481
1. Under tools\include\profiles\BlueLab-7.0.3-Release, write .dbi and .h
2、
.h file
#define UUID_EXAMPLE_SERVER 0xFF00
#define UUID_EXAMPLE_SERVER_TO_CLIENT 0xFF01
.dbi file
#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",
flags :[FLAG_IRQ],
properties :[write, notify],
value :0x0,
client_config
{
name : "EXAMPLE_SERVER_TO_CLIENT_CHAR_CFG",
flags : [ FLAG_IRQ ]
}
}
},
#endif /*__GATT_EXAMPLE_SERVER_DB_DBI__*/
3、
.h file
#define UUID_EXAMPLE_SERVER 0xFF00
#define UUID_EXAMPLE_SERVER_TO_CLIENT 0xFF01
#define UUID_EXAMPLE_CLIENT_TO_SERVER 0xFF02
.dbi file
#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",
flags :[FLAG_IRQ],
properties :[notify],
size_value :0x14,
client_config
{
name : "EXAMPLE_SERVER_TO_CLIENT_CHAR_CFG",
flags : [ FLAG_IRQ ]
}
},
characteristic{
uuid :UUID_EXAMPLE_CLIENT_TO_SERVER,
name :"EXAMPLE_CLIENT_TO_SERVER",
flags :[FLAG_IRQ],
properties :[write_cmd],
size_value :0x14
}
},
#endif /*__GATT_EXAMPLE_SERVER_DB_DBI__*/
4. Add #include "gatt_example_server_db.dbi" in sink_gatt_db.db;
5. Just compile, and sink_gatt_db.c and sink_gatt_db.h will be generated.
6. When connecting, it will access the interface display information such as CCC, the protocol stack report event GATT_MANAGER_SERVER_ACCESS_IND will enter sinkGattManagerMsgHandler, the native code general GATT is not processed here, as shown in the figure below, it needs to be modified to: gatt_status_success
Modify it as follows, and add the GATT ind function handleMGattAccessInd at the same time, as shown below:
Then implement the interface, and implement the write and read interfaces at the same time, as shown in the figure below:
7. The interface for GATT to send data is: