small core fixes: remove time handler callback redundancy, substitute consts.
This commit is contained in:
@@ -71,6 +71,6 @@
|
||||
#endif
|
||||
|
||||
|
||||
#define MY_CAPABILIIES MY_CAP_RESET MY_CAP_RADIO MY_CAP_OTA_FW MY_CAP_TYPE MY_CAP_ARCH MY_CAP_SIGN
|
||||
#define MY_CAPABILITIES MY_CAP_RESET MY_CAP_RADIO MY_CAP_OTA_FW MY_CAP_TYPE MY_CAP_ARCH MY_CAP_SIGN
|
||||
|
||||
#endif /* MyGatewayTransportEthernet_h */
|
||||
|
||||
@@ -90,20 +90,27 @@ void hwWriteConfig(int adr, uint8_t value)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int8_t hwSleep(unsigned long ms) {
|
||||
// TODO: Not supported!
|
||||
(void)ms;
|
||||
return -2;
|
||||
}
|
||||
|
||||
int8_t hwSleep(uint8_t interrupt, uint8_t mode, unsigned long ms) {
|
||||
// TODO: Not supported!
|
||||
(void)interrupt;
|
||||
(void)mode;
|
||||
(void)ms;
|
||||
return -2;
|
||||
}
|
||||
|
||||
int8_t hwSleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mode2, unsigned long ms) {
|
||||
// TODO: Not supported!
|
||||
// TODO: Not supported!
|
||||
(void)interrupt1;
|
||||
(void)mode1;
|
||||
(void)interrupt2;
|
||||
(void)mode2;
|
||||
(void)ms;
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ extern "C" {
|
||||
struct rst_info resetInfo;
|
||||
|
||||
int atexit(void (*func)()) {
|
||||
(void)func;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -92,6 +93,7 @@ static void loop_wrapper() {
|
||||
}
|
||||
|
||||
static void loop_task(os_event_t *events) {
|
||||
(void)events;
|
||||
g_micros_at_task_start = system_get_time();
|
||||
cont_run(&g_cont, &loop_wrapper);
|
||||
if(cont_check(&g_cont) != 0) {
|
||||
|
||||
@@ -96,7 +96,7 @@ bool protocolParse(MyMessage &message, char *inputString) {
|
||||
}
|
||||
|
||||
char * protocolFormat(MyMessage &message) {
|
||||
snprintf_P(_fmtBuffer, MY_GATEWAY_MAX_SEND_LENGTH, PSTR("%d;%d;%d;%d;%d;%s\n"), message.sender, message.sensor, mGetCommand(message), mGetAck(message), message.type, message.getString(_convBuffer));
|
||||
snprintf_P(_fmtBuffer, MY_GATEWAY_MAX_SEND_LENGTH, PSTR("%d;%d;%d;%d;%d;%s\n"), message.sender, message.sensor, (uint8_t)mGetCommand(message), (uint8_t)mGetAck(message), message.type, message.getString(_convBuffer));
|
||||
return _fmtBuffer;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ void _process() {
|
||||
#if defined(MY_RADIO_FEATURE)
|
||||
transportProcess();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#if defined(MY_RADIO_FEATURE)
|
||||
@@ -59,15 +60,24 @@ static inline bool isValidParent( const uint8_t parent ) {
|
||||
}
|
||||
#endif
|
||||
|
||||
void _infiniteLoop() {
|
||||
while(1) {
|
||||
#if defined(MY_GATEWAY_ESP8266)
|
||||
yield();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void _begin() {
|
||||
#if !defined(MY_DISABLED_SERIAL)
|
||||
hwInit();
|
||||
#endif
|
||||
|
||||
// Call before() in sketch (if it exists)
|
||||
if (before) before();
|
||||
if (before)
|
||||
before();
|
||||
|
||||
debug(PSTR("Starting " MY_NODE_TYPE " (" MY_CAPABILIIES ", " LIBRARY_VERSION ")\n"));
|
||||
debug(PSTR("Starting " MY_NODE_TYPE " (" MY_CAPABILITIES ", " LIBRARY_VERSION ")\n"));
|
||||
|
||||
signerInit();
|
||||
|
||||
@@ -78,11 +88,7 @@ void _begin() {
|
||||
if (!transportInit()) {
|
||||
debug(PSTR("Radio init failed. Check wiring.\n"));
|
||||
// Nothing more we can do
|
||||
while(1) {
|
||||
#if defined(MY_GATEWAY_ESP8266)
|
||||
yield();
|
||||
#endif
|
||||
};
|
||||
_infiniteLoop();
|
||||
} else {
|
||||
debug(PSTR("Radio init successful.\n"));
|
||||
}
|
||||
@@ -97,11 +103,7 @@ void _begin() {
|
||||
if (!gatewayTransportInit()) {
|
||||
debug(PSTR("Transport driver init fail\n"));
|
||||
// Nothing more we can do
|
||||
while(1) {
|
||||
#if defined(MY_GATEWAY_ESP8266)
|
||||
yield();
|
||||
#endif
|
||||
}
|
||||
_infiniteLoop();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -296,25 +298,27 @@ void _processInternalMessages() {
|
||||
}
|
||||
} else if (type == I_HEARTBEAT) {
|
||||
sendHeartbeat();
|
||||
} else if (type == I_TIME && receiveTime) {
|
||||
} else if (type == I_TIME) {
|
||||
// Deliver time to callback
|
||||
if (receiveTime)
|
||||
receiveTime(_msg.getULong());
|
||||
}
|
||||
#if defined(MY_REPEATER_FEATURE)
|
||||
if (type == I_CHILDREN && _msg.getString()[0] == 'C') {
|
||||
// Clears child relay data for this node
|
||||
debug(PSTR("clear\n"));
|
||||
uint8_t i = 255;
|
||||
do {
|
||||
hwWriteConfig(EEPROM_ROUTES_ADDRESS+i, 0xff);
|
||||
} while (i--);
|
||||
// Clear parent node id & distance to gw
|
||||
hwWriteConfig(EEPROM_PARENT_NODE_ID_ADDRESS, 0xFF);
|
||||
hwWriteConfig(EEPROM_DISTANCE_ADDRESS, 0xFF);
|
||||
// Find parent node
|
||||
transportFindParentNode();
|
||||
_sendRoute(build(_msg, _nc.nodeId, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_CHILDREN,false).set(""));
|
||||
if (type == I_CHILDREN) {
|
||||
if (_msg.getString()[0] == 'C') {
|
||||
// Clears child relay data for this node
|
||||
debug(PSTR("clear routing table\n"));
|
||||
uint8_t i = 255;
|
||||
do {
|
||||
hwWriteConfig(EEPROM_ROUTES_ADDRESS+i, BROADCAST_ADDRESS);
|
||||
} while (i--);
|
||||
// Clear parent node id & distance to gw
|
||||
hwWriteConfig(EEPROM_PARENT_NODE_ID_ADDRESS, AUTO);
|
||||
hwWriteConfig(EEPROM_DISTANCE_ADDRESS, DISTANCE_INVALID);
|
||||
// Find parent node
|
||||
transportFindParentNode();
|
||||
_sendRoute(build(_msg, _nc.nodeId, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_CHILDREN,false).set(""));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -236,6 +236,8 @@ void _process(void);
|
||||
|
||||
void _processInternalMessages();
|
||||
|
||||
void _infiniteLoop();
|
||||
|
||||
boolean _sendRoute(MyMessage &message);
|
||||
|
||||
extern NodeConfig _nc;
|
||||
|
||||
@@ -164,7 +164,9 @@ inline void transportProcess() {
|
||||
if (_nc.nodeId == AUTO) {
|
||||
// sensor net gateway will return max id if all sensor id are taken
|
||||
debug(PSTR("full\n"));
|
||||
while (1); // Wait here. Nothing else we can do...
|
||||
// Nothing else we can do...
|
||||
_infiniteLoop();
|
||||
|
||||
}
|
||||
transportPresentNode();
|
||||
// Write id to EEPROM
|
||||
|
||||
Reference in New Issue
Block a user