Merge branch 'development' into development
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
Arduino
|
||||
=======
|
||||
|
||||
MySensors Arduino Library v1.5
|
||||
MySensors Arduino Library v2.0.0-beta
|
||||
|
||||
Please visit www.mysensors.org for more information
|
||||
|
||||
|
||||
@@ -371,7 +371,17 @@
|
||||
|
||||
/**
|
||||
* @def MY_RF24_CHANNEL
|
||||
* @brief RF channel for the sensor net, 0-127.
|
||||
* @brief RF channel for the sensor net, 0-125.
|
||||
* Frequence: 2400 Mhz - 2525 Mhz Channels: 126
|
||||
* http://www.mysensors.org/radio/nRF24L01Plus.pdf
|
||||
* 0 => 2400 Mhz (RF24 channel 1)
|
||||
* 1 => 2401 Mhz (RF24 channel 2)
|
||||
* 76 => 2476 Mhz (RF24 channel 77)
|
||||
* 83 => 2483 Mhz (RF24 channel 84)
|
||||
* 124 => 2524 Mhz (RF24 channel 125)
|
||||
* 125 => 2525 Mhz (RF24 channel 126)
|
||||
* In some countries there might be limitations, in Germany for example only the range 2400,0 - 2483,5 Mhz is allowed
|
||||
* http://www.bundesnetzagentur.de/SharedDocs/Downloads/DE/Sachgebiete/Telekommunikation/Unternehmen_Institutionen/Frequenzen/Allgemeinzuteilungen/2013_10_WLAN_2,4GHz_pdf.pdf
|
||||
*/
|
||||
#ifndef MY_RF24_CHANNEL
|
||||
#define MY_RF24_CHANNEL 76
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
#endif
|
||||
|
||||
// Not necessary to include blinking feature if no LED's are defined!
|
||||
#if defined(MY_LEDS_BLINKING_FEATURE) && !defined(MY_DEFAULT_RX_LED_PIN) && !defined(MU_DEFAULT_TX_LED_PIN) && !defined(MY_ERR_LED_PIN)
|
||||
#if defined(MY_LEDS_BLINKING_FEATURE) && !defined(MY_DEFAULT_RX_LED_PIN) && !defined(MY_DEFAULT_TX_LED_PIN) && !defined(MY_ERR_LED_PIN)
|
||||
#undef MY_LEDS_BLINKING_FEATURE
|
||||
#endif
|
||||
|
||||
@@ -179,9 +179,10 @@
|
||||
#endif
|
||||
// GATEWAY - COMMON FUNCTIONS
|
||||
// We only support MQTT Client using W5100 and ESP8266 at the moment
|
||||
#if !defined(MY_CONTROLLER_IP_ADDRESS)
|
||||
#error You must specify MY_CONTROLLER_IP_ADDRESS (MQTT broker address)
|
||||
#if !(defined(MY_CONTROLLER_URL_ADDRESS) || defined(MY_CONTROLLER_IP_ADDRESS))
|
||||
#error You must specify MY_CONTROLLER_IP_ADDRESS or MY_CONTROLLER_URL_ADDRESS
|
||||
#endif
|
||||
|
||||
#if !defined(MY_MQTT_PUBLISH_TOPIC_PREFIX)
|
||||
#error You must specify a topic publish prefix MY_MQTT_PUBLISH_TOPIC_PREFIX for this MQTT client
|
||||
#endif
|
||||
|
||||
@@ -156,7 +156,11 @@ bool gatewayTransportSend(MyMessage &message)
|
||||
ret = _ethernetServer.endPacket();
|
||||
#else
|
||||
EthernetClient client;
|
||||
if (client.connect(_ethernetControllerIP, MY_PORT)) {
|
||||
#if defined(MY_CONTROLLER_URL_ADDRESS)
|
||||
if (client.connect(MY_CONTROLLER_URL_ADDRESS, MY_PORT)) {
|
||||
#else
|
||||
if (client.connect(_ethernetControllerIP, MY_PORT)) {
|
||||
#endif
|
||||
client.write(_ethernetMsg, strlen(_ethernetMsg));
|
||||
client.stop();
|
||||
}
|
||||
|
||||
@@ -28,12 +28,16 @@
|
||||
uint8_t protocolH2i(char c);
|
||||
|
||||
|
||||
IPAddress _brokerIp(MY_CONTROLLER_IP_ADDRESS);
|
||||
#if defined MY_CONTROLLER_IP_ADDRESS
|
||||
IPAddress _brokerIp(MY_CONTROLLER_IP_ADDRESS);
|
||||
#endif
|
||||
|
||||
#if defined(MY_GATEWAY_ESP8266)
|
||||
#define EthernetClient WiFiClient
|
||||
IPAddress _gatewayIp(MY_IP_GATEWAY_ADDRESS);
|
||||
IPAddress _subnetIp(MY_IP_SUBNET_ADDRESS);
|
||||
#if defined(MY_IP_ADDRESS)
|
||||
IPAddress _gatewayIp(MY_IP_GATEWAY_ADDRESS);
|
||||
IPAddress _subnetIp(MY_IP_SUBNET_ADDRESS);
|
||||
#endif
|
||||
#else
|
||||
byte _clientMAC[] = { MY_MAC_ADDRESS };
|
||||
#endif
|
||||
@@ -44,6 +48,7 @@ IPAddress _brokerIp(MY_CONTROLLER_IP_ADDRESS);
|
||||
|
||||
EthernetClient _ethClient;
|
||||
PubSubClient _client(_ethClient);
|
||||
bool _connecting = true;
|
||||
bool _available = false;
|
||||
char _convBuffer[MAX_PAYLOAD*2+1];
|
||||
char _fmtBuffer[MY_GATEWAY_MAX_SEND_LENGTH];
|
||||
@@ -150,7 +155,13 @@ bool reconnectMQTT() {
|
||||
}
|
||||
|
||||
bool gatewayTransportInit() {
|
||||
_client.setServer(_brokerIp, MY_PORT);
|
||||
_connecting = true;
|
||||
#if defined(MY_CONTROLLER_IP_ADDRESS)
|
||||
_client.setServer(_brokerIp, MY_PORT);
|
||||
#else
|
||||
_client.setServer(MY_CONTROLLER_URL_ADDRESS, MY_PORT);
|
||||
#endif
|
||||
|
||||
_client.setCallback(incomingMQTT);
|
||||
|
||||
#if defined(MY_GATEWAY_ESP8266)
|
||||
@@ -164,30 +175,42 @@ bool gatewayTransportInit() {
|
||||
MY_SERIALDEVICE.print(".");
|
||||
yield();
|
||||
}
|
||||
MY_SERIALDEVICE.print(F("IP: "));
|
||||
MY_SERIALDEVICE.print("IP: ");
|
||||
MY_SERIALDEVICE.println(WiFi.localIP());
|
||||
#else
|
||||
#ifdef MY_IP_ADDRESS
|
||||
Ethernet.begin(_clientMAC, _clientIp);
|
||||
MY_SERIALDEVICE.print(F("IP: "));
|
||||
MY_SERIALDEVICE.println(Ethernet.localIP());
|
||||
#else
|
||||
// Get IP address from DHCP
|
||||
Ethernet.begin(_clientMAC);
|
||||
MY_SERIALDEVICE.print(F("IP: "));
|
||||
if (!Ethernet.begin(_clientMAC))
|
||||
{
|
||||
MY_SERIALDEVICE.print("DHCP FAILURE...");
|
||||
_connecting = false;
|
||||
return false;
|
||||
}
|
||||
MY_SERIALDEVICE.print("IP: ");
|
||||
MY_SERIALDEVICE.println(Ethernet.localIP());
|
||||
#endif /* IP_ADDRESS_DHCP */
|
||||
#endif
|
||||
|
||||
// give the Ethernet interface a second to initialize
|
||||
// TODO: use HW delay
|
||||
wait(1000);
|
||||
#endif
|
||||
_connecting = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool gatewayTransportAvailable() {
|
||||
if (_connecting)
|
||||
return false;
|
||||
|
||||
//keep lease on dhcp address
|
||||
//Ethernet.maintain();
|
||||
if (!_client.connected()) {
|
||||
reconnectMQTT();
|
||||
//reinitialise client
|
||||
if (gatewayTransportInit())
|
||||
reconnectMQTT();
|
||||
return false;
|
||||
}
|
||||
_client.loop();
|
||||
|
||||
@@ -123,8 +123,6 @@ void _begin() {
|
||||
#elif defined(MY_RADIO_FEATURE)
|
||||
// Read settings from eeprom
|
||||
hwReadConfigBlock((void*)&_nc, (void*)EEPROM_NODE_ID_ADDRESS, sizeof(NodeConfig));
|
||||
// Read latest received controller configuration from EEPROM
|
||||
hwReadConfigBlock((void*)&_cc, (void*)EEPROM_CONTROLLER_CONFIG_ADDRESS, sizeof(ControllerConfig));
|
||||
#ifdef MY_OTA_FIRMWARE_FEATURE
|
||||
// Read firmware config from EEPROM, i.e. type, version, CRC, blocks
|
||||
hwReadConfigBlock((void*)&_fc, (void*)EEPROM_FIRMWARE_TYPE_ADDRESS, sizeof(NodeFirmwareConfig));
|
||||
|
||||
@@ -388,7 +388,7 @@ RF24::RF24(uint8_t _cepin, uint8_t _cspin):
|
||||
|
||||
void RF24::setChannel(uint8_t channel)
|
||||
{
|
||||
const uint8_t max_channel = 127;
|
||||
const uint8_t max_channel = 125;
|
||||
write_register(RF_CH,min(channel,max_channel));
|
||||
}
|
||||
|
||||
|
||||
@@ -601,7 +601,7 @@ public:
|
||||
/**
|
||||
* Set RF communication channel
|
||||
*
|
||||
* @param channel Which RF channel to communicate on, 0-127
|
||||
* @param channel Which RF channel to communicate on, 0-125
|
||||
*/
|
||||
void setChannel(uint8_t channel);
|
||||
|
||||
|
||||
@@ -103,8 +103,8 @@
|
||||
#define MY_IP_GATEWAY_ADDRESS 192,168,178,1
|
||||
#define MY_IP_SUBNET_ADDRESS 255,255,255,0
|
||||
|
||||
|
||||
// MQTT broker ip address.
|
||||
// MQTT broker ip address or url. Define one or the other.
|
||||
//#define MY_CONTROLLER_URL_ADDRESS "m20.cloudmqtt.com"
|
||||
#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 68
|
||||
|
||||
// The MQTT broker port to to open
|
||||
|
||||
Reference in New Issue
Block a user