ANT+控制器可请求此页面(如第5.3节所述)确定有关ANT+自行车灯的附加信息。这是ANT+自行车灯的可选页面。如果不支持此页,则应忽略对此页的请求。当ANT+控制器请求时,数据页19从ANT+自行车灯广播。此信息中的所有字段应按表7-30所述进行设置。

7.14.1 电池百分比
该字段用于以百分比表示剩余电池电量。如果不支持此字段,则应将其设置为无效,即0xFF。
/* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved.
*
* The information contained herein is property of Nordic Semiconductor ASA.
* Terms and conditions of usage are described in detail in NORDIC
* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
*
* Licensees are granted free, non-transferable use of the information. NO
* WARRANTY of ANY KIND is provided. This heading must NOT be removed from
* the file.
*
*/
#include "ant_BikeLight_page_19.h"
#include "ant_BikeLight_utils.h"
#include "ant_BikeLight_page_logger.h"
#include "SEGGER_RTT.h"
#include "SEGGER_RTT_Conf.h"
#include "main.h"
/**@brief BikeLight 补充信息 (0x13) 第19页数据布局结构. 如果不支持此页面,则对它的请求应被忽略 */
typedef struct
{
uint8_t Light_Index; //灯光索引 0-63
uint8_t Sublight_Index : 3; //子灯索引 0-4
uint8_t Reserved : 5; //保留
uint8_t Reserved1[4]; //保留
uint8_t Battery_percentage; //电池百分比 单位:1% 范围:[0,100]
} ant_BikeLight_page19_data_layout_t;
static void page19_data_log(ant_BikeLight_page19_data_t const *p_page_data)
{
// SEGGER_RTT_printf(0, "Light_Index: %d\r\n", (uint8_t)p_page_data->Light_Index);
}
void ant_BikeLight_page_19_encode(uint8_t *p_page_buffer,
ant_BikeLight_page19_data_t const *p_page_data)
{
ant_BikeLight_page19_data_layout_t *p_outcoming_data = (ant_BikeLight_page19_data_layout_t *)p_page_buffer;
memset(p_page_buffer, 0, sizeof(ant_BikeLight_page19_data_layout_t));
p_outcoming_data->Light_Index = p_page_data->Light_Index;
p_outcoming_data->Battery_percentage = p_page_data->Battery_percentage;
// page19_data_log(p_page_data);
}
void ant_BikeLight_page_19_decode(uint8_t const *p_page_buffer,
ant_BikeLight_page19_data_t *p_page_data)
{
// ant_BikeLight_page19_data_layout_t const *p_incoming_data =
// (ant_BikeLight_page19_data_layout_t *)p_page_buffer;
// p_page_data->Light_Index = p_incoming_data->Light_Index;
page19_data_log(p_page_data);
}
/* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved.
*
* The information contained herein is property of Nordic Semiconductor ASA.
* Terms and conditions of usage are described in detail in NORDIC
* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
*
* Licensees are granted free, non-transferable use of the information. NO
* WARRANTY of ANY KIND is provided. This heading must NOT be removed from
* the file.
*
*/
#ifndef ANT_BIKELIGHT_PAGE_19_H__
#define ANT_BIKELIGHT_PAGE_19_H__
#include <stdint.h>
typedef struct
{
uint8_t Light_Index; //灯光索引 0-63
uint8_t Sublight_Index : 3; //子灯索引 0-4
uint8_t Reserved : 5; //保留
uint8_t Reserved1[4]; //保留
uint8_t Battery_percentage; //电池百分比 单位:1% 范围:[0,100]
} ant_BikeLight_page19_data_t;
#define DEFAULT_ANT_BikeLight_PAGE19() \
(ant_BikeLight_page19_data_t) \
{ \
.Light_Index = 0, \
.Sublight_Index = 0, \
.Battery_percentage = 100, \
}
void ant_BikeLight_page_19_encode(uint8_t *p_page_buffer,
ant_BikeLight_page19_data_t const *p_page_data);
void ant_BikeLight_page_19_decode(uint8_t const *p_page_buffer,
ant_BikeLight_page19_data_t *p_page_data);
#endif // ANT_BIKELIGHT_PAGE_19_H__
/** @} */
浙公网安备 33010602011771号