@@ -67,15 +67,15 @@ char S_50[] PROGMEM = "Sketch_version"; // Does not exist in MyMessage.h!
67
67
68
68
69
69
PROGMEM const char *sType [] = {
70
- S_0, S_1, S_2, S_3, S_4, S_5, S_6, S_7, S_8, S_9, S_10,
70
+ S_0, S_1, S_2, S_3, S_4, S_5, S_6, S_7, S_8, S_9, S_10,
71
71
S_11, S_12, S_13, S_14, S_15, S_16, S_17, S_18, S_19, S_20,
72
- S_21, S_22, S_23, S_24, S_25, S_26, S_27, S_28, S_29, S_30,
72
+ S_21, S_22, S_23, S_24, S_25, S_26, S_27, S_28, S_29, S_30,
73
73
S_31, S_32, S_33, S_34, S_35, S_36, S_37, S_38, S_39, S_40,
74
74
S_41, S_42, S_43, S_44, S_45, S_46, S_47, S_48, S_49, S_50
75
75
};
76
76
77
77
78
- MyMQTT::MyMQTT (uint8_t _cepin, uint8_t _cspin, uint8_t _rx, uint8_t _tx, uint8_t _er) :
78
+ MyMQTT::MyMQTT (uint8_t _cepin, uint8_t _cspin, uint8_t _rx, uint8_t _tx, uint8_t _er) :
79
79
MySensor(_cepin, _cspin) {
80
80
if (_rx != NULL ) {
81
81
pinRx = _rx;
@@ -85,7 +85,7 @@ MySensor(_cepin, _cspin) {
85
85
if (_tx != NULL ) {
86
86
pinTx = _tx;
87
87
pinMode (pinTx, OUTPUT);
88
- ledMode = true ;
88
+ ledMode = true ;
89
89
}
90
90
if (_er != NULL ) {
91
91
pinEr = _er;
@@ -132,7 +132,7 @@ void MyMQTT::processMQTTMessage(char *inputString, int inputPos) {
132
132
buffer[0 ]= 0 ;
133
133
buffsize = 0 ;
134
134
#ifdef TCPDUMP
135
- Serial.print (" <<" );
135
+ Serial.print (" <<" );
136
136
char buf[4 ];
137
137
for (int a=0 ; a<inputPos; a++) { sprintf (buf," %02X " ,(byte)inputString[a]); Serial.print (buf); } Serial.println (" " );
138
138
#endif
@@ -165,14 +165,14 @@ void MyMQTT::processMQTTMessage(char *inputString, int inputPos) {
165
165
}
166
166
if (buffsize > 0 ) {
167
167
#ifdef TCPDUMP
168
- Serial.print (" >>" );
168
+ Serial.print (" >>" );
169
169
char buf[4 ];
170
- for (int a=0 ; a<buffsize; a++) { sprintf (buf," %02X " ,(byte)buffer[a]); Serial.print (buf); } Serial.println (" " );
170
+ for (int a=0 ; a<buffsize; a++) { sprintf (buf," %02X " ,(byte)buffer[a]); Serial.print (buf); } Serial.println (" " );
171
171
#endif
172
172
dataCallback (buffer,&buffsize);
173
173
}
174
174
// We publish everything we get, we dont care if its subscribed or not!
175
- if ((byte)inputString[0 ] >> 4 == MQTTPUBLISH || (MQTT_SEND_SUBSCRIPTION && (byte)inputString[0 ] >> 4 == MQTTSUBSCRIBE)) {
175
+ if ((byte)inputString[0 ] >> 4 == MQTTPUBLISH || (MQTT_SEND_SUBSCRIPTION && (byte)inputString[0 ] >> 4 == MQTTSUBSCRIBE)) {
176
176
buffer[0 ]= 0 ;
177
177
buffsize = 0 ;
178
178
if ((byte)inputString[0 ] >> 4 == MQTTSUBSCRIBE) {
@@ -194,19 +194,19 @@ void MyMQTT::processMQTTMessage(char *inputString, int inputPos) {
194
194
} else if (i==3 ) {
195
195
char match=0 ;
196
196
for (int j=0 ; strcpy_P (convBuf, (char *)pgm_read_word (&(sType [j]))) ; j++) {
197
- if (strcmp (str,convBuf)==0 ) {
198
- match=j;
197
+ if (strcmp (str,convBuf)==0 ) {
198
+ match=j;
199
199
break ;
200
200
}
201
- }
201
+ }
202
202
msg.type = match;
203
203
}
204
204
i++;
205
205
}
206
206
if ((char )inputString[1 ] > (char )(inputString[3 ]+2 ) && !((byte)inputString[0 ] >> 4 == MQTTSUBSCRIBE)) {
207
207
strcpy (convBuf,inputString+(inputString[3 ]+4 ));
208
208
msg.set (convBuf);
209
- } else {
209
+ } else {
210
210
msg.set (" " );
211
211
}
212
212
msg.sender = GATEWAY_ADDRESS;
@@ -227,7 +227,7 @@ void MyMQTT::SendMQTT(MyMessage &msg) {
227
227
if (msg.isAck ()) {
228
228
Serial.println (" msg is ack!" );
229
229
if (msg.sender ==255 && mGetCommand (msg)==C_INTERNAL && msg.type ==I_ID_REQUEST) {
230
- // TODO: sending ACK request on id_response fucks node up. doesn't work.
230
+ // TODO: sending ACK request on id_response fucks node up. doesn't work.
231
231
// The idea was to confirm id and save to EEPROM_LATEST_NODE_ADDRESS.
232
232
}
233
233
} else {
@@ -239,11 +239,11 @@ void MyMQTT::SendMQTT(MyMessage &msg) {
239
239
saveState (EEPROM_LATEST_NODE_ADDRESS,newNodeID);
240
240
}
241
241
if (mGetCommand (msg)==C_INTERNAL && msg.type ==I_CONFIG) { // CONFIG
242
- // As for now there is only one 'config' request.
242
+ // As for now there is only one 'config' request.
243
243
// We force SI! Resistance is futile!
244
244
//
245
- // Todo : Support for more config types, Maybe just read from own EEPROM?
246
- // Use internal EEPROM_CONTROLLER_CONFIG_ADDRESS and special MQTT address to write to
245
+ // Todo : Support for more config types, Maybe just read from own EEPROM?
246
+ // Use internal EEPROM_CONTROLLER_CONFIG_ADDRESS and special MQTT address to write to
247
247
// EEPROM_CONTROLLER_CONFIG_ADDRESS & EEPROM_LOCAL_CONFIG_ADDRESS
248
248
msg.destination = msg.sender ; // NodeID
249
249
msg.sender = GATEWAY_ADDRESS;
@@ -273,10 +273,10 @@ void MyMQTT::SendMQTT(MyMessage &msg) {
273
273
mSetVersion (msg, PROTOCOL_VERSION);
274
274
txBlink (1 );
275
275
if (!sendRoute (msg)) errBlink (1 );
276
- // if (sendRoute(msg)) saveState(EEPROM_LATEST_NODE_ADDRESS,newNodeID); // If send OK save to eeprom. DOES NOT ALWAYS RETURN 'OK'!?
276
+ // if (sendRoute(msg)) saveState(EEPROM_LATEST_NODE_ADDRESS,newNodeID); // If send OK save to eeprom. DOES NOT ALWAYS RETURN 'OK'!?
277
277
} else if (mGetCommand (msg)!=0 ) {
278
278
if (mGetCommand (msg)==3 ) msg.type =msg.type +38 ;
279
- buffer[buffsize++] = MQTTPUBLISH << 4 ; // 0:
279
+ buffer[buffsize++] = MQTTPUBLISH << 4 ; // 0:
280
280
buffer[buffsize++] = 0x09 ; // 1: Remaining length with no payload, we'll set this later to correct value, buffsize -2
281
281
buffer[buffsize++] = 0x00 ; // 2: Length MSB (Remaing length can never exceed ff,so MSB must be 0!)
282
282
buffer[buffsize++] = 0x08 ; // 3: Length LSB (ADDR), We'll set this later
@@ -297,11 +297,11 @@ void MyMQTT::SendMQTT(MyMessage &msg) {
297
297
#ifdef TCPDUMP
298
298
Serial.print (" >>" );
299
299
char buf[4 ];
300
- for (int a=0 ; a<buffsize; a++) { sprintf (buf," %02X " ,(byte)buffer[a]); Serial.print (buf); } Serial.println (" " );
300
+ for (int a=0 ; a<buffsize; a++) { sprintf (buf," %02X " ,(byte)buffer[a]); Serial.print (buf); } Serial.println (" " );
301
301
#endif
302
302
dataCallback (buffer,&buffsize);
303
303
}
304
- }
304
+ }
305
305
}
306
306
307
307
boolean MyMQTT::isLedMode () {
@@ -350,7 +350,7 @@ void MyMQTT::errBlink(uint8_t cnt) {
350
350
char MyMQTT::strncpysType_retL (char *str, char index, char start) {
351
351
char c;
352
352
char l;
353
- char *p = (char *)pgm_read_word (&(sType [index ]));
353
+ char *p = (char *)pgm_read_word (&(sType [index ]));
354
354
str+=start;
355
355
while ((c = pgm_read_byte (p))) {
356
356
*str=c;
0 commit comments