You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
1.9 KiB
78 lines
1.9 KiB
1 year ago
|
#ifndef TPC_lora_H
|
||
|
#define TPC_lora_H
|
||
|
|
||
|
#include "tpc_x.h"
|
||
|
|
||
|
#define D_TS_lrdlora_data_len 12
|
||
|
|
||
|
#define D_TS_lrdlora_data_len2 12
|
||
|
|
||
|
typedef struct
|
||
|
{//8byte
|
||
|
vU8 filter; ///0x68
|
||
|
vU16 len; //长度
|
||
|
vU8 CMD:7;
|
||
|
vU8 DIR:1;
|
||
|
|
||
|
vU8 buf[D_TS_lrdlora_data_len+1];//buffer
|
||
|
vU8 ocr;
|
||
|
////6、校验和:从长度到数据字段的校验码,使用累加和进行计算,即各字节相加求和取最低字节。
|
||
|
|
||
|
vU8 filtert; ///0x16
|
||
|
vU8 buf2[44];
|
||
|
}TS_pp_lrdlora_;///协议处理函数 pp protocal package 协包议
|
||
|
|
||
|
extern TS_pp_lrdlora_ ts_lrdlora_send, ts_lrdlora_rec;
|
||
|
#define D_lrdlora_filter 0x68
|
||
|
#define D_lrdlora_filtertail 0x16
|
||
|
|
||
|
typedef struct
|
||
|
{
|
||
|
U8 reg;
|
||
|
vU16 len;
|
||
|
vU16 num; //接收到的数据的计数, 随着数据接收而变化注意数据长度的范围
|
||
|
U8 head; //接收标志头标志
|
||
|
U8 ok; //接收协议ok标志
|
||
|
U8 debugok;
|
||
|
U8 ocr;
|
||
|
U8 a;
|
||
|
|
||
|
U8 *sp;
|
||
|
TS_pp_lrdlora_ *tp;
|
||
|
}ts_s2b_lrdlora_;////协议处理变量
|
||
|
extern ts_s2b_lrdlora_ ts_s2b_lrdlora;
|
||
|
|
||
|
#if 0
|
||
|
send()
|
||
|
|
||
|
{TS_lrdlora_send.filter = 0x68;
|
||
|
send(TS_lrdlora_send.filter)
|
||
|
send(TS_lrdlora_send.len)
|
||
|
send(TS_lrdlora_send.DIR|TS_lrdlora_send.CMD)
|
||
|
p=TS_lrdlora_send.buf;
|
||
|
for(len)
|
||
|
{
|
||
|
send(*p);
|
||
|
p++
|
||
|
cor ;
|
||
|
|
||
|
}
|
||
|
|
||
|
send(TS_lrdlora_send.ocr)
|
||
|
send(TS_lrdlora_send.filtert)
|
||
|
|
||
|
}
|
||
|
#endif
|
||
|
////1、帧头: 帧起始标志,固定值为 0x68。
|
||
|
////2、长度: 帧头到帧尾的总字节长度。
|
||
|
////3、DIR: 指示帧传送方向,0:模组->用户。1:用户->模组。
|
||
|
////4、CMD: 命令字,指示不同的帧类型。
|
||
|
////5、数据: 可变长的数据部分,不同命令的数据字段内容不同,参照各条命令中的定义。
|
||
|
////6、校验和:从长度到数据字段的校验码,使用累加和进行计算,即各字节相加求和取最低字节。
|
||
|
////7、帧尾: 帧结束标志,固定值为 0x16。
|
||
|
|
||
|
extern void L1_s2b_lora(ts_s2b_lrdlora_ *p);
|
||
|
extern void L1_s2b_lora_init(void);
|
||
|
|
||
|
#endif
|