41 lines
1.7 KiB
C
41 lines
1.7 KiB
C
/****************************************************************************
|
|
|
|
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
|
|
|
|
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
|
|
be copied by any method or incorporated into another program without
|
|
the express written consent of Aerospace C.Power. This Information or any portion
|
|
thereof remains the property of Aerospace C.Power. The Information contained herein
|
|
is believed to be accurate and Aerospace C.Power assumes no responsibility or
|
|
liability for its use in any way and conveys no license or title under
|
|
any patent or copyright and makes no representation or warranty that this
|
|
Information is free from patent or copyright infringement.
|
|
|
|
****************************************************************************/
|
|
#include "iot_crc_api.h"
|
|
#include "app_1901.h"
|
|
|
|
#if SUPPORT_IEEE_1901
|
|
|
|
/* to package_1901_frame to_plc a proto 1901 data frame */
|
|
void package_1901_frame(uint8_t *msdu_ptr,iot_pkt_t *pkt)
|
|
{
|
|
uint16_t crc;
|
|
app_plc_frame_data_hi *head_hi;
|
|
app_custom_data *app_data = (app_custom_data *)iot_pkt_data(pkt);
|
|
uint16_t len_hi = iot_pkt_data_len(pkt) - sizeof(app_custom_data);
|
|
|
|
head_hi = (app_plc_frame_data_hi *)msdu_ptr;
|
|
head_hi->port_num = HI_DMS_CHL_MAC_PORT_APP;
|
|
head_hi->id = app_data->id;
|
|
head_hi->ctrl = HI_DMS_CHL_TX_CTRL_FORCE;
|
|
crc = iot_getcrc16(iot_pkt_data(pkt) + sizeof(app_custom_data),
|
|
len_hi, IOT_CRC16_TYPE_XMODEM);
|
|
head_hi->crc_8_low = (crc >> 8 & 0xFF);
|
|
head_hi->crc_8_high = (crc & 0xFF);
|
|
head_hi->data_length = len_hi;
|
|
os_mem_cpy(head_hi->data, (uint8_t *)(app_data + 1), len_hi);
|
|
return;
|
|
}
|
|
#endif
|