Skip to content

Commit c6ef4fb

Browse files
committed
Changed MySensors Serial, Added MySensors TCP, starting with MQTT implementation, hashing passwords, openzwave update
1 parent 1e4b44d commit c6ef4fb

File tree

109 files changed

+22402
-506
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+22402
-506
lines changed

CMakeLists.txt

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ get_directory_property (CMAKE_LUA_INCLUDES DIRECTORY lua
66
get_directory_property (CMAKE_LUA_LIBRARIES DIRECTORY lua
77
DEFINITION LUA_LIBRARIES)
88

9+
add_subdirectory (MQTT)
10+
get_directory_property (CMAKE_MQTT_INCLUDES DIRECTORY MQTT
11+
DEFINITION MQTT_INCLUDE_DIRS)
12+
get_directory_property (CMAKE_MQTT_LIBRARIES DIRECTORY MQTT
13+
DEFINITION MQTT_LIBRARIES)
14+
915
project(domoticz)
1016

1117
SET(EXECUTABLE_OUTPUT_PATH "" CACHE INTERNAL
@@ -185,8 +191,10 @@ hardware/ICYThermostat.cpp
185191
hardware/Limitless.cpp
186192
hardware/Meteostick.cpp
187193
hardware/MochadTCP.cpp
194+
hardware/MQTT.cpp
188195
hardware/MySensorsBase.cpp
189196
hardware/MySensorsSerial.cpp
197+
hardware/MySensorsTCP.cpp
190198
hardware/OpenZWave.cpp
191199
hardware/openzwave/control_panel/ozwcp.cpp
192200
hardware/openzwave/control_panel/zwavelib.cpp
@@ -295,6 +303,9 @@ else()
295303
MESSAGE(STATUS "==== LibUSB not found, support for TE923/Voltcraft disabled!")
296304
ENDIF(LIBUSB_FOUND)
297305

306+
#
307+
# Find MD5/RMD160/SHA library
308+
#
298309
find_path(OPENSSL_INCLUDE_DIR openssl/ssl.h)
299310
find_library(OPENSSL_LIBRARY ssl)
300311
if(NOT OPENSSL_INCLUDE_DIR)
@@ -307,6 +318,19 @@ else()
307318
target_link_libraries(domoticz ${OPENSSL_LIBRARY})
308319
endif()
309320

321+
FIND_LIBRARY(CRYPTO_LIBRARY NAMES crypto)
322+
IF(CRYPTO_LIBRARY)
323+
MESSAGE(STATUS "Crypto library found at: ${CRYPTO_LIBRARY}")
324+
target_link_libraries(domoticz ${CRYPTO_LIBRARY})
325+
ELSE(CRYPTO_LIBRARY)
326+
IF(NOT OPENSSL_FOUND)
327+
FIND_LIBRARY(MD_LIBRARY NAMES md)
328+
IF(MD_LIBRARY)
329+
LIST(APPEND ADDITIONAL_LIBS ${MD_LIBRARY})
330+
ENDIF(MD_LIBRARY)
331+
ENDIF(NOT OPENSSL_FOUND)
332+
ENDIF(CRYPTO_LIBRARY)
333+
310334
## support lua popen on Linux platforms
311335
#IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
312336
# SET(OperatingSystem "Linux")
@@ -367,7 +391,7 @@ else()
367391
message(STATUS "Not building on Raspberry Pi. GPIO support disabled.")
368392
ENDIF(RaspberryPi)
369393

370-
target_link_libraries(domoticz ${Boost_LIBRARIES} ${SQLITE3_LIBRARY} ${ZLIB_LIBRARIES} ${CURL_LIBRARIES} pthread lua ${CMAKE_DL_LIBS})
394+
target_link_libraries(domoticz ${Boost_LIBRARIES} ${SQLITE3_LIBRARY} ${ZLIB_LIBRARIES} ${CURL_LIBRARIES} pthread lua mqtt ${CMAKE_DL_LIBS})
371395

372396
ADD_PRECOMPILED_HEADER(domoticz "main/stdafx.h")
373397

Config/manufacturer_specific.xml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,29 @@
3636
<Product type="0000" id="0000" name="Z-Wave Extender"/>
3737
<Product type="0001" id="0001" name="Z-Stick"/>
3838
<Product type="0001" id="0002" name="Z-Stick S2"/>
39-
<Product type="0002" id="0001" name="Z-Stick S2"/>
4039
<Product type="0001" id="0003" name="Minimote" config="aeon_labs/minimote.xml"/>
40+
<Product type="0001" id="0007" name="Z-Stick S2 Lite"/>
41+
<Product type="0001" id="0016" name="Key Fob" config="aeon_labs/keyfob.xml"/>
42+
<Product type="0002" id="0001" name="Z-Stick S2"/>
4143
<Product type="0002" id="0004" name="Door/Window Sensor" config="aeon_labs/doorwindow.xml"/>
42-
<Product type="0002" id="001d" name="Door/Window Sensor" config="aeon_labs/doorwindow.xml"/>
4344
<Product type="0002" id="0005" name="Multi Sensor" config="aeon_labs/alms.xml"/>
44-
<Product type="0003" id="0006" name="Smart Energy Switch" config="aeon_labs/ses.xml"/>
45-
<Product type="0003" id="004b" name="Smart Energy Switch v2" config="aeon_labs/ses2.xml"/>
46-
<Product type="0001" id="0007" name="Z-Stick S2 Lite"/>
47-
<Product type="0003" id="0008" name="Smart Energy Illuminator"/>
4845
<Product type="0002" id="0009" name="Home Energy Meter" config="aeon_labs/hem.xml"/>
4946
<Product type="0002" id="001c" name="Home Energy Meter G2" config="aeon_labs/hemg2.xml"/>
47+
<Product type="0002" id="001d" name="Door/Window Sensor" config="aeon_labs/doorwindow.xml"/>
48+
<Product type="0002" id="0036" name="Recessed Door Sensor" config="aeon_labs/recessed_doorsensor.xml"/>
49+
<Product type="0003" id="0006" name="Smart Energy Switch" config="aeon_labs/ses.xml"/>
50+
<Product type="0003" id="0008" name="Smart Energy Illuminator"/>
5051
<Product type="0003" id="000a" name="Smart Energy 220V Utility Switch"/>
5152
<Product type="0003" id="000b" name="Smart Energy Strip"/>
5253
<Product type="0003" id="000c" name="Micro Smart Energy Switch"/>
5354
<Product type="0003" id="000d" name="Micro Smart Energy Illuminator"/>
54-
<Product type="0003" id="001b" name="Micro Smart Energy Illuminator G2"/>
5555
<Product type="0003" id="000e" name="Micro Motor Controller"/>
56+
<Product type="0003" id="0011" name="Micro Double Switch" />
5657
<Product type="0003" id="001a" name="Micro Switch (2nd Edition)"/>
58+
<Product type="0003" id="001b" name="Micro Smart Energy Illuminator G2"/>
5759
<Product type="0003" id="0012" name="Micro Smart Energy Switch G2" config="aeon_labs/ses.xml" />
58-
<Product type="0001" id="0016" name="Key Fob" config="aeon_labs/keyfob.xml"/>
59-
<Product type="0003" id="0011" name="Micro Double Switch" />
60-
<Product type="0002" id="0036" name="Recessed Door Sensor" config="aeon_labs/recessed_doorsensor.xml"/>
60+
<Product type="0003" id="0013" name="Micro Smart Energy Dimmer"/>
61+
<Product type="0003" id="004b" name="Smart Energy Switch v2" config="aeon_labs/ses2.xml"/>
6162
<Product type="0004" id="0025" name="Z-Wave Repeater"/>
6263
<Product type="0004" id="0050" name="Siren Gen5"/>
6364
</Manufacturer>
@@ -490,6 +491,7 @@
490491
<Product type="0002" id="0002" name="ZMNHAA2 Flush 1 Relay" config="qubino/ZMNHAA2.xml"/>
491492
<Product type="0003" id="0002" name="ZMNHCA2 Flush Shutter" config="qubino/ZMNHCA2.xml"/>
492493
<Product type="0004" id="0001" name="ZMNHJA2 Flush Dimmer Fil Pilote" config="qubino/ZMNHJA2.xml"/>
494+
<Product type="0005" id="0001" name="ZMNHIA2 Flush on/off thermostat" config="qubino/ZMNHIA2.xml"/>
493495
</Manufacturer>
494496
<Manufacturer id="0130" name="Quby">
495497
<Product type="0001" id="0001" name="Energy Management System"/>
@@ -537,6 +539,9 @@
537539
<Manufacturer id="0151" name="Sercomm">
538540
<Product type="0002" id="0001" name="SW-CLP01-EU Clamp Power Meter"/>
539541
</Manufacturer>
542+
<Manufacturer id="0000" name="Sigma Designs">
543+
<Product type="0001" id="0001" name="UZB Z-Wave USB Adapter"/>
544+
</Manufacturer>
540545
<Manufacturer id="0045" name="Sine Wireless">
541546
</Manufacturer>
542547
<Manufacturer id="0070" name="Smart Products">
@@ -607,9 +612,6 @@
607612
</Manufacturer>
608613
<Manufacturer id="004e" name="Zdata">
609614
</Manufacturer>
610-
<Manufacturer id="0000" name="Zensys">
611-
<Product type="0001" id="0001" name="Controller"/>
612-
</Manufacturer>
613615
<Manufacturer id="0109" name="Vision">
614616
<Product type="1001" id="0101" name="ZU1401 Z-Wave USB Stick"/>
615617
<Product type="2001" id="0101" name="ZD2102 Door/Window Sensor"/>

Config/qubino/ZMNHIA2.xml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Product xmlns='http://code.google.com/p/open-zwave/'>
3+
4+
<!-- Qubino: ZMNHIA2 Flush On Off thermostat -->
5+
6+
<!-- Configuration -->
7+
<CommandClass id="112">
8+
<Value type="list" genre="config" instance="1" index="1" label="Input 1 switch type" size="1" min="0" max="1" value="1">
9+
<Help/>
10+
<Item label="Mono-stable" value="0"/>
11+
<Item label="Bi-stable" value="1"/>
12+
</Value>
13+
14+
<Value type="list" genre="config" instance="1" index="2" label="Input 2 contact type" size="1" min="0" max="1" value="0">
15+
<Help/>
16+
<Item label="NO (normaly open) input type" value="0"/>
17+
<Item label="NC (normaly close) input type" value="1"/>
18+
</Value>
19+
20+
<Value type="list" genre="config" instance="1" index="3" label="Input 3 contact type" size="1" min="0" max="1" value="0">
21+
<Help/>
22+
<Item label="NO (normaly open) input type" value="0"/>
23+
<Item label="NC (normaly close) input type" value="1"/>
24+
</Value>
25+
26+
<Value type="list" genre="config" instance="1" index="10" label="Activate / deactivate functions ALL ON/ALL OFF" size="1" min="0" max="255" value="255">
27+
<Help>Flush on off thermostat module responds to commands ALL ON / ALL OFF that may be sent by the main controller or by other controller belonging to the system.</Help>
28+
<Item label="ALL ON active, ALL OFF active" value="255" />
29+
<Item label="ALL ON is not active ALL OFF is not active" value="0" />
30+
<Item label="ALL ON is not active ALL OFF active" value="1" />
31+
<Item label="ALL ON active ALL OFF is not active" value="2" />
32+
</Value>
33+
34+
<Value type="list" genre="config" instance="1" index="30" label="Saving the state of the relay after a power failure" size="1" min="0" max="1" value="0">
35+
<Help/>
36+
<Item label="Flush dimmer module saves its state before power failure (it returns to the last position saved before a power failure)" value="0" />
37+
<Item label="Flush dimmer module does not save the state after a power failure, it returns to off position" value="1" />
38+
</Value>
39+
40+
<Value type="byte" genre="config" instance="1" index="40" label="Power reporting in Watts on power change" size="1" min="0" max="100" value="5">
41+
<Help>Set value from 0 - 100 (0% - 100%). 0 - Reporting Disabled. 1 - 100 = 1% - 100% Reporting enabled. Power report is send (push) only when actual power in Watts in real time change for more than set percentage comparing to previous actual power in Watts, step is 1%. Default value 5</Help>
42+
</Value>
43+
44+
<Value type="short" genre="config" instance="1" index="42" label="Power reporting in Watts by time interval" min="0" max="65535" value="300">
45+
<Help>Set value means time interval (0 - 65535) in seconds, when power report is send. 0 - Reporting Disabled. 1 - 65535 = 1 second - 65535 seconds. Reporting enabled. Power report is send with time interval set by entered value. Default value 300 (power report in Watts is send each 300s)</Help>
46+
</Value>
47+
48+
<Value type="byte" genre="config" instance="1" index="43" label="Hysteresis On" size="1" min="0" max="255" value="132">
49+
<Help>This parameter defines temperature min difference between real measured temperature and set-point temperature to turn heating on. The parameter can be set from 0 to 255 where 0 to 128 means from 0.0 °C to 12.8 °C and from 129 to 255 means from - 0.0 °C to -12.8 °C.</Help>
50+
</Value>
51+
52+
<Value type="byte" genre="config" instance="1" index="44" label="Hysteresis Off" size="1" min="0" max="255" value="132">
53+
<Help>This parameter defines temperature min difference between real measured temperature and set-point temperature to turn heating off. The parameter can be set from 0 to 255 where 0 to 128 means from 0.0 °C to 12.8 °C and from 129 to 255 means from - 0.0 °C to -12.8 °C.</Help>
54+
</Value>
55+
56+
<Value type="byte" genre="config" instance="1" index="45" label="Antifreeze" size="1" min="0" max="255" value="50">
57+
<Help>Set value means at which temperature the heating will be turned on even if the thermostat was manually set to off. The parameter can be set from 0 to 255 where 0 to 128 means from 0.0 °C to 12.8 °C and from 129 to 255 means from - 0.0 °C to -12.8 °C.</Help>
58+
</Value>
59+
60+
<Value type="list" genre="config" instance="1" index="63" label="Switch selection" size="1" min="0" max="1" value="1">
61+
<Help>Set value means the type of the heating device that is connected to the relay output. The heating device type can be normally open (NO) or normally close (NC).</Help>
62+
<Item label="NO (normaly open) input type" value="0"/>
63+
<Item label="NC (normaly close) input type" value="1"/>
64+
</Value>
65+
66+
</CommandClass>
67+
68+
<!-- Association Groups -->
69+
<CommandClass id="133">
70+
<Associations num_groups="5">
71+
<Group index="1" max_associations="5" label="Multilevel" auto="false"/>
72+
<Group index="2" max_associations="5" label="Input I1 state" auto="false"/>
73+
<Group index="3" max_associations="5" label="Input I2 state" auto="false"/>
74+
<Group index="4" max_associations="5" label="Input I3 state" auto="false"/>
75+
<Group index="5" max_associations="1" label="Default reporting" auto="true"/>
76+
</Associations>
77+
</CommandClass>
78+
79+
<!-- Remove COMMAND_CLASS_BASIC -->
80+
<CommandClass id="32" action="remove" />
81+
82+
<!-- Map endpoints to instances -->
83+
<CommandClass id="96" mapping="endpoints" />
84+
85+
</Product>

MQTT/CMakeLists.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
cmake_minimum_required(VERSION 2.6)
2+
3+
project (MQTT C)
4+
5+
# used bypackages that wish to link against lua
6+
SET(MQTT_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}")
7+
SET(MQTT_LIBRARIES mqtt)
8+
9+
SET(LIBRARY_OUTPUT_PATH "" CACHE INTERNAL
10+
"Where to put the libraries for MQTT"
11+
)
12+
13+
SET(CORE Clients.c Heap.c LinkedList.c Log.c Messages.c MQTTPacket.c MQTTPacketOut.c MQTTPersistence.c MQTTPersistenceDefault.c MQTTProtocolClient.c MQTTProtocolOut.c MQTTVersion.c
14+
Socket.c SocketBuffer.c SSLSocket.c StackTrace.c Thread.c Tree.c utf-8.c)
15+
16+
SET (LIB MQTTAsync.c)
17+
18+
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
19+
SET(OperatingSystem "Linux")
20+
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
21+
22+
ADD_LIBRARY(mqtt ${LIB} ${CORE})

MQTT/Clients.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2009, 2013 IBM Corp.
3+
*
4+
* All rights reserved. This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License v1.0
6+
* and Eclipse Distribution License v1.0 which accompany this distribution.
7+
*
8+
* The Eclipse Public License is available at
9+
* http://www.eclipse.org/legal/epl-v10.html
10+
* and the Eclipse Distribution License is available at
11+
* http://www.eclipse.org/org/documents/edl-v10.php.
12+
*
13+
* Contributors:
14+
* Ian Craggs - initial API and implementation and/or initial documentation
15+
* Ian Craggs - add SSL support
16+
*******************************************************************************/
17+
18+
/**
19+
* @file
20+
* \brief functions which apply to client structures
21+
* */
22+
23+
#include "Clients.h"
24+
25+
#include <string.h>
26+
#include <stdio.h>
27+
28+
29+
/**
30+
* List callback function for comparing clients by clientid
31+
* @param a first integer value
32+
* @param b second integer value
33+
* @return boolean indicating whether a and b are equal
34+
*/
35+
int clientIDCompare(void* a, void* b)
36+
{
37+
Clients* client = (Clients*)a;
38+
/*printf("comparing clientdIDs %s with %s\n", client->clientID, (char*)b);*/
39+
return strcmp(client->clientID, (char*)b) == 0;
40+
}
41+
42+
43+
/**
44+
* List callback function for comparing clients by socket
45+
* @param a first integer value
46+
* @param b second integer value
47+
* @return boolean indicating whether a and b are equal
48+
*/
49+
int clientSocketCompare(void* a, void* b)
50+
{
51+
Clients* client = (Clients*)a;
52+
/*printf("comparing %d with %d\n", (char*)a, (char*)b); */
53+
return client->net.socket == *(int*)b;
54+
}

0 commit comments

Comments
 (0)