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.
124 lines
2.7 KiB
124 lines
2.7 KiB
#include "tpc_lora.h"
|
|
#include "c_lib.h"
|
|
#include "debug_drv.h"
|
|
#include "bsp_lora_jx.h"
|
|
#include "msp_UART2.h"
|
|
#include "bsp_lora.h"
|
|
#include "max30102.h"
|
|
|
|
///#include "app_config.h"
|
|
|
|
ts_s2b_lrdlora_ ts_s2b_lrdlora_send;////协议处理变量
|
|
|
|
Lora_param lora_param;
|
|
|
|
vU8 send[12];
|
|
vU8 Oxygen_saturation, body_temperature, heart_rate,sphygmus;
|
|
|
|
|
|
void L3_lora_analysis_init(void) //给ts_lrdlora_send赋值初始化
|
|
{
|
|
ts_s2b_lrdlora_send.ok = 0;
|
|
ts_s2b_lrdlora_send.debugok = 0;
|
|
ts_s2b_lrdlora_send.head = 0;
|
|
ts_s2b_lrdlora_send.len = 0;
|
|
ts_s2b_lrdlora_send.num = 0;
|
|
ts_s2b_lrdlora_send.sp = (U8 *)&ts_lrdlora_send;
|
|
ts_s2b_lrdlora_send.tp = &ts_lrdlora_send;
|
|
}
|
|
|
|
//需要传入的数据准备好 ,作为此函数的输入参数
|
|
void L3_lora_send_pkg(TS_pp_lrdlora_ *p, U8 *buf,U8 blen)
|
|
{ //需要把buf长度传进来 blen 参数还需要buf
|
|
int i;
|
|
vU16 ocr = 0;
|
|
p->filter = 0x68;
|
|
p->len = 0x000E;
|
|
p->CMD = 0x05;
|
|
p->DIR = 0x01;
|
|
for(i=0;i<blen;i++)
|
|
{
|
|
p->buf[i] = *(buf+i);
|
|
}
|
|
|
|
ocr = Fun_SC_Check(&p->len,11);
|
|
p->ocr = (vU8)ocr;
|
|
p->filtert = 0x16;
|
|
p->buf[blen] = p->ocr;
|
|
p->buf[blen+1] = p->filtert;
|
|
}
|
|
////u16out_10a
|
|
|
|
void L3_lora_send(void)
|
|
{
|
|
D_lora_wakeup();
|
|
lora_param.Oxygen_saturation = (int)ts_max30102.SPO2_out;
|
|
lora_param.body_temperature = (int)ts_mx95.u16out_10o;
|
|
lora_param.heart_rate = (int)ts_max30102.hr_out2;
|
|
lora_param.sphygmus = (int)ts_max30102.hr_out;
|
|
L3_lora_send_pkg(&ts_lrdlora_send,&lora_param,8);
|
|
L1_uart2_Array((U8 *)&ts_lrdlora_send, ts_lrdlora_send.len);
|
|
L1_uartD_uchexArray((U8 *)&ts_lrdlora_send, ts_lrdlora_send.len);
|
|
}
|
|
/*************/
|
|
|
|
|
|
U8 Fun_SC_Check(U8 *p1, unsigned short int len)//累加和校验
|
|
{
|
|
U8 sum = 0;
|
|
for(;len > 0; len--)
|
|
{
|
|
sum += *p1++;
|
|
}
|
|
|
|
return sum;
|
|
}
|
|
|
|
|
|
|
|
|
|
//当收到 68 00 0A 03 66 77 77 66 C7 16 指令后将传感器参数发送出去
|
|
|
|
/*(d->sp[0] == 0x68)&&(d->sp[1] == 0x00)&&(d->sp[2] == 0x0A)&&(d->sp[3] == 0x03)&&(d->sp[4] == 0x66)
|
|
&&(d->sp[5] == 0x77)&&(d->sp[6] == 0x77)&&(d->sp[7] == 0x66)&&(d->sp[8] == 0x48)&&(d->sp[9] == 0x16)*/
|
|
|
|
//通过变量ts_lrdlora_send
|
|
|
|
|
|
/*
|
|
void L3_lora_analysis(ts_s2b_lrdlora_ *p, ts_s2b_lrdlora_ *d, U8 a, U8 b, U8 h)
|
|
{
|
|
if(d->sp[0] == 0x68)
|
|
{
|
|
if((d->[1] == 0x00)&&(d->[2] == 0x0A))
|
|
{
|
|
}
|
|
}
|
|
if()
|
|
{
|
|
U8 num;
|
|
vU16 ocr = 0;
|
|
p->sp[0] = 0x68;
|
|
p->sp[1] = 0x00;
|
|
p->sp[2] = 0x09;
|
|
p->sp[3] = 0x84;
|
|
p->sp[4] = a;
|
|
p->sp[5] = b;
|
|
p->sp[6] = h;
|
|
for(num = 1;num <= 6;num++)
|
|
{
|
|
ocr = ocr + p->sp[num];
|
|
}
|
|
ocr = D_us2uc_L(ocr);
|
|
|
|
p->tp->ocr = ocr;
|
|
p->tp->filtert = 0x16;
|
|
ts_s2b_lrdlora_send.ok = 1;
|
|
ts_s2b_lrdlora_send.len = 9;
|
|
}
|
|
else
|
|
{
|
|
L3_lora_analysis_init();
|
|
}
|
|
}
|
|
*/
|
|
|