我想定期执行 BLE“通知“、并尝试修改 basic_ble 作为基础。 为了实现固定的时间间隔、我认为 API“BLEAppUtil_startTimer"可能“可能很有用、但在 API 手册或其他地方找不到。
所以,我有几个问题:
(1) 请告诉我如何使用 BLEAppUtil_startTimer。
(2) 如果我要定期执行处理、使用此 API 是否正确? 如果有更好的方法、请告诉我。
此致。
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
我想定期执行 BLE“通知“、并尝试修改 basic_ble 作为基础。 为了实现固定的时间间隔、我认为 API“BLEAppUtil_startTimer"可能“可能很有用、但在 API 手册或其他地方找不到。
所以,我有几个问题:
(1) 请告诉我如何使用 BLEAppUtil_startTimer。
(2) 如果我要定期执行处理、使用此 API 是否正确? 如果有更好的方法、请告诉我。
此致。
您好:
可以使用 BLEAppUtil_startTimer:
/********************************************************************* * @fn BLEAppUtil_startTimer * * @brief Start a timer instance * * @param timerCB - callback function that will be called when the timer expired * @param timeInMS - the time to set in the timer * @param isPeriodic - a flag that indicates if the timer is periodic or not * @param pData - the data to pass to the timer callback * * @return Returns the timer handle */ BLEAppUtil_timerHandle BLEAppUtil_startTimer(BLEAppUtil_timerCB_t timerCB, uint32_t timeInMS, bool isPeriodic, void *pData);
您可以在中找到上述信息 /common/BLEAppUtil/inc/bleapputil_timers.h.
它的用法是标头中描述的内容。 您提供了一个在计时器到期时将调用的回调函数、到期前的时长(以毫秒为单位)、计时器是周期性的(如果它是每 x 毫秒发生一次,还是只发生一次)以及应传递给回调函数的数据。
或者、您可以使用 ClockP 驱动程序: ClockP.h 文件参考
BLEAppUtil_startTimer 实际上在后台使用 ClockP 驱动程序、为方便起见而提供、但如果您需要进一步控制计时器、请直接使用 ClockP。
希望这能有所帮助!
此致、
Nima Behmanesh