本文将用前灯为例子。
**
1. 车灯通道
**
对于车灯,必须要创建两个通道,分别为主通道和共享通道。
小提示:通道开启数量是固定的,不是动态开启。修改位置如下:(全局搜索)
关键字:ANT_CONFIG_TOTAL_CHANNELS_ALLOCATED
检测是否已连接(Light_Index!=0),成功连接后,才允许开启共享通道。
/*********************************************
函数名:ant_BikeLight_SHARED_MASTER_Init
功 能:共享通道初始化
形 参:ch--> 0--主灯共享通道(可发可接) 1--副灯共享通道(只接)
返回值:
备 注:
作 者:薛建强
时 间:2020/02/27
使 用:
**********************************************/
void ant_BikeLight_SHARED_MASTER_Init(void)
{
uint32_t err_code = 0;
uint8_t pucStatus = 0;
/*共享通道*/
if (SystemInit_Type.ANT_SHARED_CHANNEL == 0)
{
pucStatus = ant_BikeLight_Shared_close(ant_channel_Shared.channel_number);//关闭共享通道
if (pucStatus == 100) //通道成功未关闭
{
return;
}
else if ((pucStatus == 17) || (pucStatus == STATUS_ASSIGNED_CHANNEL))
{
err_code = sd_ant_channel_unassign(BikeLight_Shared_CHANNEL_NUMBER);
SEGGER_RTT_printf(0, "ANT BikeLight Shared channel_unassign %u close %d\n\r", BikeLight_Shared_CHANNEL_NUMBER, err_code);
}
if (m_ant_BikeLight.page_33.Light_Index_Set == 1)//ID=1,主灯
{
ant_channel_Shared.channel_type = BikeLight_SENS_CHANNEL_TYPE_Shared;
//ant_channel_Shared.device_number = BikeLight_DEVICE_NUMBER; //将ANT设备号设置为MAC地址
ant_channel_Shared.device_number = NRF_FICR->DEVICEADDR[0]; //将ANT设备号设置为MAC地址
}
else if (m_ant_BikeLight.page_33.Light_Index_Set > 1)//ID>1,副灯
{
ant_channel_Shared.channel_type = BikeLight_DISP_CHANNEL_TYPE_Shared;
//ant_channel_Shared.device_number = BikeLight_DEVICE_NUMBER; //将ANT设备号设置为MAC地址
ant_channel_Shared.device_number = NRF_FICR->DEVICEADDR[0]; //将ANT设备号设置为MAC地址
}
else
{
SEGGER_RTT_printf(0, "Shared_open_fail,not Light_Index!!! %d\r\n", m_ant_BikeLight.page_33.Light_Index_Set);
return;
}
ant_channel_Shared.channel_number = BikeLight_Shared_CHANNEL_NUMBER; //通道号
ant_channel_Shared.ext_assign = BikeLight_EXT_ASSIGN; //ANT 外部分配.
ant_channel_Shared.rf_freq = BikeLight_ANTPLUS_RF_FREQ; //频率
ant_channel_Shared.transmission_type = m_ant_BikeLight.page_33.Transmission_Type; //主灯的传送类型
ant_channel_Shared.device_type = BikeLight_DEVICE_TYPE_Shared; //设备类型
ant_channel_Shared.device_number = m_ant_BikeLight.page_33.DeviceNumber_MSB << 8 | m_ant_BikeLight.page_33.DeviceNumber_LSB;
ant_channel_Shared.channel_period = BikeLight_MSG_PERIOD_8Hz;//消息周期
ant_channel_Shared.network_number = 0;
err_code = ant_channel_init(&ant_channel_Shared);
APP_ERROR_CHECK(err_code);
err_code = ant_BikeLight_Shared_open(&ant_channel_Shared);
SEGGER_RTT_printf(0, "Shared_open,err_code=%02X device_number:%d transmission_type:%d\r\n", err_code, ant_channel_Shared.device_number, ant_channel_Shared.transmission_type);
APP_ERROR_CHECK(err_code);
if (SystemInit_Type.ANT_SHARED_CHANNEL == 1 && SystemReg.ANT_SHARED_CHANNEL == 2)
{
err_code = ANT_Send_Message(BikeLight_Shared_CHANNEL_NUMBER, ANT_message_payload_Shared_Wait);
ANT_Relay_New_Share_Page = 0; //发送指定页
}
}
}
**
2. 通道类型
**
/**@brief ANT channel configuration structure. */
typedef struct
{
uint8_t channel_number; ///< 分配的频道号。
uint8_t channel_type; ///< 通道类型 (see Assign Channel Parameters in ant_parameters.h: @ref ant_parameters).
uint8_t ext_assign; ///< 扩展分配 (see Ext. Assign Channel Parameters in ant_parameters.h: @ref ant_parameters).
uint8_t rf_freq; ///< 射频偏移 2400 MHz (for example, 2466 MHz, ucFreq = 66).
uint8_t transmission_type; ///< 传输类型.
uint8_t device_type; ///< 设备类型.
uint16_t device_number; ///< 设备编号.
uint16_t channel_period; ///< 32千赫的周期计数。
uint8_t network_number; ///< 表示网络密钥的网络号.
#if ANT_CONFIG_ENCRYPTED_CHANNELS > 0
ant_encrypt_channel_settings_t * p_crypto_settings; ///< 指向加密设置的指针,如果必须省略此配置,则为空。
#endif
} ant_channel_config_t;
主通道配置:
channel_number :0 //通道0
channel_type :0x10 ///< 主频道 (PARAMETER_TX_NOT_RX).
ext_assign :0x10 //通道快速启动模式。
rf_freq :57//频率,十进制 57 (2457 MHz).
transmission_type:5u //广播通道
device_type :0x23 //设备类型:车灯==35(广播通道类型)
device_number :NRF_FICR->DEVICEADDR[0]; //将ANT设备号设置为MAC地址
channel_period:4084///< 消息周期,十进制 4035 (8.12 Hz)
network_number:0
共享通道配置:
channel_number :1 //通道1
这里的通道类型需要根据实际控制:
当索引号为0时:
channel_type :0x10 ///< 主频道 (PARAMETER_TX_NOT_RX).
当索引号为>0时:
channel_type :0x00 ///< 从属信道 (PARAMETER_RX_NOT_TX).
ext_assign :0x10 //通道快速启动模式。
rf_freq :57//频率,十进制 57 (2457 MHz).
transmission_type:6u //共享通道
device_type :0x24 ///< 设备类型:车灯==36(共享通道类型)
device_number :m_ant_BikeLight.page_33.DeviceNumber_MSB << 8 | m_ant_BikeLight.page_33.DeviceNumber_LSB;//设备号有P33连接命令决定。
channel_period:4084///< 消息周期,十进制 4035 (8.12 Hz).
network_number:0
**
3. 数据轮询
**
由于前面设置了8HZ(125ms)的消息周期,所以20*9=180ms。这样消息冲撞概率会小。
/*********************************************
函数名:ant_message_send
功 能:用于设置ANT消息的有效负载并发送它的函数。(广播通道)
形 参:p_profile--指向配置文件实例的指针。
返回值:
备 注:
作 者:薛建强
时 间:2020/02/27
使 用:
**********************************************/
void ant_message_send(ant_BikeLight_profile_t *p_profile)
{
uint32_t err_code;
if (ANT_PAGE_NEW < 127) //广播通道的内容
{
sens_message_encode(p_profile, ANT_message_payload);//对广播命令进行编码
err_code = sd_ant_broadcast_message_tx(p_profile->channel_number, 8, ANT_message_payload);//发送广播命令
// if (ANT_message_payload[0] == 18)
// {
SEGGER_RTT_printf(0, "channel0---TX page_%02d: %02X %02X %02X %02X %02X %02X %02X %02X --err_code:%d\n\r", \
ANT_message_payload[0], Replace_Buff(ANT_message_payload), err_code
);//打印发送共享命令
// }
}
else//共享通道的内容
{
if (ANT_PAGE_NEW == 127 + 1)
{
err_code = sd_ant_broadcast_message_tx(p_profile->channel_number, 8, ANT_message_payload_Wait_2);//共享通道的内容转发广播通道
SEGGER_RTT_printf(0, "[channel3---TX page_%02d: %02X %02X %02X %02X %02X %02X %02X %02X --err:%d]\n\r", \
ANT_PAGE_NEW - 127, Replace_Buff(ANT_message_payload_Wait_2), err_code
);//打印发送共享命令
}
else if (ANT_PAGE_NEW == 127 + 2)
{
err_code = sd_ant_broadcast_message_tx(p_profile->channel_number, 8, ANT_message_payload_Wait_3);//共享通道的内容转发广播通道
SEGGER_RTT_printf(0, "[channel3---TX page_%02d: %02X %02X %02X %02X %02X %02X %02X %02X --err:%d]\n\r", \
ANT_PAGE_NEW - 127, Replace_Buff(ANT_message_payload_Wait_3), err_code
);//打印发送共享命令
}
else if (ANT_PAGE_NEW == 127 + 3)
{
err_code = sd_ant_broadcast_message_tx(p_profile->channel_number, 8, ANT_message_payload_Wait_4);//共享通道的内容转发广播通道
SEGGER_RTT_printf(0, "[channel3---TX page_%02d: %02X %02X %02X %02X %02X %02X %02X %02X --err:%d]\n\r", \
ANT_PAGE_NEW - 127, Replace_Buff(ANT_message_payload_Wait_4), err_code
);//打印发送共享命令
}
else if (ANT_PAGE_NEW == 127 + 4)
{
err_code = sd_ant_broadcast_message_tx(p_profile->channel_number, 8, ANT_message_payload_Wait_5);//共享通道的内容转发广播通道
SEGGER_RTT_printf(0, "[channel3---TX page_%02d: %02X %02X %02X %02X %02X %02X %02X %02X --err:%d]\n\r", \
ANT_PAGE_NEW - 127, Replace_Buff(ANT_message_payload_Wait_5), err_code
);//打印发送共享命令
}
else if (ANT_PAGE_NEW == 127 + 5)
{
err_code = sd_ant_broadcast_message_tx(p_profile->channel_number, 8, ANT_message_payload_Wait_6);//共享通道的内容转发广播通道
SEGGER_RTT_printf(0, "[channel3---TX page_%02d: %02X %02X %02X %02X %02X %02X %02X %02X --err:%d]\n\r", \
ANT_PAGE_NEW - 127, Replace_Buff(ANT_message_payload_Wait_6), err_code
);//打印发送共享命令
}
else if (ANT_PAGE_NEW == 127 + 6)
{
err_code = sd_ant_broadcast_message_tx(p_profile->channel_number, 8, ANT_message_payload_Wait_7);//共享通道的内容转发广播通道
SEGGER_RTT_printf(0, "[channel3---TX page_%02d: %02X %02X %02X %02X %02X %02X %02X %02X --err:%d]\n\r", \
ANT_PAGE_NEW - 127, Replace_Buff(ANT_message_payload_Wait_7), err_code
);//打印发送共享命令
}
else if (ANT_PAGE_NEW == 127 + 7)
{
err_code = sd_ant_broadcast_message_tx(p_profile->channel_number, 8, ANT_message_payload_Wait_8);//共享通道的内容转发广播通道
SEGGER_RTT_printf(0, "[channel3---TX page_%02d: %02X %02X %02X %02X %02X %02X %02X %02X --err:%d]\n\r", \
ANT_PAGE_NEW - 127, Replace_Buff(ANT_message_payload_Wait_8), err_code
);//打印发送共享命令
}
else if (ANT_PAGE_NEW == 127 + 8)
{
err_code = sd_ant_broadcast_message_tx(p_profile->channel_number, 8, ANT_message_payload_Wait_9);//共享通道的内容转发广播通道
SEGGER_RTT_printf(0, "[channel3---TX page_%02d: %02X %02X %02X %02X %02X %02X %02X %02X --err:%d]\n\r", \
ANT_PAGE_NEW - 127, Replace_Buff(ANT_message_payload_Wait_9), err_code
);//打印发送共享命令
}
else if (ANT_PAGE_NEW == 127 + 9)
{
err_code = sd_ant_broadcast_message_tx(p_profile->channel_number, 8, ANT_message_payload_Wait_10);//共享通道的内容转发广播通道
SEGGER_RTT_printf(0, "[channel3---TX page_%02d: %02X %02X %02X %02X %02X %02X %02X %02X --err:%d]\n\r", \
ANT_PAGE_NEW - 127, Replace_Buff(ANT_message_payload_Wait_10), err_code
);//打印发送共享命令
}
ANT_PAGE_NEW = 0;
}
APP_ERROR_CHECK(err_code);
}
/*********************************************
函数名:ant_message_send_Shared
功 能:用于设置ANT消息的有效负载并发送它的函数。(共享通道)
形 参:p_profile--指向配置文件实例的指针。
返回值:
备 注:
作 者:薛建强
时 间:2020/02/27
使 用:
**********************************************/
void ant_message_send_Shared(ant_channel_config_t *p_channel)
{
uint32_t err_code;
static uint8_t i = 0, a = 0; //记录发送次数
static uint8_t Flag = 1; //用于轮询请求 Page1和Page2
if (SystemInit_Type.ANT_SHARED_CHANNEL == 1 && SystemReg.ANT_SHARED_CHANNEL == 1)
{
/*共享通道需要交换字节0和字节1*/
if (ANT_Relay_New_Share_Page == 0)
{
if (a < 250 && ++a < 10)
{
return;
}
a = 0;
if (SystemReg.ANT_Networking_Number_Loop > SystemReg.ANT_Networking_Number)
{
SystemReg.ANT_Networking_Number_Loop = 2;
}
ANT_message_payload_Shared[0] = SystemReg.ANT_Networking_Number_Loop; //修改灯光索引轮询其他组网车灯
ANT_message_payload_Shared[6] = Flag; //其他页面
err_code = sd_ant_broadcast_message_tx(p_channel->channel_number, 8, ANT_message_payload_Shared);//发送共享命令
if (SystemReg.ANT_Networking_Number_Loop < 254)
{
SystemReg.ANT_Networking_Number_Loop++;
}
SEGGER_RTT_printf(0, "channel1---TX page_%02d: %02X %02X %02X %02X %02X %02X %02X %02X --err_code:%d\n\r", \
ANT_Relay_New_Share_Page, Replace_Buff(ANT_message_payload_Shared), err_code
);//打印发送共享命令
}
else//非70页
{
err_code = sd_ant_broadcast_message_tx(p_channel->channel_number, 8, ANT_message_payload_Shared_Wait);//发送共享命令
// SEGGER_RTT_printf(0, "channel1---TX page_%02d: %02X %02X %02X %02X %02X %02X %02X %02X --err_code:%d\n\r", \
// ANT_Relay_New_Share_Page,Replace_Buff(ANT_message_payload_Shared), err_code
// );//打印发送共享命令
SEGGER_RTT_printf(0, "channel1---TX page_%02d: %02X %02X %02X %02X %02X %02X %02X %02X --err_code:%d\n\r", \
ANT_Relay_New_Share_Page, Replace_Buff(ANT_message_payload_Shared_Wait), err_code
);//打印发送共享命令
if (ANT_Relay_New_Share_Page != 32)
{
ANT_Relay_New_Share_Page = 0;
}
}
APP_ERROR_CHECK(err_code);
if (ANT_message_payload_Shared_Wait[1] == ANT_Relay_New_Share_Page) //发送到共享通道的命令是否匹配
{
if (ANT_message_payload_Shared_Wait[1] == 32 && m_ant_BikeLight.page_1.Light_Index == 1)
{
i++;
SEGGER_RTT_printf(0, "%d ci off Share channel\r\n", i);
if (ANT_message_payload_Wait_2[0] == 0 && ANT_message_payload_Wait_2[1] == 0) //主机关闭,且没有副灯
{
i = 3;
}
if (i > 2)
{
i = 0;
if (ANT_message_payload_Shared_Wait[0] == 0 || ANT_message_payload_Shared_Wait[0] == m_ant_BikeLight.page_1.Light_Index)
{
ANT_Relay_New_Share_Page = 0; //复位共享通道当前页
if (SystemInit_Type.ANT_SHARED_CHANNEL != 0 || SystemReg.ANT_SHARED_CHANNEL != 0)
{
ant_BikeLight_Shared_close(ant_channel_Shared.channel_number);//关闭共享通道
SystemInit_Type.ANT_SHARED_CHANNEL = 0;
SystemReg.ANT_SHARED_CHANNEL = 0;
}
Delete_BikeLight_Light_Index();
SystemReg.ANT_Networking_Number = 2;
/*关机*/
System_ONOFF(1);//0--开机 1--关机
Light_State_ModeNum_Update();
SEGGER_RTT_printf(0, "4 ci off Share channel\r\n");
Delete_ANT_message_payload_Wait();//清空数组
}
if (SystemReg.Wait_Off_Own == 1) //是否关闭自身
{
SystemReg.Wait_Off_Own = 0;
ANT_message_payload_Shared_Wait[0] = m_ant_BikeLight.page_1.Light_Index;//主灯替换为自己的索引并转播
}
else//仅仅让副灯关机
{
ANT_Relay_New_Share_Page = 0; //复位共享通道当前页
Delete_ANT_message_payload_Wait();//清空数组
}
}
}
else
{
ANT_Relay_New_Share_Page = 0; //复位共享通道当前页
}
}
}
else if (SystemInit_Type.ANT_SHARED_CHANNEL == 1 && SystemReg.ANT_SHARED_CHANNEL == 2)
{
if (SystemReg.Burst_update_channel_1 == 1) //突发通道1发送Page1
{
SystemReg.Burst_update_channel_1 = 0;
memcpy(ANT_message_payload_Shared, &(m_ant_BikeLight.page_1), sizeof(ant_BikeLight_page1_data_t));//复制非自身内容至共享通道缓存区
ANT_Shared_Channel_sens_message_encode(ANT_message_payload_Shared, 1);//对该命令进行重组
uint32_t err_code;
err_code = ANT_Send_Message(BikeLight_Shared_CHANNEL_NUMBER, ANT_message_payload_Shared);
SEGGER_RTT_printf(0, "[channel1_Burst]---TX page_%02d: %02X %02X %02X %02X %02X %02X %02X %02X --err_code:%d\n\r", \
1, Replace_Buff(ANT_message_payload_Shared), err_code); //打印发送共享命令
}
else if (ANT_Relay_New_Share_Page != 0)
{
uint32_t err_code;
err_code = ANT_Send_Message(BikeLight_Shared_CHANNEL_NUMBER, ANT_message_payload_Shared_Wait);
SEGGER_RTT_printf(0, "[channel1_request]---TX page_%02d: %02X %02X %02X %02X %02X %02X %02X %02X --err_code:%d\n\r", \
ANT_Relay_New_Share_Page, Replace_Buff(ANT_message_payload_Shared_Wait), err_code); //打印发送共享命令
ANT_Relay_New_Share_Page = 0; //复位
}
}
}
/*********************************************
函数名:sens_message_encode
功 能:每次触发TX事件,都会调用该函数【广播通道编码】
形 参:p_profile 指向配置文件实例的指针。
p_message_payload 消息数据(8个字节)用于存放编码后的数据
返回值:
备 注:
作 者:薛建强
时 间:2020/03/02
使 用:
**********************************************/
static void sens_message_encode(ant_BikeLight_profile_t *p_profile, uint8_t *p_message_payload)
{
ant_BikeLight_message_layout_t *p_BikeLight_message_payload =
(ant_BikeLight_message_layout_t *)p_message_payload;
p_BikeLight_message_payload->page_number = next_page_number_get(p_profile);
// SEGGER_RTT_printf(0, "BikeLight TX Page number: %u\n\r", p_BikeLight_message_payload->page_number);
switch (p_BikeLight_message_payload->page_number)
{
case ANT_BikeLight_PAGE_1:
ant_BikeLight_page_1_encode(p_BikeLight_message_payload->page_payload, &(p_profile->page_1));
break;
case ANT_BikeLight_PAGE_2:
ant_BikeLight_page_2_encode(p_BikeLight_message_payload->page_payload, &(p_profile->page_2));
break;
// case ANT_BikeLight_PAGE_3:
// ant_BikeLight_page_3_encode(p_BikeLight_message_payload->page_payload, &(p_profile->page_3));
// break;
// case ANT_BikeLight_PAGE_4:
// ant_BikeLight_page_4_encode(p_BikeLight_message_payload->page_payload, &(p_profile->page_4));
// break;
// case ANT_BikeLight_PAGE_5:
// ant_BikeLight_page_5_encode(p_BikeLight_message_payload->page_payload, &(p_profile->page_5));
// break;
// case ANT_BikeLight_PAGE_6:
// ant_BikeLight_page_6_encode(p_BikeLight_message_payload->page_payload, &(p_profile->page_6));
// break;
// case ANT_BikeLight_PAGE_16:
// ant_BikeLight_page_16_encode(p_BikeLight_message_payload->page_payload, &(p_profile->page_16));
// break;
// case ANT_BikeLight_PAGE_17:
// ant_BikeLight_page_17_encode(p_BikeLight_message_payload->page_payload, &(p_profile->page_17));
// break;
case ANT_BikeLight_PAGE_18:
ant_BikeLight_page_18_encode(p_BikeLight_message_payload->page_payload, &(p_profile->page_18));
break;
case ANT_BikeLight_PAGE_19:
ant_BikeLight_page_19_encode(p_BikeLight_message_payload->page_payload, &(p_profile->page_19));
break;
case ANT_BikeLight_PAGE_32://断开连接
ant_BikeLight_page_32_encode(p_BikeLight_message_payload->page_payload, &(p_profile->page_32));
break;
case ANT_BikeLight_PAGE_33:
ant_BikeLight_page_33_encode(p_BikeLight_message_payload->page_payload, &(p_profile->page_33));
break;
case ANT_BikeLight_PAGE_34:
ant_BikeLight_page_34_encode(p_BikeLight_message_payload->page_payload, &(p_profile->page_34));
break;
case ANT_BikeLight_PAGE_70:
ant_BikeLight_page_70_encode(p_BikeLight_message_payload->page_payload, &(p_profile->page_70));
break;
case ANT_BikeLight_PAGE_80:
ant_BikeLight_page_80_encode(p_BikeLight_message_payload->page_payload, &(p_profile->page_80));
break;
case ANT_BikeLight_PAGE_81:
ant_BikeLight_page_81_encode(p_BikeLight_message_payload->page_payload, &(p_profile->page_81));
break;
default:
return;
}
p_profile->evt_handler(p_profile, (ant_BikeLight_evt_t)p_BikeLight_message_payload->page_number);
}
/*********************************************
函数名:next_page_number_get
功 能:用于获取要发送的下一个页码的函数.[广播通道]
形 参:p_profile 指向配置文件实例的指针。
返回值:下一个页码值
备 注:
作 者:薛建强
时 间:2020/03/02
使 用:
**********************************************/
static ant_BikeLight_page_t next_page_number_get(ant_BikeLight_profile_t *p_profile)
{
ant_BikeLight_sens_cb_t *p_BikeLight_cb = p_profile->_cb.p_sens_cb;
ant_BikeLight_page_t page_number;
static uint8_t Flag = 0;
if (ANT_PAGE_NEW == 18 || ANT_PAGE_NEW == 32 || ANT_PAGE_NEW == 33 || ANT_PAGE_NEW == 34 || ANT_PAGE_NEW == 70) //插入指定页
{
p_BikeLight_cb->ext_page_number = (ant_BikeLight_page_t)ANT_PAGE_NEW;
}
else
{
/****************只输出特定的数据页**************/
if (Flag == 0)
{
if (++ANT_PAGE_NEW > (sizeof(page_buff) / sizeof(uint8_t)) - 1)
{
ANT_PAGE_NEW = 0;
Flag = 1;
}
p_BikeLight_cb->ext_page_number = (ant_BikeLight_page_t)page_buff[ANT_PAGE_NEW];
}
else
{
if ((ANT_message_payload_Wait_2[0] != 0 || ANT_message_payload_Wait_2[1] != 0) && Flag == 1)
{
ANT_PAGE_NEW = 127 + 1;
Flag++;
p_BikeLight_cb->ext_page_number = (ant_BikeLight_page_t)ANT_PAGE_NEW;
}
else if ((ANT_message_payload_Wait_3[0] != 0 || ANT_message_payload_Wait_3[1] != 0) && Flag == 2)
{
ANT_PAGE_NEW = 127 + 2;
Flag++;
p_BikeLight_cb->ext_page_number = (ant_BikeLight_page_t)ANT_PAGE_NEW;
}
else if ((ANT_message_payload_Wait_4[0] != 0 || ANT_message_payload_Wait_4[1] != 0) && Flag == 3)
{
ANT_PAGE_NEW = 127 + 3;
Flag++;
p_BikeLight_cb->ext_page_number = (ant_BikeLight_page_t)ANT_PAGE_NEW;
}
else if ((ANT_message_payload_Wait_5[0] != 0 || ANT_message_payload_Wait_5[1] != 0) && Flag == 4)
{
ANT_PAGE_NEW = 127 + 4;
Flag++;
p_BikeLight_cb->ext_page_number = (ant_BikeLight_page_t)ANT_PAGE_NEW;
}
else if ((ANT_message_payload_Wait_6[0] != 0 || ANT_message_payload_Wait_6[1] != 0) && Flag == 5)
{
ANT_PAGE_NEW = 127 + 5;
Flag++;
p_BikeLight_cb->ext_page_number = (ant_BikeLight_page_t)ANT_PAGE_NEW;
}
else if ((ANT_message_payload_Wait_7[0] != 0 || ANT_message_payload_Wait_7[1] != 0) && Flag == 6)
{
ANT_PAGE_NEW = 127 + 6;
Flag++;
p_BikeLight_cb->ext_page_number = (ant_BikeLight_page_t)ANT_PAGE_NEW;
}
else if ((ANT_message_payload_Wait_8[0] != 0 || ANT_message_payload_Wait_8[1] != 0) && Flag == 7)
{
ANT_PAGE_NEW = 127 + 7;
Flag++;
p_BikeLight_cb->ext_page_number = (ant_BikeLight_page_t)ANT_PAGE_NEW;
}
else if ((ANT_message_payload_Wait_9[0] != 0 || ANT_message_payload_Wait_9[1] != 0) && Flag == 8)
{
ANT_PAGE_NEW = 127 + 8;
Flag++;
p_BikeLight_cb->ext_page_number = (ant_BikeLight_page_t)ANT_PAGE_NEW;
}
else if ((ANT_message_payload_Wait_10[0] != 0 || ANT_message_payload_Wait_10[1] != 0) && Flag == 9)
{
ANT_PAGE_NEW = 127 + 9;
Flag++;
p_BikeLight_cb->ext_page_number = (ant_BikeLight_page_t)ANT_PAGE_NEW;
}
else
{
ANT_PAGE_NEW = 0;
Flag = 0;
p_BikeLight_cb->ext_page_number = (ant_BikeLight_page_t)page_buff[ANT_PAGE_NEW];
}
}
}
page_number = p_BikeLight_cb->ext_page_number;
//SEGGER_RTT_printf(0, "page_number:%d --- ext_page_number:%d\r\n", page_number, p_BikeLight_cb->ext_page_number);
return page_number;
}
**
只要通道0一直循环发送P1/P2/P80/P81,ANT码表或其他设备就能搜索到。
**
上面忘记了重点:修改网络密钥。
全局搜索关键词:ANT_PLUS_NETWORK_KEY
这里必须填写ANT+密钥,否则码表无法搜索到此设备。
由于密钥是保密的,请自己去ANT+官网注册会员,获取密钥