This commit is contained in:
Sergio Pernas 2022-03-23 16:58:30 -03:00
parent c4cd7cd9b1
commit 01043e1739

View file

@ -1,9 +1,30 @@
int inData; int inData;
const char* valueSensor; const char* valueSensor;
const byte devID = 0x01; const byte devID = 0x01;
int errCode;
char sendData[3];
typedef struct {
char senType;
char senValue;
char senUnit;
} senFrame;
void newFrame (senFrame *pt, char sensor) {
pt-> senType = "hum";
pt-> senValue = "10.5";
pt-> senUnit = "%";
for ( byte i = 0; i < 4; i++) sendData[i] = ( ((byte *)pt)[i] );
Serial.println (sendData[sensor]);
}
@ -11,24 +32,22 @@ const byte devID = 0x01;
void setup() { void setup() {
Serial.begin(14400); Serial.begin(14400);
}
void loop() {
if ( Serial.available() > 0) {
switch (inData) {
case devID:
newFrame();
break;
}
}
} }
/*if ( Serial.available() > 0) {
void loop() {
if ( Serial.available() > 0) {
inData = Serial.read(); inData = Serial.read();
switch (inData) { switch (inData) {
@ -54,5 +73,4 @@ void setup() {
break; break;
} }
} } */
}