11.12:添加信号量同步机制;完成网关节点对环境节点的执行器控制功能。
This commit is contained in:
@@ -84,7 +84,112 @@ void vLoRaToGateExeIdPkt(uint8_t ucExeId)
|
||||
}
|
||||
}
|
||||
|
||||
void vLoRaReceivedMesg(void)
|
||||
eLoRaMsgRecStatus xLoRaMessageReceived(uint8_t *pucData)
|
||||
{
|
||||
switch (*pucData)
|
||||
{
|
||||
case 0xD1:
|
||||
/* code */
|
||||
return statusNode1;
|
||||
|
||||
case 0xD2:
|
||||
return statusNode2;
|
||||
|
||||
case 0xFA:
|
||||
return statusExeLed;
|
||||
|
||||
case 0xFB:
|
||||
return statusExeFan;
|
||||
|
||||
case 0xFC:
|
||||
return statusExeHumidifier;
|
||||
|
||||
case 0xFD:
|
||||
return statusExeBuzzer;
|
||||
|
||||
case 0xFE:
|
||||
return statusExeServo;
|
||||
|
||||
case 0x01:
|
||||
return statusExeOn;
|
||||
|
||||
case 0x00:
|
||||
return statusExeOff;
|
||||
|
||||
default:
|
||||
return statusNode1;
|
||||
}
|
||||
}
|
||||
|
||||
eLoRaMsgRecStatus xLoRaMsgProcess(uint8_t ucDataRecNodeId, uint8_t ucDataRecExeId, uint8_t ucDataRecExeSta)
|
||||
{
|
||||
switch (xLoRaMessageReceived(&ucDataRecNodeId))
|
||||
{
|
||||
case statusNode1:
|
||||
/* code */
|
||||
while (xLoRaMessageReceived(&ucDataRecExeSta) == statusExeOn)
|
||||
{
|
||||
/* code */
|
||||
if (xLoRaMessageReceived(&ucDataRecExeId) == statusExeLed)
|
||||
{
|
||||
/* code */
|
||||
return statusLedOn;
|
||||
} else if (xLoRaMessageReceived(&ucDataRecExeId) == statusExeFan)
|
||||
{
|
||||
/* code */
|
||||
return statusFanOn;
|
||||
} else if (xLoRaMessageReceived(&ucDataRecExeId) == statusExeHumidifier)
|
||||
{
|
||||
/* code */
|
||||
return statusHumidifierOn;
|
||||
}
|
||||
}
|
||||
while (xLoRaMessageReceived(&ucDataRecExeSta) == statusExeOff)
|
||||
{
|
||||
/* code */
|
||||
if (xLoRaMessageReceived(&ucDataRecExeId) == statusExeLed)
|
||||
{
|
||||
/* code */
|
||||
return statusLedOff;
|
||||
} else if (xLoRaMessageReceived(&ucDataRecExeId) == statusExeFan)
|
||||
{
|
||||
/* code */
|
||||
return statusFanOff;
|
||||
} else if (xLoRaMessageReceived(&ucDataRecExeId) == statusExeHumidifier)
|
||||
{
|
||||
/* code */
|
||||
return statusHumidifierOff;
|
||||
}
|
||||
}
|
||||
|
||||
case statusNode2:
|
||||
while (xLoRaMessageReceived(&ucDataRecExeSta) == statusExeOn)
|
||||
{
|
||||
/* code */
|
||||
if (xLoRaMessageReceived(&ucDataRecExeId) == statusExeBuzzer)
|
||||
{
|
||||
/* code */
|
||||
return statusBuzzerOn;
|
||||
} else if (xLoRaMessageReceived(&ucDataRecExeId) == statusExeServo)
|
||||
{
|
||||
/* code */
|
||||
return statusServoOn;
|
||||
}
|
||||
}
|
||||
while (xLoRaMessageReceived(&ucDataRecExeSta) == statusExeOff)
|
||||
{
|
||||
/* code */
|
||||
if (xLoRaMessageReceived(&ucDataRecExeId) == statusExeBuzzer)
|
||||
{
|
||||
/* code */
|
||||
return statusBuzzerOff;
|
||||
} else if (xLoRaMessageReceived(&ucDataRecExeId) == statusExeServo)
|
||||
{
|
||||
/* code */
|
||||
return statusServoOff;
|
||||
}
|
||||
}
|
||||
default:
|
||||
return statusNode1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "USART3.h"
|
||||
|
||||
#define LORA_MODE
|
||||
// #define LORA_MODE
|
||||
|
||||
/* LoRa<52>ľ<EFBFBD>̬<EFBFBD><CCAC><EFBFBD><EFBFBD> */
|
||||
#define LORA_MODE_INIT 1
|
||||
@@ -36,6 +36,29 @@
|
||||
|
||||
/* LoRa<52><61>ֲ<EFBFBD><D6B2> */
|
||||
|
||||
typedef enum {
|
||||
statusGatawayNode = 1,
|
||||
statusNode1,
|
||||
statusNode2,
|
||||
statusExeLed,
|
||||
statusExeFan,
|
||||
statusExeHumidifier,
|
||||
statusExeBuzzer,
|
||||
statusExeServo,
|
||||
statusExeOn,
|
||||
statusExeOff,
|
||||
statusLedOn,
|
||||
statusLedOff,
|
||||
statusFanOn,
|
||||
statusFanOff,
|
||||
statusHumidifierOn,
|
||||
statusHumidifierOff,
|
||||
statusBuzzerOn,
|
||||
statusBuzzerOff,
|
||||
statusServoOn,
|
||||
statusServoOff
|
||||
}eLoRaMsgRecStatus;
|
||||
|
||||
typedef struct {
|
||||
uint8_t ucLoRaGateAddrHigh;
|
||||
uint8_t ucLoRaGateAddrLow;
|
||||
@@ -129,6 +152,8 @@ void vLoRaConnectionPkt(uint8_t ucNodeId);
|
||||
void vLoRaToGateIdPkt(uint8_t ucNodeId);
|
||||
void vLoRaToGateSenIdPkt(uint8_t ucSensorId);
|
||||
void vLoRaToGateExeIdPkt(uint8_t ucExecutorId);
|
||||
void vLoRaReceivedMesg(void);
|
||||
eLoRaMsgRecStatus xLoRaMessageReceived(uint8_t *pucData);
|
||||
eLoRaMsgRecStatus xLoRaMsgProcess(uint8_t ucDataRecNodeId, uint8_t ucDataRecExeId, uint8_t ucDataRecExeSta);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user