mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
гейт
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
#include "Global.h"
|
||||
#ifdef MYSENSORS
|
||||
#define MY_DEBUG
|
||||
#define MY_RADIO_RF24
|
||||
#define MY_RF24_PA_LEVEL RF24_PA_HIGH // RF24_PA_MIN, RF24_PA_LOW, RF24_PA_HIGH, RF24_PA_MAX
|
||||
//#define MY_ENCRYPTION_SIMPLE_PASSWD "XpenBam"
|
||||
//#define MY_RF24_DATARATE RF24_2MBPS
|
||||
#define MY_GATEWAY_SERIAL
|
||||
#include "MySensors.h"
|
||||
extern void receive(const MyMessage &message);
|
||||
extern String parseToString(const MyMessage &message);
|
||||
#endif
|
||||
@@ -1,52 +0,0 @@
|
||||
#include "Global.h"
|
||||
#include "classes/IoTItem.h"
|
||||
#include "Arduino.h"
|
||||
#include "MySensorsData.h"
|
||||
|
||||
#ifdef MYSENSORS
|
||||
|
||||
void receive(const MyMessage& message) {
|
||||
String inMsg = String(message.getSender()) + "," + // node-id
|
||||
String(message.getSensor()) + "," + // child-sensor-id
|
||||
String(message.getType()) + "," + // type of var
|
||||
String(message.getCommand()) + "," + // command
|
||||
parseToString(message) + ";"; // value
|
||||
|
||||
SerialPrint("i", F("MySensorsGate"), inMsg);
|
||||
|
||||
mysensorBuf += inMsg;
|
||||
}
|
||||
|
||||
String parseToString(const MyMessage& message) {
|
||||
String value = "error";
|
||||
switch (message.getPayloadType()) {
|
||||
case 0: // Payload type is string
|
||||
value = message.getString();
|
||||
return value;
|
||||
case 1: // Payload type is byte
|
||||
value = String(message.getByte());
|
||||
return value;
|
||||
case 2: // Payload type is INT16
|
||||
value = String(message.getInt());
|
||||
return value;
|
||||
case 3: // Payload type is UINT16
|
||||
value = String(message.getUInt());
|
||||
return value;
|
||||
case 4: // Payload type is INT32
|
||||
value = String(message.getInt());
|
||||
return value;
|
||||
case 5: // Payload type is UINT32
|
||||
value = String(message.getUInt());
|
||||
return value;
|
||||
case 6: // Payload type is binary
|
||||
value = String(message.getBool());
|
||||
return value;
|
||||
case 7: // Payload type is float32
|
||||
value = String(message.getFloat());
|
||||
return value;
|
||||
default:
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user