像这样更改广播间隔可以吗?
可以参考下方动态广播的链接:https://www.cnblogs.com/risc5-ble/p/16619902.html
有两种方式实现,一种是通过关闭广播跟新参数再打开广播实现,另一种是调用更新广播内容函数,只可以改变内容。
上述方法可以修改广播数据,修改广播间隔需要GAPRole_SetParameter GAPROLE_MIN_CONN_INTERVAL与?GAP_SetParamValue?TGAP_DISC_ADV_INT_MIN等4个参数吗?
使用关闭广播修改参数再开启广播的方式是可以修改广播间隔的。
uint16_t advInt = DEFAULT_ADVERTISING_INTERVAL;
GAP_SetParamValue(TGAP_DISC_ADV_INT_MIN, advInt);
GAP_SetParamValue(TGAP_DISC_ADV_INT_MAX, advInt);
验证广播间隔是可以调整的,请问怎么获取是否正在广播的状态呢?peripheralStateNotificationCB会通报新状态,有没有更直接读取的接口呢?
可以使用此函数去获取状态:GAPRole_GetParameter(GAPROLE_STATE , &state);
#define GAPROLE_INIT 0 //!< Waiting to be started
#define GAPROLE_STARTED 1 //!< Started but not advertising
#define GAPROLE_ADVERTISING 2 //!< Currently Advertising
#define GAPROLE_WAITING 3 //!< Device is started but not advertising, is in waiting period before advertising again
#define GAPROLE_CONNECTED 4 //!< In a connection
#define GAPROLE_CONNECTED_ADV 5 //!< In a connection + advertising
#define GAPROLE_ERROR 6 //!< Error occurred - invalid state
谢谢