Weird compile error for Patrick
This commit is contained in:
@@ -1,13 +1,17 @@
|
|||||||
#ifndef MyConfig_h
|
#ifndef MyConfig_h
|
||||||
#define MyConfig_h
|
#define MyConfig_h
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
/**********************************
|
|
||||||
* Enable/Disable debug logging
|
// Enable debug flag for debug prints. This will add a lot to the size of the final sketch but good
|
||||||
***********************************/
|
// to see what is actually is happening when developing
|
||||||
#define DEBUG
|
#define DEBUG
|
||||||
|
|
||||||
|
// Serial output baud rate
|
||||||
#define BAUD_RATE 115200
|
#define BAUD_RATE 115200
|
||||||
|
|
||||||
|
// Set the hardware driver to use (initialized by MySensor-class)
|
||||||
|
#include "MyHwATMega328.h"
|
||||||
|
typedef MyHwATMega328 MyHwDriver;
|
||||||
|
|
||||||
/**********************************
|
/**********************************
|
||||||
* Message Signing Settings
|
* Message Signing Settings
|
||||||
|
|||||||
@@ -15,17 +15,18 @@ class MyHw
|
|||||||
public:
|
public:
|
||||||
// MyHw constructor
|
// MyHw constructor
|
||||||
MyHw();
|
MyHw();
|
||||||
virtual void init() = 0;
|
/* // The following is defined as macros to save space
|
||||||
|
virtual void init() = 0;
|
||||||
virtual void watchdogReset() = 0;
|
virtual void watchdogReset() = 0;
|
||||||
virtual void reboot() = 0;
|
virtual void reboot() = 0;
|
||||||
virtual unsigned long millisec() = 0;
|
virtual unsigned long millisec() = 0;
|
||||||
|
virtual uint8_t readConfig(uint8_t pos) = 0;
|
||||||
|
virtual void writeConfig(uint8_t pos, uint8_t value) = 0;
|
||||||
|
virtual void readConfigBlock(void* buf, void * pos, size_t length) = 0;
|
||||||
|
virtual void writeConfigBlock(void* pos, void* buf, uint16_t length) = 0; */
|
||||||
virtual void sleep(unsigned long ms) = 0;
|
virtual void sleep(unsigned long ms) = 0;
|
||||||
virtual bool sleep(uint8_t interrupt, uint8_t mode, unsigned long ms) = 0;
|
virtual bool sleep(uint8_t interrupt, uint8_t mode, unsigned long ms) = 0;
|
||||||
virtual uint8_t sleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mode2, unsigned long ms) = 0;
|
virtual uint8_t sleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mode2, unsigned long ms) = 0;
|
||||||
virtual uint8_t readConfigByte(uint8_t pos) = 0;
|
|
||||||
virtual void writeConfigByte(uint8_t pos, uint8_t value) = 0;
|
|
||||||
virtual void readConfigBlock(void* buf, void * pos, size_t length) = 0;
|
|
||||||
virtual void writeConfigBlock(void* pos, void* buf, uint16_t length) = 0;
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
virtual void debugPrint(bool isGW, const char *fmt, ... ) = 0;
|
virtual void debugPrint(bool isGW, const char *fmt, ... ) = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -16,6 +16,27 @@ MyHwATMega328::MyHwATMega328() : MyHw()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
// The following was redifined as macros to save space
|
||||||
|
|
||||||
|
inline uint8_t MyHwATMega328::readConfig(uint8_t pos) {
|
||||||
|
return eeprom_read_byte((uint8_t*)pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void MyHwATMega328::writeConfig(uint8_t pos, uint8_t value) {
|
||||||
|
eeprom_update_byte((uint8_t*)pos, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void MyHwATMega328::readConfigBlock(void* buf, void * pos, size_t length) {
|
||||||
|
eeprom_read_block(buf, (void*)pos, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void MyHwATMega328::writeConfigBlock(void* pos, void* buf, size_t length) {
|
||||||
|
eeprom_write_block((void*)pos, (void*)buf, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void MyHwATMega328::init() {
|
inline void MyHwATMega328::init() {
|
||||||
Serial.begin(BAUD_RATE);
|
Serial.begin(BAUD_RATE);
|
||||||
}
|
}
|
||||||
@@ -25,13 +46,13 @@ inline void MyHwATMega328::watchdogReset() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void MyHwATMega328::reboot() {
|
inline void MyHwATMega328::reboot() {
|
||||||
wdt_enable(WDTO_15MS);
|
wdt_enable(WDTO_15MS); for (;;);
|
||||||
for (;;);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline unsigned long MyHwATMega328::millisec() {
|
inline unsigned long MyHwATMega328::millis() {
|
||||||
return millis();
|
return ::millis();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
void powerDown(period_t period) {
|
void powerDown(period_t period) {
|
||||||
@@ -128,21 +149,6 @@ inline uint8_t MyHwATMega328::sleep(uint8_t interrupt1, uint8_t mode1, uint8_t i
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint8_t MyHwATMega328::readConfigByte(uint8_t pos) {
|
|
||||||
return eeprom_read_byte((uint8_t*)pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void MyHwATMega328::writeConfigByte(uint8_t pos, uint8_t value) {
|
|
||||||
eeprom_update_byte((uint8_t*)pos, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void MyHwATMega328::readConfigBlock(void* buf, void * pos, size_t length) {
|
|
||||||
eeprom_read_block(buf, (void*)pos, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void MyHwATMega328::writeConfigBlock(void* pos, void* buf, size_t length) {
|
|
||||||
eeprom_write_block((void*)pos, (void*)buf, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|||||||
@@ -17,6 +17,18 @@
|
|||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Define these as macros to save valuable space
|
||||||
|
#define hw_init() Serial.begin(BAUD_RATE)
|
||||||
|
#define hw_watchdogReset() wdt_reset()
|
||||||
|
#define hw_reboot() wdt_enable(WDTO_15MS); for (;;)
|
||||||
|
#define hw_millis() millis()
|
||||||
|
#define hw_readConfig(__pos) eeprom_read_byte((uint8_t*)__pos)
|
||||||
|
#define hw_writeConfig(__pos, __value) eeprom_update_byte((uint8_t*)__pos, __value)
|
||||||
|
#define hw_readConfigBlock(__buf, __pos, __length) eeprom_read_block(buf, (void*)__pos, __length)
|
||||||
|
#define hw_writeConfigBlock(__pos, __buf, __length) eeprom_write_block((void*)__pos, (void*)__buf, __length)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
enum period_t
|
enum period_t
|
||||||
{
|
{
|
||||||
SLEEP_15Ms,
|
SLEEP_15Ms,
|
||||||
@@ -37,17 +49,18 @@ class MyHwATMega328 : public MyHw
|
|||||||
public:
|
public:
|
||||||
MyHwATMega328();
|
MyHwATMega328();
|
||||||
|
|
||||||
void init();
|
/* void init();
|
||||||
void watchdogReset();
|
void watchdogReset();
|
||||||
void reboot();
|
void reboot();
|
||||||
unsigned long millisec();
|
unsigned long millis();
|
||||||
|
uint8_t readConfig(uint8_t pos);
|
||||||
|
void writeConfig(uint8_t pos, uint8_t value);
|
||||||
|
void readConfigBlock(void* buf, void * pos, size_t length);
|
||||||
|
void writeConfigBlock(void* pos, void* buf, size_t length); */
|
||||||
|
|
||||||
void sleep(unsigned long ms);
|
void sleep(unsigned long ms);
|
||||||
bool sleep(uint8_t interrupt, uint8_t mode, unsigned long ms);
|
bool sleep(uint8_t interrupt, uint8_t mode, unsigned long ms);
|
||||||
uint8_t sleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mode2, unsigned long ms);
|
uint8_t sleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mode2, unsigned long ms);
|
||||||
uint8_t readConfigByte(uint8_t pos);
|
|
||||||
void writeConfigByte(uint8_t pos, uint8_t value);
|
|
||||||
void readConfigBlock(void* buf, void * pos, size_t length);
|
|
||||||
void writeConfigBlock(void* pos, void* buf, size_t length);
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void debugPrint(bool isGW, const char *fmt, ... );
|
void debugPrint(bool isGW, const char *fmt, ... );
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ MySensor::MySensor(MyTransport &_radio, MySigning &_signer, MyHw &_hw)
|
|||||||
|
|
||||||
|
|
||||||
void MySensor::begin(void (*_msgCallback)(const MyMessage &), uint8_t _nodeId, boolean _repeaterMode, uint8_t _parentNodeId) {
|
void MySensor::begin(void (*_msgCallback)(const MyMessage &), uint8_t _nodeId, boolean _repeaterMode, uint8_t _parentNodeId) {
|
||||||
hw.init();
|
hw_init();
|
||||||
repeaterMode = _repeaterMode;
|
repeaterMode = _repeaterMode;
|
||||||
msgCallback = _msgCallback;
|
msgCallback = _msgCallback;
|
||||||
failedTransmissions = 0;
|
failedTransmissions = 0;
|
||||||
@@ -60,11 +60,11 @@ void MySensor::begin(void (*_msgCallback)(const MyMessage &), uint8_t _nodeId, b
|
|||||||
radio.init();
|
radio.init();
|
||||||
|
|
||||||
// Read settings from eeprom
|
// Read settings from eeprom
|
||||||
hw.readConfigBlock((void*)&nc, (void*)EEPROM_NODE_ID_ADDRESS, sizeof(NodeConfig));
|
hw_readConfigBlock((void*)&nc, (void*)EEPROM_NODE_ID_ADDRESS, sizeof(NodeConfig));
|
||||||
// Read latest received controller configuration from EEPROM
|
// Read latest received controller configuration from EEPROM
|
||||||
hw.readConfigBlock((void*)&cc, (void*)EEPROM_CONTROLLER_CONFIG_ADDRESS, sizeof(ControllerConfig));
|
hw_readConfigBlock((void*)&cc, (void*)EEPROM_CONTROLLER_CONFIG_ADDRESS, sizeof(ControllerConfig));
|
||||||
// Read out the signing requirements from EEPROM
|
// Read out the signing requirements from EEPROM
|
||||||
hw.readConfigBlock((void*)doSign, (void*)EEPROM_SIGNING_REQUIREMENT_TABLE_ADDRESS, sizeof(doSign));
|
hw_readConfigBlock((void*)doSign, (void*)EEPROM_SIGNING_REQUIREMENT_TABLE_ADDRESS, sizeof(doSign));
|
||||||
|
|
||||||
if (isGateway) {
|
if (isGateway) {
|
||||||
nc.distance = 0;
|
nc.distance = 0;
|
||||||
@@ -79,7 +79,7 @@ void MySensor::begin(void (*_msgCallback)(const MyMessage &), uint8_t _nodeId, b
|
|||||||
if (!autoFindParent) {
|
if (!autoFindParent) {
|
||||||
nc.parentNodeId = _parentNodeId;
|
nc.parentNodeId = _parentNodeId;
|
||||||
// Save static parent id in eeprom (used by bootloader)
|
// Save static parent id in eeprom (used by bootloader)
|
||||||
hw.writeConfigByte(EEPROM_PARENT_NODE_ID_ADDRESS, _parentNodeId);
|
hw_writeConfig(EEPROM_PARENT_NODE_ID_ADDRESS, _parentNodeId);
|
||||||
// We don't actually know the distance to gw here. Let's pretend it is 1.
|
// We don't actually know the distance to gw here. Let's pretend it is 1.
|
||||||
// If the current node is also repeater, be aware of this.
|
// If the current node is also repeater, be aware of this.
|
||||||
nc.distance = 1;
|
nc.distance = 1;
|
||||||
@@ -94,7 +94,7 @@ void MySensor::begin(void (*_msgCallback)(const MyMessage &), uint8_t _nodeId, b
|
|||||||
nc.nodeId = _nodeId;
|
nc.nodeId = _nodeId;
|
||||||
// Save static id in eeprom
|
// Save static id in eeprom
|
||||||
if (_nodeId > 0)
|
if (_nodeId > 0)
|
||||||
hw.writeConfigByte(EEPROM_NODE_ID_ADDRESS, _nodeId);
|
hw_writeConfig(EEPROM_NODE_ID_ADDRESS, _nodeId);
|
||||||
} else if (isValidParent(nc.parentNodeId)) {
|
} else if (isValidParent(nc.parentNodeId)) {
|
||||||
// Try to fetch node-id from gateway
|
// Try to fetch node-id from gateway
|
||||||
requestNodeId();
|
requestNodeId();
|
||||||
@@ -206,7 +206,7 @@ boolean MySensor::sendRoute(MyMessage &message) {
|
|||||||
ok = sendWrite(nc.parentNodeId, message);
|
ok = sendWrite(nc.parentNodeId, message);
|
||||||
} else {
|
} else {
|
||||||
// Relay the message
|
// Relay the message
|
||||||
uint8_t route = hw.readConfigByte(EEPROM_ROUTES_ADDRESS+dest);
|
uint8_t route = hw_readConfig(EEPROM_ROUTES_ADDRESS+dest);
|
||||||
if (route > GATEWAY_ADDRESS && route < BROADCAST_ADDRESS) {
|
if (route > GATEWAY_ADDRESS && route < BROADCAST_ADDRESS) {
|
||||||
// This message should be forwarded to a child node. If we send message
|
// This message should be forwarded to a child node. If we send message
|
||||||
// to this nodes pipe then all children will receive it because the are
|
// to this nodes pipe then all children will receive it because the are
|
||||||
@@ -244,7 +244,7 @@ boolean MySensor::sendRoute(MyMessage &message) {
|
|||||||
// This message should be routed back towards sensor net gateway
|
// This message should be routed back towards sensor net gateway
|
||||||
ok = sendWrite(nc.parentNodeId, message);
|
ok = sendWrite(nc.parentNodeId, message);
|
||||||
// Add this child to our "routing table" if it not already exist
|
// Add this child to our "routing table" if it not already exist
|
||||||
hw.writeConfigByte(EEPROM_ROUTES_ADDRESS+sender, last);
|
hw_writeConfig(EEPROM_ROUTES_ADDRESS+sender, last);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,7 +308,7 @@ void MySensor::requestTime(void (* _timeCallback)(unsigned long)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean MySensor::process() {
|
boolean MySensor::process() {
|
||||||
hw.watchdogReset();
|
hw_watchdogReset();
|
||||||
uint8_t to = 0;
|
uint8_t to = 0;
|
||||||
if (!radio.available(&to))
|
if (!radio.available(&to))
|
||||||
return false;
|
return false;
|
||||||
@@ -357,7 +357,7 @@ boolean MySensor::process() {
|
|||||||
|
|
||||||
if (repeaterMode && last != nc.parentNodeId) {
|
if (repeaterMode && last != nc.parentNodeId) {
|
||||||
// Message is from one of the child nodes. Add it to routing table.
|
// Message is from one of the child nodes. Add it to routing table.
|
||||||
hw.writeConfigByte(EEPROM_ROUTES_ADDRESS+sender, last);
|
hw_writeConfig(EEPROM_ROUTES_ADDRESS+sender, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if sender requests an ack back.
|
// Check if sender requests an ack back.
|
||||||
@@ -385,8 +385,8 @@ boolean MySensor::process() {
|
|||||||
// Found a neighbor closer to GW than previously found
|
// Found a neighbor closer to GW than previously found
|
||||||
nc.distance = distance;
|
nc.distance = distance;
|
||||||
nc.parentNodeId = msg.sender;
|
nc.parentNodeId = msg.sender;
|
||||||
hw.writeConfigByte(EEPROM_PARENT_NODE_ID_ADDRESS, nc.parentNodeId);
|
hw_writeConfig(EEPROM_PARENT_NODE_ID_ADDRESS, nc.parentNodeId);
|
||||||
hw.writeConfigByte(EEPROM_DISTANCE_ADDRESS, nc.distance);
|
hw_writeConfig(EEPROM_DISTANCE_ADDRESS, nc.distance);
|
||||||
debug(PSTR("parent=%d, d=%d\n"), nc.parentNodeId, nc.distance);
|
debug(PSTR("parent=%d, d=%d\n"), nc.parentNodeId, nc.distance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -406,7 +406,7 @@ boolean MySensor::process() {
|
|||||||
CLEAR_SIGN(msg.sender);
|
CLEAR_SIGN(msg.sender);
|
||||||
}
|
}
|
||||||
// Save updated table
|
// Save updated table
|
||||||
hw.writeConfigBlock((void*)EEPROM_SIGNING_REQUIREMENT_TABLE_ADDRESS, (void*)doSign, sizeof(doSign));
|
hw_writeConfigBlock((void*)EEPROM_SIGNING_REQUIREMENT_TABLE_ADDRESS, (void*)doSign, sizeof(doSign));
|
||||||
|
|
||||||
// Inform sender about our preference if we are a gateway, but only require signing if the sender required signing
|
// Inform sender about our preference if we are a gateway, but only require signing if the sender required signing
|
||||||
// We do not currently want a gateway to require signing from all nodes in a network just because it wants one node
|
// We do not currently want a gateway to require signing from all nodes in a network just because it wants one node
|
||||||
@@ -425,7 +425,7 @@ boolean MySensor::process() {
|
|||||||
|
|
||||||
if (type == I_REBOOT) {
|
if (type == I_REBOOT) {
|
||||||
// Requires MySensors or other bootloader with watchdogs enabled
|
// Requires MySensors or other bootloader with watchdogs enabled
|
||||||
hw.reboot();
|
hw_reboot();
|
||||||
} else if (type == I_ID_RESPONSE) {
|
} else if (type == I_ID_RESPONSE) {
|
||||||
if (nc.nodeId == AUTO) {
|
if (nc.nodeId == AUTO) {
|
||||||
nc.nodeId = msg.getByte();
|
nc.nodeId = msg.getByte();
|
||||||
@@ -436,7 +436,7 @@ boolean MySensor::process() {
|
|||||||
}
|
}
|
||||||
setupNode();
|
setupNode();
|
||||||
// Write id to EEPROM
|
// Write id to EEPROM
|
||||||
hw.writeConfigByte(EEPROM_NODE_ID_ADDRESS, nc.nodeId);
|
hw_writeConfig(EEPROM_NODE_ID_ADDRESS, nc.nodeId);
|
||||||
debug(PSTR("id=%d\n"), nc.nodeId);
|
debug(PSTR("id=%d\n"), nc.nodeId);
|
||||||
}
|
}
|
||||||
} else if (type == I_CONFIG) {
|
} else if (type == I_CONFIG) {
|
||||||
@@ -444,18 +444,18 @@ boolean MySensor::process() {
|
|||||||
// and store it in eeprom if changed
|
// and store it in eeprom if changed
|
||||||
isMetric = msg.getString()[0] == 'M' ;
|
isMetric = msg.getString()[0] == 'M' ;
|
||||||
cc.isMetric = isMetric;
|
cc.isMetric = isMetric;
|
||||||
hw.writeConfigByte(EEPROM_CONTROLLER_CONFIG_ADDRESS, isMetric);
|
hw_writeConfig(EEPROM_CONTROLLER_CONFIG_ADDRESS, isMetric);
|
||||||
} else if (type == I_CHILDREN) {
|
} else if (type == I_CHILDREN) {
|
||||||
if (repeaterMode && msg.getString()[0] == 'C') {
|
if (repeaterMode && msg.getString()[0] == 'C') {
|
||||||
// Clears child relay data for this node
|
// Clears child relay data for this node
|
||||||
debug(PSTR("clear\n"));
|
debug(PSTR("clear\n"));
|
||||||
uint8_t i = 255;
|
uint8_t i = 255;
|
||||||
do {
|
do {
|
||||||
hw.writeConfigByte(EEPROM_ROUTES_ADDRESS+i, 0xff);
|
hw_writeConfig(EEPROM_ROUTES_ADDRESS+i, 0xff);
|
||||||
} while (i--);
|
} while (i--);
|
||||||
// Clear parent node id & distance to gw
|
// Clear parent node id & distance to gw
|
||||||
hw.writeConfigByte(EEPROM_PARENT_NODE_ID_ADDRESS, 0xFF);
|
hw_writeConfig(EEPROM_PARENT_NODE_ID_ADDRESS, 0xFF);
|
||||||
hw.writeConfigByte(EEPROM_DISTANCE_ADDRESS, 0xFF);
|
hw_writeConfig(EEPROM_DISTANCE_ADDRESS, 0xFF);
|
||||||
// Find parent node
|
// Find parent node
|
||||||
findParentNode();
|
findParentNode();
|
||||||
sendRoute(build(msg, nc.nodeId, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_CHILDREN,false).set(""));
|
sendRoute(build(msg, nc.nodeId, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_CHILDREN,false).set(""));
|
||||||
@@ -480,7 +480,7 @@ boolean MySensor::process() {
|
|||||||
// Relaying nodes should always answer ping messages
|
// Relaying nodes should always answer ping messages
|
||||||
// Wait a random delay of 0-2 seconds to minimize collision
|
// Wait a random delay of 0-2 seconds to minimize collision
|
||||||
// between ping ack messages from other relaying nodes
|
// between ping ack messages from other relaying nodes
|
||||||
wait(hw.millisec() & 0x3ff);
|
wait(hw_millis() & 0x3ff);
|
||||||
sendWrite(sender, build(msg, nc.nodeId, sender, NODE_SENSOR_ID, C_INTERNAL, I_FIND_PARENT_RESPONSE, false).set(nc.distance));
|
sendWrite(sender, build(msg, nc.nodeId, sender, NODE_SENSOR_ID, C_INTERNAL, I_FIND_PARENT_RESPONSE, false).set(nc.distance));
|
||||||
}
|
}
|
||||||
} else if (to == nc.nodeId) {
|
} else if (to == nc.nodeId) {
|
||||||
@@ -496,15 +496,15 @@ MyMessage& MySensor::getLastMessage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MySensor::saveState(uint8_t pos, uint8_t value) {
|
void MySensor::saveState(uint8_t pos, uint8_t value) {
|
||||||
hw.writeConfigByte(EEPROM_LOCAL_CONFIG_ADDRESS+pos, value);
|
hw_writeConfig(EEPROM_LOCAL_CONFIG_ADDRESS+pos, value);
|
||||||
}
|
}
|
||||||
uint8_t MySensor::loadState(uint8_t pos) {
|
uint8_t MySensor::loadState(uint8_t pos) {
|
||||||
return hw.readConfigByte(EEPROM_LOCAL_CONFIG_ADDRESS+pos);
|
return hw_readConfig(EEPROM_LOCAL_CONFIG_ADDRESS+pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MySensor::wait(unsigned long ms) {
|
void MySensor::wait(unsigned long ms) {
|
||||||
unsigned long enter = hw.millisec();
|
unsigned long enter = hw_millis();
|
||||||
while (hw.millisec() - enter < ms) {
|
while (hw_millis() - enter < ms) {
|
||||||
process();
|
process();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -530,9 +530,9 @@ bool MySensor::sign(MyMessage &message) {
|
|||||||
} else {
|
} else {
|
||||||
// We have to wait for the nonce to arrive before we can sign our original message
|
// We have to wait for the nonce to arrive before we can sign our original message
|
||||||
// Other messages could come in-between. We trust process() takes care of them
|
// Other messages could come in-between. We trust process() takes care of them
|
||||||
unsigned long enter = hw.millisec();
|
unsigned long enter = hw_millis();
|
||||||
msgSign = message; // Copy the message to sign since message buffer might be touched in process()
|
msgSign = message; // Copy the message to sign since message buffer might be touched in process()
|
||||||
while (hw.millisec() - enter < 5000) {
|
while (hw_millis() - enter < 5000) {
|
||||||
if (process()) {
|
if (process()) {
|
||||||
if (mGetCommand(getLastMessage()) == C_INTERNAL && getLastMessage().type == I_GET_NONCE_RESPONSE) {
|
if (mGetCommand(getLastMessage()) == C_INTERNAL && getLastMessage().type == I_GET_NONCE_RESPONSE) {
|
||||||
// Proceed with signing if nonce has been received
|
// Proceed with signing if nonce has been received
|
||||||
|
|||||||
@@ -13,14 +13,13 @@
|
|||||||
#define MySensor_h
|
#define MySensor_h
|
||||||
|
|
||||||
#include "Version.h" // Auto generated by bot
|
#include "Version.h" // Auto generated by bot
|
||||||
|
#include "MyConfig.h"
|
||||||
#include "MyHw.h"
|
#include "MyHw.h"
|
||||||
#include "MyHwATMega328.h"
|
|
||||||
#include "MyTransport.h"
|
#include "MyTransport.h"
|
||||||
#include "MyTransportNRF24.h"
|
#include "MyTransportNRF24.h"
|
||||||
#include "MyParser.h"
|
#include "MyParser.h"
|
||||||
#include "MySigning.h"
|
#include "MySigning.h"
|
||||||
#include "MySigningNone.h"
|
#include "MySigningNone.h"
|
||||||
#include "MyConfig.h"
|
|
||||||
#include "MyMessage.h"
|
#include "MyMessage.h"
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -74,7 +73,7 @@ class MySensor
|
|||||||
* Creates a new instance of Sensor class.
|
* Creates a new instance of Sensor class.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
MySensor(MyTransport &radio =*new MyTransportNRF24(), MySigning &signer=*new MySigningNone(), MyHw &hw=*new MyHwATMega328());
|
MySensor(MyTransport &radio =*new MyTransportNRF24(), MySigning &signer=*new MySigningNone(), MyHw &hw=*new MyHwDriver());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Begin operation of the MySensors library
|
* Begin operation of the MySensors library
|
||||||
|
|||||||
Reference in New Issue
Block a user