通用数据页80传输制造商的ID,型号和硬件版本。
注意,该数据页不得在共享通道上使用。当此数据页在广播频道上发送时,应始终描述发送该页的ANT+自行车灯。包含灯光索引字段的数据页16(0x10)应在共享通道上使用,并且主灯应使用它来描述辅助灯的制造商信息。
有关此页面的详细信息,请参考ANT+ Common Pages文档。
/* 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_80.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 制造商标识 (0x50) 第80页数据布局结构. */
typedef struct
{
uint8_t reserved[2]; //未使用,填充0xFF
uint8_t hw_revision; //硬件版本
uint8_t manufacturer_id[2]; //制造商id
uint8_t model_number[2]; //产品型号
} ant_BikeLight_page80_data_layout_t;
static void page80_data_log(ant_BikeLight_page80_data_t const *p_page_data)
{
// SEGGER_RTT_printf(0, "hw revision: %u\n\r", p_page_data->hw_revision);
// SEGGER_RTT_printf(0, "manufacturer id: %u\n\r", p_page_data->manufacturer_id);
// SEGGER_RTT_printf(0, "model number: %u\n\r", p_page_data->model_number);
}
void ant_BikeLight_page_80_encode(uint8_t *p_page_buffer,
ant_BikeLight_page80_data_t const *p_page_data)
{
ant_BikeLight_page80_data_layout_t *p_outcoming_data = (ant_BikeLight_page80_data_layout_t *)p_page_buffer;
memset(p_page_buffer, 0xFF, sizeof(ant_BikeLight_page80_data_layout_t));
p_outcoming_data->hw_revision = p_page_data->hw_revision;
UNUSED_PARAMETER(uint16_encode(p_page_data->manufacturer_id,
p_outcoming_data->manufacturer_id));
UNUSED_PARAMETER(uint16_encode(p_page_data->model_number, p_outcoming_data->model_number));
page80_data_log(p_page_data);
}
void ant_BikeLight_page_80_decode(uint8_t const *p_page_buffer,
ant_BikeLight_page80_data_t *p_page_data)
{
ant_BikeLight_page80_data_layout_t const *p_incoming_data =
(ant_BikeLight_page80_data_layout_t *)p_page_buffer;
p_page_data->hw_revision = p_incoming_data->hw_revision;
p_page_data->manufacturer_id = uint16_decode(p_incoming_data->manufacturer_id);
p_page_data->model_number = uint16_decode(p_incoming_data->model_number);
m_ant_BikeLight.page_1.Last_Sequence_Number = 80;
page80_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_80_H__
#define ANT_BIKELIGHT_PAGE_80_H__
#include <stdint.h>
typedef struct
{
uint8_t hw_revision; //硬件版本。
uint16_t manufacturer_id; //制造商ID。
uint16_t model_number; //型号。
} ant_BikeLight_page80_data_t;
#define DEFAULT_ANT_BikeLight_PAGE80() \
(ant_BikeLight_page80_data_t) \
{ \
.hw_revision = 0x00, \
.manufacturer_id = UINT8_MAX, \
.model_number = 0x00, \
}
/**@brief Initialize page 80.
*/
#define ANT_BikeLight_page80(hw_rev, man_id, mod_num) \
(ant_BikeLight_page80_data_t) \
{ \
.hw_revision = (hw_rev), \
.manufacturer_id = (man_id), \
.model_number = (mod_num), \
}
void ant_BikeLight_page_80_encode(uint8_t *p_page_buffer,
ant_BikeLight_page80_data_t const *p_page_data);
void ant_BikeLight_page_80_decode(uint8_t const *p_page_buffer,
ant_BikeLight_page80_data_t *p_page_data);
#endif // ANT_BIKELIGHT_PAGE_80_H__
/** @} */