forked from iot-playground/Arduino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
43 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,10 @@ | |
V1.1 - additional data types | ||
V1.0 - first version | ||
Created by Igor Jarc <[email protected]> | ||
Created by Igor Jarc | ||
See http://iot-playground.com for details | ||
Please use community fourum on website | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
|
@@ -62,7 +64,7 @@ void Esp8266EasyIoT::begin(void (*_msgCallback)(const Esp8266EasyIoTMsg &), int | |
//while(processesp() != E_IDLE) delay(1); | ||
|
||
// wait some time | ||
for(int i=0;i<500;i++) | ||
for(int i=0;i<600;i++) | ||
{ | ||
if (processesp() != E_IDLE) | ||
delay(10); | ||
|
@@ -106,22 +108,23 @@ void Esp8266EasyIoT::requestNodeId() | |
|
||
void Esp8266EasyIoT::requestTime(void (* _timeCallback)(unsigned long)) { | ||
timeCallback = _timeCallback; | ||
writeesp(build(msg, _nodeId, C_INTERNAL, I_TIME, NODE_SENSOR_ID, false).set("")); | ||
//writeesp(build(msg, _nodeId, C_INTERNAL, I_TIME, NODE_SENSOR_ID, false).set("")); | ||
|
||
_waitingCommandResponse = true; | ||
_commandRespondTimer = millis(); | ||
|
||
//waitIdle(); | ||
|
||
if (processesp() != E_IDLE) | ||
{ | ||
for(int i=0;i<30;i++) | ||
{ | ||
if (processesp() == E_IDLE) | ||
break; | ||
delay(10); | ||
} | ||
} | ||
sendinternal(build(msg, _nodeId, C_INTERNAL, I_TIME, NODE_SENSOR_ID, false).set("")); | ||
_waitingCommandResponse = false; | ||
|
||
//if (processesp() != E_IDLE) | ||
//{ | ||
// for(int i=0;i<30;i++) | ||
// { | ||
// if (processesp() == E_IDLE) | ||
// break; | ||
// delay(10); | ||
// } | ||
//} | ||
} | ||
|
||
|
||
|
@@ -155,10 +158,12 @@ void Esp8266EasyIoT::sendinternal(Esp8266EasyIoTMsg &message) | |
{ | ||
//if (waitIdle() && writeesp(message)) | ||
// waitIdle(); | ||
|
||
resetPingTimmer(); | ||
|
||
if (processesp() != E_IDLE) | ||
{ | ||
for(int i=0;i<30;i++) | ||
for(int i=0;i<100;i++) | ||
{ | ||
if (processesp() == E_IDLE) | ||
break; | ||
|
@@ -170,7 +175,7 @@ void Esp8266EasyIoT::sendinternal(Esp8266EasyIoTMsg &message) | |
|
||
if (processesp() != E_IDLE) | ||
{ | ||
for(int i=0;i<30;i++) | ||
for(int i=0;i<100;i++) | ||
{ | ||
if (processesp() == E_IDLE) | ||
break; | ||
|
@@ -268,6 +273,7 @@ bool Esp8266EasyIoT::process() | |
debug(PSTR("Receive C_SET\n")); | ||
resetPingTimmer(); | ||
|
||
_newMessage = false; | ||
// Call incoming message callback if available | ||
if (msgCallback != NULL) { | ||
msgCallback(msg); | ||
|
@@ -283,6 +289,8 @@ bool Esp8266EasyIoT::process() | |
// calclulate new CRC | ||
ack.crc8(); | ||
|
||
debug(PSTR("ACK message\n")); | ||
//sendinternal(ack); | ||
if (writeesp(ack)) | ||
{ | ||
debug(PSTR("ACK message\n")); | ||
|
@@ -335,6 +343,12 @@ bool Esp8266EasyIoT::process() | |
} | ||
|
||
|
||
void Esp8266EasyIoT::setNewMsg(Esp8266EasyIoTMsg &msgnew) | ||
{ | ||
msg = msgnew; | ||
} | ||
|
||
|
||
void Esp8266EasyIoT::setPingTimmer() | ||
{ | ||
_pingTimmer = millis() - PING_TIME - 1; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,10 @@ | |
V1.1 - additional data types | ||
V1.0 - first version | ||
Created by Igor Jarc <[email protected]> | ||
Created by Igor Jarc | ||
See http://iot-playground.com for details | ||
Please use community fourum on website | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
|
@@ -91,6 +93,9 @@ class Esp8266EasyIoT | |
|
||
void sendBatteryLevel(uint8_t level, bool ack=false); | ||
|
||
void setNewMsg(Esp8266EasyIoTMsg &); | ||
|
||
|
||
protected: | ||
Esp8266EasyIoTMsg msg; | ||
Esp8266EasyIoTMsg ack; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,10 @@ | |
V1.1 - additional data types | ||
V1.0 - first version | ||
Created by Igor Jarc <[email protected]> | ||
Created by Igor Jarc | ||
See http://iot-playground.com for details | ||
Please use community fourum on website | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,10 @@ | |
V1.1 - additional data types | ||
V1.0 - first version | ||
Created by Igor Jarc <[email protected]> | ||
Created by Igor Jarc | ||
See http://iot-playground.com for details | ||
Please use community fourum on website | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
|
@@ -17,7 +19,7 @@ | |
#endif | ||
|
||
|
||
#define LIBRARY_VERSION "1.1" | ||
#define LIBRARY_VERSION "1.3" | ||
#define PROTOCOL_VERSION 2 | ||
#define MAX_MESSAGE_LENGTH 127 | ||
#define HEADER_SIZE 9 | ||
|