diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index 05bf7bd..ab25925 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -9,6 +9,7 @@ on: - "CMakeLists.txt" - "cmake/**" - "examples/**.cpp" + - "examples/**CMakeLists.txt" - "!**Makefile" # old build system is not tested in this workflow - ".github/workflows/build_linux.yml" push: @@ -19,6 +20,7 @@ on: - "CMakeLists.txt" - "cmake/**" - "examples/**.cpp" + - "examples/**CMakeLists.txt" - "!**Makefile" # old build system is not tested in this workflow - ".github/workflows/build_linux.yml" release: diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index de288e1..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "python.formatting.provider": "black" -} \ No newline at end of file diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index daacb69..0a19467 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -44,15 +44,13 @@ elseif("${RF24_DRIVER}" STREQUAL "wiringPi") else() message(FATAL "Lib ${RF24_DRIVER} not found.") endif() -elseif(NOT "${LibPIGPIO}" STREQUAL "LibPIGPIO-NOTFOUND" AND NOT DEFINED RF24_NO_INTERRUPT) - if(NOT "${RF24_DRIVER}" STREQUAL "pigpio") - message(STATUS "linking to ${LibPIGPIO} for interrupt support") - else() +elseif(NOT "${RF24_DRIVER}" STREQUAL "pigpio") + if(NOT "${LibPIGPIO}" STREQUAL "LibPIGPIO-NOTFOUND") message(STATUS "linking to ${LibPIGPIO}") + list(APPEND linked_libs ${LibPIGPIO}) + else() + message(FATAL "lib ${RF24_DRIVER} not found.") endif() - list(APPEND linked_libs ${LibPIGPIO}) -else() - message(STATUS "Disabling IRQ pin support") endif() set(example RF24GatewayNode) @@ -63,24 +61,12 @@ add_executable(${example} ${example}.cpp) target_link_libraries(${example} PUBLIC ${linked_libs} ) -if("${LibPIGPIO}" STREQUAL "LibPIGPIO-NOTFOUND" OR DEFINED RF24_NO_INTERRUPT) - target_compile_definitions(${example} PUBLIC RF24_NO_INTERRUPT) -endif() - -if("${RF24_DRIVER}" STREQUAL "MRAA" OR "${RF24_DRIVER}" STREQUAL "wiringPi") - message(STATUS "skipping gwNodeInt example because it is incompatible with selected driver") -elseif(NOT "${LibPIGPIO}" STREQUAL "LibPIGPIO-NOTFOUND" AND NOT DEFINED RF24_NO_INTERRUPT) - add_subdirectory(gwNodeInt) -endif() +add_subdirectory(gwNodeInt) add_subdirectory(addons/Sniffer) include(../cmake/enableNcursesExample.cmake) if(BUILD_NCURSES_EXAMPLE) add_subdirectory(ncurses) - if("${RF24_DRIVER}" STREQUAL "MRAA" OR "${RF24_DRIVER}" STREQUAL "wiringPi") - message(STATUS "skipping ncursesInt example because it is incompatible with selected driver") - elseif(NOT "${LibPIGPIO}" STREQUAL "LibPIGPIO-NOTFOUND" AND NOT DEFINED RF24_NO_INTERRUPT) - add_subdirectory(ncursesInt) - endif() + add_subdirectory(ncursesInt) endif() diff --git a/examples/addons/Sniffer/CMakeLists.txt b/examples/addons/Sniffer/CMakeLists.txt index 2138fe6..30d7cc4 100644 --- a/examples/addons/Sniffer/CMakeLists.txt +++ b/examples/addons/Sniffer/CMakeLists.txt @@ -7,6 +7,3 @@ add_executable(${example} ${example}.cpp) target_link_libraries(${example} PUBLIC ${linked_libs} ) -if("${LibPIGPIO}" STREQUAL "LibPIGPIO-NOTFOUND" OR DEFINED RF24_NO_INTERRUPT) - target_compile_definitions(${example} PUBLIC RF24_NO_INTERRUPT) -endif() diff --git a/examples/addons/mqttLogger.py b/examples/addons/mqttLogger.py index 682b3a2..d3e5bbc 100644 --- a/examples/addons/mqttLogger.py +++ b/examples/addons/mqttLogger.py @@ -10,13 +10,9 @@ RF24NetworkFrame frame = RF24NetworkFrame(header, buf, size); gw.sendUDP(mesh.getNodeID(header.from_node), frame); """ -import paho.mqtt.client as mqtt -import socket -try: #python 2 to 3 hack - unicode("") # all strings are unicode in python3 -except NameError: - unicode = str # does the same thing as python2's builtin unicode() +import socket +import paho.mqtt.client as mqtt ### Setup the MQTT host IP & topic to publish to mqttHost = "10.10.2.2" @@ -29,7 +25,6 @@ sock.bind(server_address) while True: - data, address = sock.recvfrom(2048) print("received {} bytes from {}".format(len(data), address)) @@ -40,6 +35,6 @@ # TODO: Sort, Display and Analyze the data mqttc = mqtt.Client() mqttc.connect(mqttHost, 1883) - data = unicode(data, errors="replace") + data = data.decode(errors="replace") mqttc.publish(topic, data) mqttc.loop(2) diff --git a/examples/clients/PythonClient/pyClient.py b/examples/clients/PythonClient/pyClient.py index e49d19c..6f26bca 100644 --- a/examples/clients/PythonClient/pyClient.py +++ b/examples/clients/PythonClient/pyClient.py @@ -5,10 +5,11 @@ Turn a light on in the evening and off in the morning according to a schedule """ -import urllib2 from datetime import datetime -import time import syslog +import time +from urllib.error import HTTPError, URLError +from urllib.request import urlopen ######### Configuration ######### @@ -23,21 +24,19 @@ lightState = 2 while 1: - # Get the current hour currentHour = datetime.now().hour # Check to see if the system should be off if (currentHour >= scheduleON or currentHour < scheduleOFF) and lightState != 1: - result = 0 # Connect to our sensor at 10.10.3.44:1000/ and request OFF try: - response = urllib2.urlopen(requestOFF, None, 15) # 15 second time-out + response = urlopen(requestOFF, None, 15) # 15 second time-out result = response.getcode() - except urllib2.HTTPError, e: + except HTTPError as e: syslog.syslog("HTTPError = " + str(e.code)) - except urllib2.URLError, e: + except URLError as e: syslog.syslog("URLError = " + str(e.reason)) except Exception: import traceback @@ -54,11 +53,11 @@ result = 0 try: - response = urllib2.urlopen(requestON, None, 15) # 15 second time-out + response = urlopen(requestON, None, 15) # 15 second time-out result = response.getcode() - except urllib2.HTTPError, e: + except HTTPError as e: syslog.syslog("HTTPError = " + str(e.code)) - except urllib2.URLError, e: + except URLError as e: syslog.syslog("URLError = " + str(e.reason)) except Exception: import traceback diff --git a/examples/ncurses/CMakeLists.txt b/examples/ncurses/CMakeLists.txt index 3ee2513..68e6e22 100644 --- a/examples/ncurses/CMakeLists.txt +++ b/examples/ncurses/CMakeLists.txt @@ -12,6 +12,3 @@ target_link_libraries(${example} PUBLIC ${linked_libs} ${CURSES_LIBRARIES} ) -if("${LibPIGPIO}" STREQUAL "LibPIGPIO-NOTFOUND" OR DEFINED RF24_NO_INTERRUPT) - target_compile_definitions(${example} PUBLIC RF24_NO_INTERRUPT) -endif()