mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-18 00:45:55 +08:00
配网部分
This commit is contained in:
@@ -1,40 +1,40 @@
|
||||
#include "uart1_receive.h"
|
||||
|
||||
void BSP_UART1ReceiveInfor(void)
|
||||
{
|
||||
if(UART1ReadFlag&0x8000)
|
||||
{
|
||||
UART1ReadFlag = 0;
|
||||
memset((void *)UART1ReadBuf,0,sizeof(UART1ReadBuf));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "uart1_receive.h"
|
||||
|
||||
void BSP_UART1ReceiveInfor(void)
|
||||
{
|
||||
if(UART1ReadFlag&0x8000)
|
||||
{
|
||||
UART1ReadFlag = 0;
|
||||
memset((void *)UART1ReadBuf,0,sizeof(UART1ReadBuf));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
#ifndef _UART1_RECEIVE_H_
|
||||
#define _UART1_RECEIVE_H_
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
#include "bsp_uart1.h"
|
||||
|
||||
#include "bsp_timer3.h"
|
||||
|
||||
#include "bsp_port.h"
|
||||
|
||||
void Sys_Usart1RecMessage(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _UART1_RECEIVE_H_
|
||||
#define _UART1_RECEIVE_H_
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
#include "bsp_uart1.h"
|
||||
|
||||
#include "bsp_timer3.h"
|
||||
|
||||
#include "bsp_port.h"
|
||||
|
||||
void Sys_Usart1RecMessage(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,81 +1,81 @@
|
||||
#include "uart2_receive.h"
|
||||
|
||||
uint8_t txLen = 0;
|
||||
uint8_t txBuf[20] = {0};
|
||||
|
||||
static uint8_t Server_CheckSum(uint8_t * buf)
|
||||
{
|
||||
uint8_t len = 0,i = 0;
|
||||
uint16_t CheckSum = 0;
|
||||
len = buf[2] - 2;
|
||||
|
||||
for( i = 0; i < len; i++)
|
||||
CheckSum += buf[i+2];
|
||||
|
||||
return (uint8_t)CheckSum;
|
||||
}
|
||||
|
||||
void Server_Protocol(void)
|
||||
{
|
||||
if(UART2ReadFlag&0x8000)
|
||||
{
|
||||
if(UART2ReadBuf[0]==0xAA && UART2ReadBuf[1]==0xBB)
|
||||
{
|
||||
// 校验和
|
||||
switch(UART2ReadBuf[3])
|
||||
{
|
||||
case 0x90 : { } break; // 返回配网结果
|
||||
case 0x91 : { DevParam.Server = UART2ReadBuf[8]; } break; // 返回网络状态
|
||||
|
||||
case 0x94 : { } break; // 返回上报属性结果
|
||||
case 0x95 : { } break; // 返回上报事件结果
|
||||
|
||||
case 0x96 : { } break; // 下发控制
|
||||
case 0x97 : { } break; // 下发获取状态
|
||||
default : break;
|
||||
}
|
||||
}
|
||||
UART2ReadFlag = 0;
|
||||
memset((void *)UART2ReadBuf,0,sizeof(UART2ReadBuf));
|
||||
}
|
||||
|
||||
// 间隔2秒上报设备状态
|
||||
if( (DevParam.Server==2) && (DevParam.ServerUpdateTime>=2000) )
|
||||
{
|
||||
txLen = 0;
|
||||
txBuf[txLen++] = 0xAA; txBuf[txLen++] = 0xBB;
|
||||
txBuf[txLen++] = 0x00; // 数据长度,帧头后有效数据长度
|
||||
txBuf[txLen++] = 0x84; // 上报属性
|
||||
txBuf[txLen++] = 0x01; txBuf[txLen++] = 0x02; txBuf[txLen++] = 0x03; txBuf[txLen++] = 0x04; // 客户端ID
|
||||
|
||||
/////////参数////////
|
||||
txBuf[txLen++] = 0x01; txBuf[txLen++] = 0x01;
|
||||
txBuf[txLen++] = 0x01; txBuf[txLen++] = 0x01;
|
||||
///////////////////////
|
||||
|
||||
txBuf[txLen++] = 0x00; // 校验和
|
||||
txBuf[txLen++] = 0x5F; // 帧尾
|
||||
|
||||
txBuf[2] = txLen-2; // 数据长度
|
||||
txBuf[txLen-2] = Server_CheckSum(txBuf);// 校验和
|
||||
|
||||
// 发送
|
||||
ESP8266_SendData( txBuf, txLen);
|
||||
|
||||
DevParam.ServerUpdateTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "uart2_receive.h"
|
||||
|
||||
uint8_t txLen = 0;
|
||||
uint8_t txBuf[20] = {0};
|
||||
|
||||
static uint8_t Server_CheckSum(uint8_t * buf)
|
||||
{
|
||||
uint8_t len = 0,i = 0;
|
||||
uint16_t CheckSum = 0;
|
||||
len = buf[2] - 2;
|
||||
|
||||
for( i = 0; i < len; i++)
|
||||
CheckSum += buf[i+2];
|
||||
|
||||
return (uint8_t)CheckSum;
|
||||
}
|
||||
|
||||
void Server_Protocol(void)
|
||||
{
|
||||
if(UART2ReadFlag&0x8000)
|
||||
{
|
||||
if(UART2ReadBuf[0]==0xAA && UART2ReadBuf[1]==0xBB)
|
||||
{
|
||||
// 校验和
|
||||
switch(UART2ReadBuf[3])
|
||||
{
|
||||
case 0x90 : { } break; // 返回配网结果
|
||||
case 0x91 : { DevParam.Server = UART2ReadBuf[8]; } break; // 返回网络状态
|
||||
|
||||
case 0x94 : { } break; // 返回上报属性结果
|
||||
case 0x95 : { } break; // 返回上报事件结果
|
||||
|
||||
case 0x96 : { } break; // 下发控制
|
||||
case 0x97 : { } break; // 下发获取状态
|
||||
default : break;
|
||||
}
|
||||
}
|
||||
UART2ReadFlag = 0;
|
||||
memset((void *)UART2ReadBuf,0,sizeof(UART2ReadBuf));
|
||||
}
|
||||
|
||||
// 间隔2秒上报设备状态
|
||||
if( (DevParam.Server==2) && (DevParam.ServerUpdateTime>=2000) )
|
||||
{
|
||||
txLen = 0;
|
||||
txBuf[txLen++] = 0xAA; txBuf[txLen++] = 0xBB;
|
||||
txBuf[txLen++] = 0x00; // 数据长度,帧头后有效数据长度
|
||||
txBuf[txLen++] = 0x84; // 上报属性
|
||||
txBuf[txLen++] = 0x01; txBuf[txLen++] = 0x02; txBuf[txLen++] = 0x03; txBuf[txLen++] = 0x04; // 客户端ID
|
||||
|
||||
/////////参数////////
|
||||
txBuf[txLen++] = 0x01; txBuf[txLen++] = 0x01;
|
||||
txBuf[txLen++] = 0x01; txBuf[txLen++] = 0x01;
|
||||
///////////////////////
|
||||
|
||||
txBuf[txLen++] = 0x00; // 校验和
|
||||
txBuf[txLen++] = 0x5F; // 帧尾
|
||||
|
||||
txBuf[2] = txLen-2; // 数据长度
|
||||
txBuf[txLen-2] = Server_CheckSum(txBuf);// 校验和
|
||||
|
||||
// 发送
|
||||
ESP8266_SendData( txBuf, txLen);
|
||||
|
||||
DevParam.ServerUpdateTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
#ifndef _UART2_RECEIVE_H_
|
||||
#define _UART2_RECEIVE_H_
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
#include "bsp_timer3.h"
|
||||
|
||||
#include "bsp_uart2.h"
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _UART2_RECEIVE_H_
|
||||
#define _UART2_RECEIVE_H_
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
#include "bsp_timer3.h"
|
||||
|
||||
#include "bsp_uart2.h"
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
#include "uart3_receive.h"
|
||||
|
||||
void BSP_UART3ReceiveInfor(void)
|
||||
{
|
||||
// Sys_Usart3RecComplete(System_1ms);
|
||||
// if(Usart3ReadFlag&0x8000)
|
||||
// {
|
||||
// Sys_Usart3SendStr("uart3:");
|
||||
// Sys_Usart3SendData(Usart3ReadBuf,(Usart3ReadFlag&(~(1<<15))));
|
||||
//
|
||||
// Usart3ReadFlag = 0;
|
||||
// memset((void *)Usart3ReadBuf,0,sizeof(Usart3ReadBuf));
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "uart3_receive.h"
|
||||
|
||||
void BSP_UART3ReceiveInfor(void)
|
||||
{
|
||||
// Sys_Usart3RecComplete(System_1ms);
|
||||
// if(Usart3ReadFlag&0x8000)
|
||||
// {
|
||||
// Sys_Usart3SendStr("uart3:");
|
||||
// Sys_Usart3SendData(Usart3ReadBuf,(Usart3ReadFlag&(~(1<<15))));
|
||||
//
|
||||
// Usart3ReadFlag = 0;
|
||||
// memset((void *)Usart3ReadBuf,0,sizeof(Usart3ReadBuf));
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
#ifndef _UART3_RECEIVE_H_
|
||||
#define _UART3_RECEIVE_H_
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
#include "bsp_timer3.h"
|
||||
|
||||
#include "bsp_uart3.h"
|
||||
|
||||
|
||||
void BSP_UART3ReceiveInfor(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _UART3_RECEIVE_H_
|
||||
#define _UART3_RECEIVE_H_
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
#include "bsp_timer3.h"
|
||||
|
||||
#include "bsp_uart3.h"
|
||||
|
||||
|
||||
void BSP_UART3ReceiveInfor(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user