moved comment and minor ops
This commit is contained in:
+23
-23
@@ -1,20 +1,20 @@
|
|||||||
/* MyMQTT Broker Gateway 0.1b
|
/* MyMQTT Broker Gateway 0.1b
|
||||||
|
|
||||||
Created by Daniel Wiegert <daniel.wiegert@gmail.com>
|
Created by Daniel Wiegert <daniel.wiegert@gmail.com>
|
||||||
Based on MySensors Ethernet Gateway by Henrik Ekblad <henrik.ekblad@gmail.com>
|
Based on MySensors Ethernet Gateway by Henrik Ekblad <henrik.ekblad@gmail.com>
|
||||||
http://www.mysensors.org
|
http://www.mysensors.org
|
||||||
|
|
||||||
Requires MySensors lib 1.4b
|
Requires MySensors lib 1.4b
|
||||||
|
|
||||||
* Change below; TCP_IP, TCP_PORT, TCP_MAC
|
* Change below; TCP_IP, TCP_PORT, TCP_MAC
|
||||||
This will listen on your selected TCP_IP:TCP_PORT below, Please change TCP_MAC your liking also.
|
This will listen on your selected TCP_IP:TCP_PORT below, Please change TCP_MAC your liking also.
|
||||||
*1 -> NOTE: Keep first byte at x2, x6, xA or xE (replace x with any hex value) for using Local Ranges.
|
*1 -> NOTE: Keep first byte at x2, x6, xA or xE (replace x with any hex value) for using Local Ranges.
|
||||||
|
|
||||||
*2 You can use standard pin set-up as MySensors recommends or if you own a IBOARD you may change
|
*2 You can use standard pin set-up as MySensors recommends or if you own a IBOARD you may change
|
||||||
the radio-pins below if you hardware mod your iBoard. see [URL BELOW] for more details.
|
the radio-pins below if you hardware mod your iBoard. see [URL BELOW] for more details.
|
||||||
http://forum.mysensors.org/topic/224/iboard-cheap-single-board-ethernet-arduino-with-radio/5
|
http://forum.mysensors.org/topic/224/iboard-cheap-single-board-ethernet-arduino-with-radio/5
|
||||||
|
|
||||||
* Don't forget to look at the definitions in libraries\MySensors\MyMQTT.h!
|
* Don't forget to look at the definitions in libraries\MySensors\MyMQTT.h!
|
||||||
|
|
||||||
define TCPDUMP and connect serial interface if you have problems, please write on
|
define TCPDUMP and connect serial interface if you have problems, please write on
|
||||||
http://forum.mysensors.org/ and explain your problem, include serial output. Don't forget to
|
http://forum.mysensors.org/ and explain your problem, include serial output. Don't forget to
|
||||||
@@ -29,8 +29,9 @@
|
|||||||
MQTT_SEND_SUBSCRIPTION is if you want the MyMQTT to send a empty payload message to your nodes.
|
MQTT_SEND_SUBSCRIPTION is if you want the MyMQTT to send a empty payload message to your nodes.
|
||||||
This can be useful if you want to send latest state back to the MQTT client. Just check if incoming
|
This can be useful if you want to send latest state back to the MQTT client. Just check if incoming
|
||||||
message has any length or not.
|
message has any length or not.
|
||||||
|
Example: if (msg.type==V_LIGHT && strlen(msg.getString())>0) otherwise the code might do strange things.
|
||||||
|
|
||||||
* Address-layout is : [MQTT_BROKER_PREFIX]/[NodeID]/[SensorID]/[SensorType]
|
* Address-layout is : [MQTT_BROKER_PREFIX]/[NodeID]/[SensorID]/[SensorType]
|
||||||
NodeID and SensorID is uint8 (0-255) number.
|
NodeID and SensorID is uint8 (0-255) number.
|
||||||
Last segment is translation of the sensor type, look inside MyMQTT.cpp for the definitions.
|
Last segment is translation of the sensor type, look inside MyMQTT.cpp for the definitions.
|
||||||
User can change this to their needs. We have also left some space for custom types.
|
User can change this to their needs. We have also left some space for custom types.
|
||||||
@@ -39,17 +40,17 @@ Special: (sensor 255 reserved for special commands)
|
|||||||
You can receive a node sketch name with MyMQTT/20/255/Sketch_name (or version with _version)
|
You can receive a node sketch name with MyMQTT/20/255/Sketch_name (or version with _version)
|
||||||
|
|
||||||
To-do:
|
To-do:
|
||||||
Special commands : clear or set EEPROM Values, Send REBOOT and Receive reboot for MyMQTT itself.
|
Special commands : clear or set EEPROM Values, Send REBOOT and Receive reboot for MyMQTT itself.
|
||||||
Be able to send ACK so client returns the data being sent.
|
Be able to send ACK so client returns the data being sent.
|
||||||
... Please come with ideas!
|
... Please come with ideas!
|
||||||
|
|
||||||
Test in more MQTT clients, So far tested in openhab and MyMQTT for Android (Not my creation)
|
Test in more MQTT clients, So far tested in openhab and MyMQTT for Android (Not my creation)
|
||||||
- http://www.openhab.org/
|
- http://www.openhab.org/
|
||||||
- https://play.google.com/store/apps/details?id=at.tripwire.mqtt.client&hl=en
|
- https://play.google.com/store/apps/details?id=at.tripwire.mqtt.client&hl=en
|
||||||
... Please notify me if you use this broker with other software.
|
... Please notify me if you use this broker with other software.
|
||||||
|
|
||||||
|
|
||||||
* Example Openhab configuration:
|
* Example Openhab configuration:
|
||||||
openhab.cfg
|
openhab.cfg
|
||||||
---
|
---
|
||||||
mqtt:mysensor.url=tcp://192.168.0.234:1883
|
mqtt:mysensor.url=tcp://192.168.0.234:1883
|
||||||
@@ -75,7 +76,7 @@ sitemap/test.site
|
|||||||
---
|
---
|
||||||
sitemap demo label="Menu"
|
sitemap demo label="Menu"
|
||||||
Frame label="Openhab" {
|
Frame label="Openhab" {
|
||||||
Group item=test label="Test group"
|
Group item=test label="Test group"
|
||||||
}
|
}
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -148,7 +149,7 @@ int main(void) {
|
|||||||
delay(1000); // Wait for Ethernet to get configured.
|
delay(1000); // Wait for Ethernet to get configured.
|
||||||
gw.begin(RF24_PA_LEVEL_GW, RF24_CHANNEL, RF24_DATARATE, writeEthernet);
|
gw.begin(RF24_PA_LEVEL_GW, RF24_CHANNEL, RF24_DATARATE, writeEthernet);
|
||||||
server.begin();
|
server.begin();
|
||||||
// Add led timer interrupt
|
// Add led timer interrupt
|
||||||
if (gw.isLedMode()) {
|
if (gw.isLedMode()) {
|
||||||
MsTimer2::set(200, ledTimersInterrupt);
|
MsTimer2::set(200, ledTimersInterrupt);
|
||||||
MsTimer2::start();
|
MsTimer2::start();
|
||||||
@@ -159,4 +160,3 @@ int main(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ void MyMQTT::SendMQTT(MyMessage &msg) {
|
|||||||
mSetVersion(msg, PROTOCOL_VERSION);
|
mSetVersion(msg, PROTOCOL_VERSION);
|
||||||
txBlink(1);
|
txBlink(1);
|
||||||
if (!sendRoute(msg)) errBlink(1);
|
if (!sendRoute(msg)) errBlink(1);
|
||||||
// if (sendRoute(msg)) saveState(EEPROM_LATEST_NODE_ADDRESS,newNodeID); // If send OK save to eeprom. DOES NOT ALWAYS RETURN 'OK'!?
|
// if (sendRoute(msg)) saveState(EEPROM_LATEST_NODE_ADDRESS,newNodeID); // If send OK save to eeprom. DOES NOT ALWAYS RETURN 'OK'!?
|
||||||
} else if (mGetCommand(msg)!=0) {
|
} else if (mGetCommand(msg)!=0) {
|
||||||
if (mGetCommand(msg)==3) msg.type=msg.type+38;
|
if (mGetCommand(msg)==3) msg.type=msg.type+38;
|
||||||
buffer[buffsize++] = MQTTPUBLISH << 4; // 0:
|
buffer[buffsize++] = MQTTPUBLISH << 4; // 0:
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ version 2 as published by the Free Software Foundation.
|
|||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
//#define TCPDUMP // Dump TCP packages.
|
#define TCPDUMP // Dump TCP packages.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MQTT_FIRST_SENSORID 20 // If you want manually configured nodes below this value. 255 = Disable
|
#define MQTT_FIRST_SENSORID 20 // If you want manually configured nodes below this value. 255 = Disable
|
||||||
@@ -54,8 +54,6 @@ version 2 as published by the Free Software Foundation.
|
|||||||
#define MQTTQOS1 (1 << 1)
|
#define MQTTQOS1 (1 << 1)
|
||||||
#define MQTTQOS2 (2 << 1)
|
#define MQTTQOS2 (2 << 1)
|
||||||
|
|
||||||
#define MyTestVar F("Test")
|
|
||||||
|
|
||||||
class MyMQTT :
|
class MyMQTT :
|
||||||
public MySensor {
|
public MySensor {
|
||||||
public:
|
public:
|
||||||
@@ -91,4 +89,3 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user