在peripheral例子里面其实是有连接参数更新状态回调,主要是连接间隔和连接超时时间握手后的结果
在HID例子添加只要在一个文件(以HIDKeyboard为例子,在hidkbd.c里面修改)里面修改3个地方
第一步:
static void peripheralParamUpdateCB(uint16_t connHandle, uint16_t connInterval, uint16_t connSlaveLatency, uint16_t connTimeout); //函数声明
第二步:
// GAP Role Callbacks static gapRolesCBs_t Peripheral_PeripheralCBs = { NULL, // Profile State Change Callbacks NULL, // When a valid RSSI is read from controller (not used by application) peripheralParamUpdateCB }; //定义GAP层回调
第三步:
static void peripheralParamUpdateCB(uint16_t connHandle, uint16_t connInterval, uint16_t connSlaveLatency, uint16_t connTimeout) { if(connHandle == hidEmuConnHandle) { // peripheralConnList.connInterval = connInterval; // peripheralConnList.connSlaveLatency = connSlaveLatency; // peripheralConnList.connTimeout = connTimeout; PRINT("Update %x - Int %x \n", connHandle, connInterval); } else { PRINT("ERR..\n"); } }//添加函数实体,连接参数协商后会自动调用,参数可以自定义变量存储下来
编译:
执行效果展示:
标签:connHandle,connSlaveLatency,connInterval,CH573,uint16,CH579,connTimeout,连接,CH32F From: https://www.cnblogs.com/debugdabiaoge/p/17024598.html