GATT 称为通用属性规范 Generic Attribute profile,GATT 层是传输真正数据所在的层。GATT 程序模块的作用是用于协商和跟踪 GATT 连接参数和更新数据长度,在 BLE 程序中,初始化 GATT 程序模块只需调用库函数 nrf_ble_gatt_init ()即可完成初始化。
//初始化GATT程序模块
static void gatt_init(void)
{
//初始化GATT程序模块
ret_code_t err_code = nrf_ble_gatt_init(&m_gatt, NULL);
//检查函数返回的错误代码
APP_ERROR_CHECK(err_code);
}