├── .gitattributes ├── .gitignore ├── .gitmodules ├── .vscode ├── c_cpp_properties.json └── settings.json ├── README.md ├── bluetooth ├── ble.py ├── readme.md ├── test.py └── test.pyc ├── config ├── README.md ├── boards.json ├── grafana │ ├── README.md │ ├── dashboards │ │ ├── Environment Sensors-1529829618258.json │ │ ├── Home Sensors-1514049986511.json │ │ ├── Home Sensors-1526927476465.json │ │ ├── Sensors status-1514050027519.json │ │ ├── Sensors status-1526927503671.json │ │ ├── nRF52 Batteries-1530295320930.json │ │ └── nRF52.json │ └── grafana.ini ├── influxdb │ ├── README.md │ ├── backup.sh │ ├── influxdb.conf │ └── restore.sh ├── mongodb │ ├── README.md │ └── mongodb.conf ├── nodes.json └── topics.json ├── dimmer ├── smt32_rfpio_firmware │ ├── .gitignore │ ├── .mbed │ ├── cf.bat │ ├── compile.bat │ ├── config_flash.bat │ ├── config_read.bat │ ├── crc.lib │ ├── debug.bat │ ├── debug_nano.json │ ├── develop_nano.json │ ├── dimm.lib │ ├── flash.bat │ ├── main.cpp │ ├── mbed-os.lib │ ├── mbed_settings.py │ └── nrf-mesh.lib └── stm32_rfnode_pulser │ ├── .gitignore │ ├── .mbed │ ├── cf.bat │ ├── compile.bat │ ├── develop_nano.json │ ├── flash.bat │ ├── main.cpp │ ├── mbed-os.lib │ └── mbed_settings.py ├── joystick_servo ├── .gitattributes ├── .gitignore ├── SConstruct ├── configfile.txt ├── main.cpp └── readme.md ├── listen.bat ├── nRF51_Beacon ├── .gitignore ├── Makefile ├── debug.bat ├── debug.jdebug ├── debug.jdebug.user ├── esb_low_power_ptx_gcc_nrf51_aa.ld ├── jlink │ ├── jlflash.jlink │ ├── power_off.jlink │ └── power_on.jlink ├── main.c ├── off.bat ├── on.bat ├── readme.md ├── sdk_config.h └── test.bat ├── nRF51_Sensors ├── .gitignore ├── .vscode │ └── settings.json ├── ap3216c │ ├── ap3216c.c │ └── ap3216c.h ├── beacon_project │ ├── .gitignore │ ├── Makefile │ ├── debug.jdebug │ ├── debug.jdebug.user │ └── main.c ├── bmp180 │ ├── README.md │ ├── bmp180.c │ ├── bmp180.h │ ├── bmp180_app.c │ └── bmp180_app.h ├── debug.bat ├── debug.jdebug ├── debug.jdebug.user ├── doc │ └── sensor_tag_sch_mpu6050.pdf ├── esb_low_power_ptx_gcc_nrf51_aa.ld ├── jlflash.jlink ├── mpu6050_app │ ├── mpu6050_app.c │ ├── mpu6050_app.h │ └── mpu60x0_register_map.h ├── readme.md ├── sdk_config.h ├── sensors_project │ ├── Makefile │ └── main.c └── twi_master_config.h ├── raspi_mesh_server ├── cpp_mqtt_ruler │ ├── .gitignore │ ├── SConstruct │ ├── configfile.txt │ ├── json.hpp │ ├── log.cpp │ ├── log.hpp │ ├── main.cpp │ ├── test │ │ ├── SConstruct │ │ └── main.cpp │ ├── utils.cpp │ └── utils.hpp ├── cpp_server │ ├── .gitignore │ ├── .vscode │ │ ├── c_cpp_properties.json │ │ └── settings.json │ ├── LICENSE.txt │ ├── SConstruct │ ├── help.txt │ ├── main.cpp │ └── test_logs │ │ ├── 2017.01.22 - client.txt │ │ └── 2017.01.22 - server.txt ├── hci_client │ ├── .gitignore │ ├── cfg.py │ ├── client.py │ ├── config.json │ ├── config_WassDell.json │ ├── mesh_wrapper.py │ ├── mqtt_wrapper.py │ └── serial_wrapper.py ├── py_net_gateway │ ├── .gitignore │ ├── README.md │ ├── cfg.py │ ├── config_milight.json │ ├── config_wemo.json │ ├── milight_gateway.py │ ├── rasp.py │ ├── raspi_status.py │ └── wemo_client.py ├── ruler │ ├── .gitignore │ ├── __pycache__ │ │ └── cfg.cpython-36.pyc │ ├── cfg.py │ ├── config.json │ ├── ruler.py │ └── rules.py └── web_d3js_viewer │ ├── .gitignore │ ├── MovingChartExample.js │ ├── StatusPanel.js │ ├── TimeChart.js │ ├── copy_to_rpi.bat │ ├── index.html │ ├── main.js │ ├── require.js │ └── websocket.js ├── smartio ├── .gitignore ├── README.md ├── client │ ├── cmd │ │ ├── frontend.js │ │ └── index.html │ ├── frontend.js │ ├── index.html │ └── ledStyles.css ├── firmware │ ├── stm32_dongle │ │ ├── .gitignore │ │ ├── .mbed │ │ ├── Servo.lib │ │ ├── cf.bat │ │ ├── compile.bat │ │ ├── crc.lib │ │ ├── develop_nano.json │ │ ├── flash.bat │ │ ├── main.cpp │ │ ├── mbed-os.lib │ │ ├── mbed_settings.py │ │ ├── nrf-mesh.lib │ │ └── safe-uart.lib │ └── stm32_rfio │ │ ├── .gitignore │ │ ├── .mbed │ │ ├── Servo.lib │ │ ├── cf.bat │ │ ├── compile.bat │ │ ├── crc.lib │ │ ├── develop_nano.json │ │ ├── flash.bat │ │ ├── main.cpp │ │ ├── mbed-os.lib │ │ ├── mbed_settings.py │ │ ├── nrf-mesh.lib │ │ └── safe-uart.lib ├── nodejs │ ├── package.json │ ├── readme.md │ └── serial_server.js └── picpp │ ├── .gitignore │ ├── SConstruct │ ├── configfile.txt │ └── main.cpp ├── stm32_rf_dongle ├── action │ ├── .gitignore │ ├── .mbed │ ├── APDS9960.lib │ ├── cf.bat │ ├── compile.bat │ ├── config_flash.bat │ ├── config_read.bat │ ├── crc.lib │ ├── develop_nano.json │ ├── flash.bat │ ├── main.cpp │ ├── mbed-os.lib │ ├── mbed_settings.py │ ├── nrf-mesh.lib │ ├── talk │ │ ├── talk.cpp │ │ └── talk.h │ └── ws2812B.lib ├── cyclic_ping │ ├── .gitignore │ ├── .mbed │ ├── cf.bat │ ├── compile.bat │ ├── crc.lib │ ├── develop_nano.json │ ├── flash.bat │ ├── main.cpp │ ├── mbed-os.lib │ ├── mbed_settings.py │ └── nrf-mesh.lib ├── host_controller_interface │ ├── .gitignore │ ├── .mbed │ ├── cf.bat │ ├── compile.bat │ ├── config_flash.bat │ ├── config_read.bat │ ├── crc.lib │ ├── develop_nano.json │ ├── flash.bat │ ├── main.cpp │ ├── mbed-os.lib │ ├── mbed_settings.py │ ├── nrf-mesh.lib │ └── safe-uart.lib ├── rf_bridge │ ├── .gitignore │ ├── .mbed │ ├── .vscode │ │ ├── c_cpp_properties.json │ │ └── settings.json │ ├── APDS9960.lib │ ├── BME280.lib │ ├── cf.bat │ ├── compile.bat │ ├── config_flash.bat │ ├── config_read.bat │ ├── crc.lib │ ├── develop_nano.json │ ├── flash.bat │ ├── main.cpp │ ├── mbed-os.lib │ ├── mbed_settings.py │ ├── nrf-mesh.lib │ └── ws2812B.lib ├── rf_heater │ ├── .gitignore │ ├── .mbed │ ├── cf.bat │ ├── compile.bat │ ├── config_flash.bat │ ├── config_read.bat │ ├── crc.lib │ ├── develop_nano.json │ ├── flash.bat │ ├── main.cpp │ ├── mbed-os.lib │ ├── mbed_settings.py │ └── nrf-mesh.lib ├── rf_sniffer │ ├── .gitignore │ ├── .mbed │ ├── cf.bat │ ├── compile.bat │ ├── config_flash.bat │ ├── config_read.bat │ ├── crc.lib │ ├── develop_nano.json │ ├── flash.bat │ ├── main.cpp │ ├── mbed-os.lib │ ├── mbed_settings.py │ ├── nrf-mesh.lib │ └── safe-uart.lib ├── rf_timing.txt └── rf_uart_interface │ ├── .gitignore │ ├── .mbed │ ├── cf.bat │ ├── compile.bat │ ├── config_flash.bat │ ├── config_read.bat │ ├── crc.lib │ ├── develop_nano.json │ ├── flash.bat │ ├── main.cpp │ ├── mbed-os.lib │ ├── mbed_settings.py │ ├── nrf-mesh.lib │ └── safe-uart.lib ├── tools ├── .gitignore ├── cfg.py ├── off.bat ├── on.bat ├── package.bat ├── private.bat ├── public.bat ├── read.bat ├── uicr.py ├── uicr_map.json └── write.bat └── webdash.graphml /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | 3 | # Windows image file caches 4 | Thumbs.db 5 | ehthumbs.db 6 | 7 | # Folder config file 8 | Desktop.ini 9 | 10 | # Recycle Bin used on file shares 11 | $RECYCLE.BIN/ 12 | 13 | # Windows Installer files 14 | *.cab 15 | *.msi 16 | *.msm 17 | *.msp 18 | 19 | # Windows shortcuts 20 | *.lnk 21 | 22 | # ========================= 23 | # Operating System Files 24 | # ========================= 25 | 26 | # OSX 27 | # ========================= 28 | 29 | .DS_Store 30 | .AppleDouble 31 | .LSOverride 32 | 33 | # Thumbnails 34 | ._* 35 | 36 | # Files that might appear in the root of a volume 37 | .DocumentRevisions-V100 38 | .fseventsd 39 | .Spotlight-V100 40 | .TemporaryItems 41 | .Trashes 42 | .VolumeIcon.icns 43 | 44 | # Directories potentially created on remote AFP share 45 | .AppleDB 46 | .AppleDesktop 47 | Network Trash Folder 48 | Temporary Items 49 | .apdisk 50 | *.hex 51 | *.map 52 | *.bak 53 | *.dep 54 | sensors_logger/rpi_app_uart_logger/ser 55 | sensors_logger/rpi_app_uart_logger/logs/ 56 | sensors_logger/rpi_app_uart_logger/logDays.txt 57 | *.CSV 58 | rfuart/lnkstm8s103f3.icf 59 | sensors_logger/nodejs_server/instant_db.js 60 | *.o 61 | sensors_logger/rpi_app_uart_logger/.sconsign.dblite 62 | sensors_logger/rpi_app_uart_logger/node_modules/ 63 | *.dblite 64 | sensors_logger/cpp_sensors_server/streamer 65 | joystick_servo/10_joy_Multi/joy 66 | rgb_leds/rgb_leds_rf/Debug/Obj/clock_led.pbi.cout 67 | mqtt/mqtt_test_cpp/mqtt_test 68 | joystick_servo/11_Joy_STM32_Protocol/joy 69 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "raspi_mesh_server/cpp_server/mesh_config"] 2 | path = raspi_mesh_server/cpp_server/mesh_config 3 | url = https://github.com/HomeSmartMesh/mesh_config.git 4 | [submodule "web_react"] 5 | path = web_react 6 | url = https://github.com/HomeSmartMesh/web_react.git 7 | [submodule "raspi_mesh_server/rf_gateway"] 8 | path = raspi_mesh_server/rf_gateway 9 | url = https://github.com/HomeSmartMesh/rf_gateway.git 10 | [submodule "raspi_mesh_server/iot_db"] 11 | path = raspi_mesh_server/iot_db 12 | url = https://github.com/HomeSmartMesh/iot_db.git 13 | [submodule "raspi_mesh_server/py_db_proxy"] 14 | path = raspi_mesh_server/py_db_proxy 15 | url = https://github.com/HomeSmartMesh/py_db_proxy.git 16 | [submodule "nRF51_Beacon/nRF5_SDK_12.3.0_prf"] 17 | path = nRF51_Beacon/nRF5_SDK_12.3.0_prf 18 | url = https://github.com/nRFMesh/nRF5_SDK_12.3.0_prf.git 19 | [submodule "nRF51_Sensors/nRF5_SDK_12.3.0_prf"] 20 | path = nRF51_Sensors/nRF5_SDK_12.3.0_prf 21 | url = https://github.com/nRFMesh/nRF5_SDK_12.3.0_prf.git 22 | -------------------------------------------------------------------------------- /.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Mac", 5 | "includePath": [ 6 | "/usr/include" 7 | ], 8 | "browse": { 9 | "limitSymbolsToIncludedHeaders": true, 10 | "databaseFilename": "", 11 | "path": [ 12 | "/usr/include", 13 | "${workspaceRoot}" 14 | ] 15 | }, 16 | "intelliSenseMode": "clang-x64", 17 | "macFrameworkPath": [ 18 | "/System/Library/Frameworks", 19 | "/Library/Frameworks" 20 | ] 21 | }, 22 | { 23 | "name": "Linux", 24 | "includePath": [ 25 | "/usr/include" 26 | ], 27 | "browse": { 28 | "limitSymbolsToIncludedHeaders": true, 29 | "databaseFilename": "", 30 | "path": [ 31 | "/usr/include", 32 | "${workspaceRoot}" 33 | ] 34 | }, 35 | "intelliSenseMode": "clang-x64" 36 | }, 37 | { 38 | "name": "Win32", 39 | "includePath": [ 40 | "c:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include", 41 | "D:/pi/include/c++/4.9", 42 | "D:/pi/include/mosquitto", 43 | "C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/stm8/inc" 44 | ], 45 | "browse": { 46 | "limitSymbolsToIncludedHeaders": true, 47 | "databaseFilename": "", 48 | "path": [ 49 | "c:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include", 50 | "D:/pi/include/c++/4.9", 51 | "D:/pi/include/mosquitto", 52 | "C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/stm8/inc", 53 | "${workspaceRoot}" 54 | ] 55 | }, 56 | "intelliSenseMode": "msvc-x64", 57 | "cStandard": "c11", 58 | "cppStandard": "c++17" 59 | } 60 | ], 61 | "version": 4 62 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "*hpp*hpparray": "cpp", 4 | "array": "cpp", 5 | "xutility": "cpp", 6 | "utility": "cpp", 7 | "xiosbase": "cpp", 8 | "xlocale": "cpp", 9 | "vector": "cpp", 10 | "xstring": "cpp", 11 | "ios": "cpp", 12 | "twi_master.h": "c", 13 | "xmemory0": "cpp", 14 | "sdk_common.h": "c", 15 | "valarray": "c", 16 | "iosfwd": "c", 17 | "bme280.h": "c", 18 | "twi.h": "c" 19 | } 20 | } -------------------------------------------------------------------------------- /bluetooth/ble.py: -------------------------------------------------------------------------------- 1 | from bluepy.btle import Scanner, DefaultDelegate 2 | 3 | class ScanDelegate(DefaultDelegate): 4 | def __init__(self): 5 | DefaultDelegate.__init__(self) 6 | 7 | def handleDiscovery(self, dev, isNewDev, isNewData): 8 | if isNewDev: 9 | print "Discovered device", dev.addr 10 | elif isNewData: 11 | print "Received new data from", dev.addr 12 | 13 | scanner = Scanner().withDelegate(ScanDelegate()) 14 | devices = scanner.scan(10.0) 15 | 16 | for dev in devices: 17 | print "Device %s (%s), RSSI=%d dB" % (dev.addr, dev.addrType, dev.rssi) 18 | for (adtype, desc, value) in dev.getScanData(): 19 | print " %s = %s" % (desc, value) 20 | -------------------------------------------------------------------------------- /bluetooth/readme.md: -------------------------------------------------------------------------------- 1 | # Fitness Trackers 2 | 3 | Device e4:ca:1e:32:9a:d4 (random), RSSI=-64 dB 4 | Complete 128b Services = d0002d121e4b0fa4994eceb5f0ff0579 5 | Flags = 06 6 | Complete 16b Services = e7fe 7 | Complete Local Name = T93proCAE4 8 | Manufacturer = 3412fee7e4ca1e329ad4 9 | 10 | Service : 6e40fff0-b5a3-f393-e0a9-e50e24dcca9e 11 | Firmware update : 00001530-1212-efde-1523-785feabcd123 12 | Service : 0000fee7-0000-1000-8000-00805f9b34fb 13 | Service : de5bf728-d711-4e47-af26-65e3012a5dc7 14 | 15 | Device d8:e8:e8:39:2a:3d (random), RSSI=-72 dB 16 | Appearance = 0000 17 | Complete 16b Services = f00a 18 | Complete Local Name = ID115Plus HR 19 | Manufacturer = 45020000d8e8e8392a3d8f 20 | Flags = 05 21 | 22 | Service : 23 | 00000af0-0000-1000-8000-00805f9b34fb 24 | Characteristics : 25 | 00000af7-0000-1000-8000-00805f9b34fb 26 | 00000af2-0000-1000-8000-00805f9b34fb 27 | 00000af1-0000-1000-8000-00805f9b34fb 28 | 29 | 30 | sudo hciconfig hci0 down 31 | sudo hciconfig hci0 up 32 | 33 | sudo hcitool lescan 34 | 35 | sudo hcitool lecc D8:E8:E8:39:2A:3D 36 | 37 | sudo hcitool lecc 98:4F:EE:0D:06:1A 38 | 39 | gatttool -b D8:E8:E8:39:2A:3D --interactive 40 | gatttool -b E4:CA:1E:32:9A:D4 --interactive 41 | gatttool -t random -b D8:E8:E8:39:2A:3D --interactive 42 | gatttool -t random -b E4:CA:1E:32:9A:D4 --interactive 43 | 44 | 45 | 46 | pi@ioserv:~/IoT_Frameworks/bluetooth $ gatttool -b d8:e8:e8:39:2a:3d --interactive 47 | [d8:e8:e8:39:2a:3d][LE]> connect 48 | Attempting to connect to d8:e8:e8:39:2a:3d 49 | [d8:e8:e8:39:2a:3d][LE]> connect 50 | Error: connect error: Connection refused (111) 51 | -------------------------------------------------------------------------------- /bluetooth/test.py: -------------------------------------------------------------------------------- 1 | #https://gist.github.com/keithweaver/3d5dbf38074cee4250c7d9807510c7c3 2 | # Uses Bluez for Linux 3 | # 4 | # sudo apt-get install bluez python-bluez 5 | # 6 | # Taken from: https://people.csail.mit.edu/albert/bluez-intro/x232.html 7 | # Taken from: https://people.csail.mit.edu/albert/bluez-intro/c212.html 8 | 9 | import bluetooth 10 | 11 | def receiveMessages(): 12 | server_sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM ) 13 | 14 | port = 1 15 | server_sock.bind(("",port)) 16 | server_sock.listen(1) 17 | 18 | client_sock,address = server_sock.accept() 19 | print "Accepted connection from " + str(address) 20 | 21 | data = client_sock.recv(1024) 22 | print "received [%s]" % data 23 | 24 | client_sock.close() 25 | server_sock.close() 26 | 27 | def sendMessageTo(targetBluetoothMacAddress): 28 | port = 1 29 | sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM ) 30 | sock.connect((targetBluetoothMacAddress, port)) 31 | sock.send("hello!!") 32 | sock.close() 33 | 34 | def lookUpNearbyBluetoothDevices(): 35 | nearby_devices = bluetooth.discover_devices() 36 | for bdaddr in nearby_devices: 37 | print str(bluetooth.lookup_name( bdaddr )) + " [" + str(bdaddr) + "]" 38 | 39 | lookUpNearbyBluetoothDevices() 40 | -------------------------------------------------------------------------------- /bluetooth/test.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HomeSmartMesh/IoT_Frameworks/411dfba86d012bd757b3fc4d430f1f53a979f294/bluetooth/test.pyc -------------------------------------------------------------------------------- /config/README.md: -------------------------------------------------------------------------------- 1 | ### Note on security 2 | - All the info and passwords provided in the config subdirectory are for local use only 3 | - For example, remote access to local netwrok usage through a vpn is an option and is highly recommended 4 | - in case you decided to open ports to the outside world, all security aspects have to be considered (ssl, secret complex passwords) 5 | - The provided examples are only focusing on a private local network, to help get started 6 | -------------------------------------------------------------------------------- /config/boards.json: -------------------------------------------------------------------------------- 1 | { 2 | "STM8L_v2":{ 3 | "hardware" :{ 4 | "pcb":{ 5 | "repo":"https://github.com/wassfila/STM8_IoT_Boards.git", 6 | "path":"IoT_Node_Mobile_v2", 7 | "tool":"Eagle" 8 | }, 9 | "components":{ 10 | "uc":"STM8L151F3", 11 | "magnets":"MRMS211H" 12 | }, 13 | "modules":{ 14 | "rf":["nRF24"], 15 | "sensors":["BME280","MAX44009"] 16 | } 17 | }, 18 | "software" :{ 19 | "repo" :"https://github.com/wassfila/IoT_STM8.git", 20 | "programs":{ 21 | "pr01_Node_Alive" :"firmware_rf_sensors_node/pr01_Node_Alive", 22 | "pr03_PressHumTemp" :"firmware_rf_sensors_node/pr03_PressHumTemp" 23 | } 24 | } 25 | }, 26 | "STM32_Dongle":{ 27 | "hardware":{ 28 | "pcb":{ 29 | "repo":"https://github.com/wassfila/STM32_IoT_Boards.git", 30 | "path":"RFNode/design_pcb_eagle", 31 | "tool":"Eagle" 32 | }, 33 | "modules":{ 34 | "uc":"STM32_BluePill", 35 | "rf":["nRF24","nRF24_pa_lna"], 36 | "sensors":["BME280","APDS9960"] 37 | } 38 | }, 39 | "software":{ 40 | "repo" :"https://github.com/wassfila/IoT_Frameworks.git", 41 | "programs":{ 42 | "rf_uart_interface" :"stm32_rf_dongle/rf_uart_interface", 43 | "rf_bridge" :"stm32_rf_dongle/rf_bridge", 44 | "rf_sniffer" :"stm32_rf_dongle/rf_sniffer" 45 | } 46 | } 47 | }, 48 | "STM32_RFPIO":{ 49 | "hardware":{ 50 | "pcb":{ 51 | "repo":"https://github.com/wassfila/STM32_IoT_Boards.git", 52 | "path":"RFPIO/design_pcb_eagle", 53 | "tool":"Eagle" 54 | }, 55 | "modules":{ 56 | "uc":"STM32_BluePill", 57 | "rf":["nRF24","nRF24_pa_lna"], 58 | "components":{ 59 | "io_driver":"ULN2804A", 60 | "io_interface": "Servos_Coonectors" 61 | } 62 | } 63 | }, 64 | "software":{ 65 | "repo" :"https://github.com/wassfila/IoT_Frameworks.git", 66 | "programs":{ 67 | "dimmer" : "dimmer/smt32_rfpio_firmware", 68 | "smartio" : "firmware/stm32_rfio" 69 | } 70 | } 71 | }, 72 | "nRF51_Beacon":{ 73 | "hardware":{ 74 | "cots":{ 75 | "long_name":"NRF51822 Bluetooth 4.0 Wireless Module For iBeacon", 76 | "ali":"https://www.aliexpress.com/item/2V-3-3V-NRF51822-Bluetooth-4-0-Wireless-Module-For-iBeacon-Base-Station-Intelligent-Control-System/32824004498.html?spm=a2g0s.9042311.0.0.4clvvB" 77 | } 78 | }, 79 | "software":{ 80 | "repo" :"https://github.com/wassfila/IoT_Frameworks.git", 81 | "programs":{ 82 | "nRF51_Beacon" :"nRF51_Beacon" 83 | }, 84 | "uc":"nRF51822_xxAA", 85 | "rf":["nRF51"], 86 | "sensors":["button"] 87 | } 88 | }, 89 | "nRF51_Sensors":{ 90 | "hardware":{ 91 | "cots":{ 92 | "long_name":"NRF51 Sensor Tag" 93 | } 94 | }, 95 | "software":{ 96 | "repo" :"https://github.com/wassfila/IoT_Frameworks.git", 97 | "programs":{ 98 | "nRF51_Sensors" :"nRF51_Sensors" 99 | }, 100 | "uc":"nRF51822_xxAA", 101 | "rf":["nRF51"], 102 | "sensors":["MPU6050","BMP180","AP3216C"] 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /config/grafana/README.md: -------------------------------------------------------------------------------- 1 | # Install on the Raspberry pi 2 | - https://github.com/fg2it/grafana-on-raspberry/wiki 3 | 4 | please refer to the original source of info above or to the latest refrence. 5 | Notes below are just to speedup installs and not considered as complete tutorials 6 | 7 | ### Dashboards 8 | - "dashboards" subdirectory provides json files that can be uploaded to a new Grafana install 9 | 10 | ### Preparation 11 | ``` 12 | sudo apt-get install apt-transport-https curl 13 | curl https://bintray.com/user/downloadSubjectPublicKey?username=bintray | sudo apt-key add - 14 | echo "deb https://dl.bintray.com/fg2it/deb stretch main" | sudo tee -a /etc/apt/sources.list.d/grafana.list 15 | ``` 16 | ### Install 17 | ``` 18 | sudo apt-get update 19 | sudo apt-get install grafana 20 | ``` 21 | ### start service 22 | ``` 23 | systemctl daemon-reload 24 | systemctl start grafana-server 25 | systemctl status grafana-server 26 | ``` 27 | ### service start issues 28 | had to start the service from /etc/rc.local 29 | ``` 30 | sudo systemctl start grafana-server.service 31 | ``` 32 | ### config 33 | ``` 34 | sudo nano /etc/grafana/grafana.ini 35 | ``` 36 | ### default users 37 | admin / admin 38 | ### snapshots 39 | - https://snapshot.raintank.io/dashboard/snapshot/XUeMIkt3T936k036wl8pFE7acaLqONvt?orgId=2&from=1513890000000&to=1513976400000 40 | -------------------------------------------------------------------------------- /config/influxdb/README.md: -------------------------------------------------------------------------------- 1 | # Install on the Raspberry pi 2 | sources: 3 | - https://gist.github.com/boseji/bb71910d43283a1b84ab200bcce43c26 4 | - https://docs.influxdata.com/influxdb/v1.4/introduction/getting_started/ 5 | - https://github.com/influxdata/influxdb/blob/master/QUERIES.md 6 | 7 | ``` 8 | sudo apt install apt-transport-https 9 | echo "deb https://repos.influxdata.com/debian stretch stable" | sudo tee /etc/apt/sources.list.d/influxdb.list 10 | sudo apt-get update 11 | 12 | sudo apt-get install influxdb 13 | 14 | ``` 15 | 16 | ### config 17 | Default 18 | ``` 19 | sudo nano /etc/influxdb/influxdb.conf 20 | ``` 21 | directly from the repo 22 | ``` 23 | INFLUXDB_CONFIG_PATH=/home/pi/IoT_Frameworks/config/influxdb/influxdb.conf 24 | ``` 25 | 26 | ### start the service 27 | ``` 28 | sudo systemctl start influxdb 29 | ``` 30 | 31 | ### help reminder, see getting started link for more 32 | ``` 33 | influx -precision rfc3339 34 | CREATE DATABASE mydb, 35 | SHOW DATABASES 36 | SHOW SERIES on raspiStatus 37 | USE mydb 38 | 39 | DROP DATABASE mydb 40 | 41 | cpu,host=serverA,region=us_west value=0.64 42 | 43 | SHOW FIELD KEYS FROM "cpu_temp" 44 | SHOW TAG KEYS FROM "cpu_temp" 45 | SHOW TAG VALUES FROM "cpu_temp" WITH KEY="host" 46 | 47 | SELECT * FROM "cpu_temp" WHERE "host" = 'ioserv' 48 | 49 | SELECT "power" FROM "node30" WHERE time > '2017-12-24T12:33:00Z' AND time < '2017-12-24T15:34:10Z' 50 | DELETE FROM "node37" WHERE time > '2017-12-24T12:33:00Z' AND time < '2017-12-24T15:34:10Z' 51 | ``` 52 | ### Nodes posts 53 | ``` 54 | post = [ 55 | { 56 | "measurement": "node6", 57 | "time": datetime.datetime.utcnow(), 58 | "fields": { 59 | "temperature": value 60 | } 61 | } 62 | ] 63 | ``` 64 | ### Grafana Queries 65 | ``` 66 | SELECT "temperature" FROM "node6" WHERE $timeFilter 67 | ``` 68 | ### Raspi status posts 69 | ``` 70 | posts = [ 71 | { 72 | "measurement": "cpu_load", 73 | "time": tnow, 74 | "tags":{ 75 | "host":hostname 76 | }, 77 | "fields": { 78 | "value": float(rasp.getCPU_Avg1min()) 79 | } 80 | } 81 | ] 82 | ``` 83 | 84 | ### Raspi queries 85 | ``` 86 | SELECT "value" FROM "cpu_load" 87 | ``` 88 | -------------------------------------------------------------------------------- /config/influxdb/backup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Backing up the influx Databse" 3 | influxd backup /home/pi/share/$(date +%F)_influx_backup 4 | influxd backup -database meshNodes -since 2017-12-01T00:00:00Z /home/pi/share/$(date +%F)_influx_backup 5 | influxd backup -database raspiStatus -since 2017-12-01T00:00:00Z /home/pi/share/$(date +%F)_influx_backup 6 | -------------------------------------------------------------------------------- /config/influxdb/restore.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Restoring the influx Databse" 3 | sudo systemctl stop influxdb 4 | 5 | backup_path=$1 6 | influxd restore -metadir /var/lib/influxdb/meta $backup_path 7 | influxd restore -database meshNodes -datadir /var/lib/influxdb/data $backup_path 8 | influxd restore -database raspiStatus -datadir /var/lib/influxdb/data $backup_path 9 | 10 | sudo chown -R influxdb:influxdb /var/lib/influxdb 11 | 12 | sudo systemctl start influxdb 13 | -------------------------------------------------------------------------------- /config/mongodb/README.md: -------------------------------------------------------------------------------- 1 | # Install on the Raspberry pi 2 | sources: 3 | - http://yannickloriot.com/2016/04/install-mongodb-and-node-js-on-a-raspberry-pi/ 4 | 5 | ### dependencies 6 | - node 7 | 8 | ``` 9 | sudo apt-get update 10 | sudo apt-get upgrade 11 | sudo apt-get install mongodb-server 12 | sudo service mongod start 13 | mongo 14 | ``` 15 | 16 | ### config 17 | ``` 18 | sudo nano /etc/mongodb.conf 19 | ``` 20 | -------------------------------------------------------------------------------- /config/mongodb/mongodb.conf: -------------------------------------------------------------------------------- 1 | # mongodb.conf 2 | 3 | #I addedd from andyfelong 4 | storageEngine = mmapv1 5 | 6 | # Where to store the data. 7 | dbpath=/var/lib/mongodb 8 | 9 | #where to log 10 | logpath=/var/log/mongodb/mongodb.log 11 | 12 | logappend=true 13 | 14 | bind_ip = 10.0.0.44 15 | port = 27017 16 | 17 | # Enable journaling, http://www.mongodb.org/display/DOCS/Journaling 18 | journal=true 19 | 20 | # Enables periodic logging of CPU utilization and I/O wait 21 | #cpu = true 22 | 23 | # Turn on/off security. Off is currently the default 24 | #noauth = true 25 | #auth = true 26 | 27 | # Verbose logging output. 28 | #verbose = true 29 | 30 | # Inspect all client data for validity on receipt (useful for 31 | # developing drivers) 32 | #objcheck = true 33 | 34 | # Enable db quota management 35 | #quota = true 36 | 37 | # Set oplogging level where n is 38 | # 0=off (default) 39 | # 1=W 40 | # 2=R 41 | # 3=both 42 | # 7=W+some reads 43 | #oplog = 0 44 | 45 | # Diagnostic/debugging option 46 | #nocursors = true 47 | 48 | # Ignore query hints 49 | #nohints = true 50 | 51 | # Disable the HTTP interface (Defaults to localhost:27018). 52 | #nohttpinterface = true 53 | 54 | # Turns off server-side scripting. This will result in greatly limited 55 | # functionality 56 | #noscripting = true 57 | 58 | # Turns off table scans. Any query that would do a table scan fails. 59 | #notablescan = true 60 | 61 | # Disable data file preallocation. 62 | #noprealloc = true 63 | 64 | # Specify .ns file size for new databases. 65 | # nssize = 66 | 67 | # Accout token for Mongo monitoring server. 68 | #mms-token = 69 | 70 | # Server name for Mongo monitoring server. 71 | #mms-name = 72 | 73 | # Ping interval for Mongo monitoring server. 74 | #mms-interval = 75 | 76 | # Replication Options 77 | 78 | # in replicated mongo databases, specify here whether this is a slave or master 79 | #slave = true 80 | #source = master.example.com 81 | # Slave only: specify a single database to replicate 82 | #only = master.example.com 83 | # or 84 | #master = true 85 | #source = slave.example.com 86 | 87 | # Address of a server to pair with. 88 | #pairwith = 89 | # Address of arbiter server. 90 | #arbiter = 91 | # Automatically resync if slave data is stale 92 | #autoresync 93 | # Custom size for replication operation log. 94 | #oplogSize = 95 | # Size limit for in-memory storage of op ids. 96 | #opIdMem = 97 | 98 | # SSL options 99 | # Enable SSL on normal ports 100 | #sslOnNormalPorts = true 101 | # SSL Key file and password 102 | #sslPEMKeyFile = /etc/ssl/mongodb.pem 103 | #sslPEMKeyPassword = pass 104 | -------------------------------------------------------------------------------- /config/topics.json: -------------------------------------------------------------------------------- 1 | { 2 | "Nodes":{ 3 | "light" :"sensor", 4 | "temperature" :"sensor", 5 | "pressure" :"sensor", 6 | "humidity" :"sensor", 7 | "aliveness" :"sensor", 8 | "proximity" :"sensor", 9 | "dimmer" :"action", 10 | "heat" :"action", 11 | "switch" :"action" 12 | }, 13 | "jNodes":{ 14 | "dimmer" :"action", 15 | "RGB" :"action", 16 | "MeshRF" :"message", 17 | "RawRF" :"message" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /dimmer/smt32_rfpio_firmware/.gitignore: -------------------------------------------------------------------------------- 1 | .temp/ 2 | BUILD/ 3 | *.pyc 4 | mbed-os/ 5 | nrf-mesh/ 6 | crc/ 7 | dimm/ 8 | .settings/ 9 | .vscode/ 10 | -------------------------------------------------------------------------------- /dimmer/smt32_rfpio_firmware/.mbed: -------------------------------------------------------------------------------- 1 | TARGET=BLUEPILL_F103C8 2 | ROOT=. 3 | -------------------------------------------------------------------------------- /dimmer/smt32_rfpio_firmware/cf.bat: -------------------------------------------------------------------------------- 1 | call compile.bat 2 | call flash.bat 3 | -------------------------------------------------------------------------------- /dimmer/smt32_rfpio_firmware/compile.bat: -------------------------------------------------------------------------------- 1 | mbed compile -v --profile .\develop_nano.json -------------------------------------------------------------------------------- /dimmer/smt32_rfpio_firmware/config_flash.bat: -------------------------------------------------------------------------------- 1 | REM $env:Path += ";C:\Users\Wass\.platformio\packages\tool-stlink" 2 | SET PATH=%PATH%;C:\Users\Wass\.platformio\packages\tool-stlink 3 | REM 0x0800FC00 is the adress of the last block 0..63 4 | st-flash write .\BUILD\BLUEPILL_F103C8\GCC_ARM\config.bin 0x0800FC00 5 | -------------------------------------------------------------------------------- /dimmer/smt32_rfpio_firmware/config_read.bat: -------------------------------------------------------------------------------- 1 | REM $env:Path += ";C:\Users\Wass\.platformio\packages\tool-stlink" 2 | SET PATH=%PATH%;C:\Users\Wass\.platformio\packages\tool-stlink 3 | REM 0x0800FC00 is the adress of the last block 0..63 4 | st-flash read .\BUILD\BLUEPILL_F103C8\GCC_ARM\config.bin 0x0800FC00 0x400 5 | -------------------------------------------------------------------------------- /dimmer/smt32_rfpio_firmware/crc.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/crc/#22593a25b890efbe1a6a6482d58237c28a0d94ea 2 | -------------------------------------------------------------------------------- /dimmer/smt32_rfpio_firmware/debug.bat: -------------------------------------------------------------------------------- 1 | mbed compile -v --profile .\develop_nano.json -------------------------------------------------------------------------------- /dimmer/smt32_rfpio_firmware/debug_nano.json: -------------------------------------------------------------------------------- 1 | { 2 | "GCC_ARM": { 3 | "common": ["-c", "-Wall", "-Wextra", 4 | "-Wno-unused-parameter", "-Wno-missing-field-initializers", 5 | "-fmessage-length=0", "-fno-exceptions", "-fno-builtin", 6 | "-ffunction-sections", "-fdata-sections", "-funsigned-char", 7 | "-MMD", "-fno-delete-null-pointer-checks", 8 | "-fomit-frame-pointer", "-O0", "-g3", "-DMBED_DEBUG"], 9 | "asm": ["-x", "assembler-with-cpp"], 10 | "c": ["-std=gnu99","-g"], 11 | "cxx": ["-std=gnu++98", "-fno-rtti", "-Wvla","-g"], 12 | "ld": ["-Wl,--gc-sections", "-Wl,--wrap,main", "-Wl,--wrap,_malloc_r", 13 | "-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r", 14 | "-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit", 15 | "-Wl,-n","--specs=nano.specs"] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /dimmer/smt32_rfpio_firmware/develop_nano.json: -------------------------------------------------------------------------------- 1 | { 2 | "GCC_ARM": { 3 | "common": ["-c", "-Wall", "-Wextra", 4 | "-Wno-unused-parameter", "-Wno-missing-field-initializers", 5 | "-fmessage-length=0", "-fno-exceptions", "-fno-builtin", 6 | "-ffunction-sections", "-fdata-sections", "-funsigned-char", 7 | "-MMD", "-fno-delete-null-pointer-checks", 8 | "-fomit-frame-pointer", "-Os"], 9 | "asm": ["-x", "assembler-with-cpp"], 10 | "c": ["-std=gnu99","-g"], 11 | "cxx": ["-std=c++11", "-fno-rtti", "-Wvla","-g"], 12 | "ld": ["-Wl,--gc-sections", "-Wl,--wrap,main", "-Wl,--wrap,_malloc_r", 13 | "-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r", 14 | "-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit", 15 | "-Wl,-n","--specs=nano.specs"] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /dimmer/smt32_rfpio_firmware/dimm.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/light-dimmer/#fe23761e31c2f05d9375d00c3761a2d5329faebf 2 | -------------------------------------------------------------------------------- /dimmer/smt32_rfpio_firmware/flash.bat: -------------------------------------------------------------------------------- 1 | REM $env:Path += ";C:\Users\Wass\.platformio\packages\tool-stlink" 2 | SET PATH=%PATH%;C:\Users\Wass\.platformio\packages\tool-stlink 3 | st-flash write .\BUILD\BLUEPILL_F103C8\GCC_ARM\smt32_rfpio_firmware.bin 0x08000000 -------------------------------------------------------------------------------- /dimmer/smt32_rfpio_firmware/main.cpp: -------------------------------------------------------------------------------- 1 | #include "mbed.h" 2 | 3 | #include "rfmesh.h" 4 | #include "protocol.h" 5 | #include "dimm.h" 6 | #include "utils.h" 7 | 8 | //------------------------------------- CONFIG ----------------------------------------- 9 | const uint8_t CHANNEL = 2; 10 | const uint8_t NODEID = 25; 11 | //TODO use flash config 12 | 13 | #define RF_BOARD_DONGLE 0 14 | #define RF_BOARD_PIO 1 15 | 16 | #define DEBUG_RFPIO 1 17 | //-------------------------------------------------------------------------------------- 18 | //-------------------------------------------------------------------------------------- 19 | 20 | Serial rasp(PB_10, PB_11, 115200); 21 | DigitalOut myled(PC_13); 22 | 23 | Ticker tick_call; 24 | 25 | #if (RF_BOARD_DONGLE == 1) 26 | uint8_t spi_module = 1; 27 | //nRF Modules 1:Gnd, 2:3.3v, 3:ce, 4:csn, 5:sck, 6:mosi, 7:miso, 8:irq 28 | RfMesh hsm(&rasp,spi_module, PC_15, PA_4, PA_5, PA_7, PA_6, PA_0); 29 | #elif (RF_BOARD_PIO == 1) 30 | uint8_t spi_module = 2; 31 | //nRF Modules 1:Gnd, 2:3.3v, 3:ce, 4:csn, 5:sck, 6:mosi, 7:miso, 8:irq 32 | //RFPIO Layout !!!! 33 | RfMesh hsm(&rasp, spi_module, PA_5, PB_12, PB_13, PB_15, PB_14, PA_4); 34 | #endif 35 | 36 | //channel from pins A2,A3 could not be assigned to pwm even after changing uart to UART1 37 | // rel, sync, ch1,2, 3, 4 38 | Dimm dimmer(&rasp,PB_4,PB_5, PA_8,PA_9,PA_10,PA_11, PA_15,PB_3,PB_0,PB_1 ); 39 | 40 | 41 | void the_ticker() 42 | { 43 | //myled = !myled; 44 | #if(DEBUG_RFPIO == 1) 45 | //rasp.printf("rf>alive\r\n"); 46 | #endif 47 | } 48 | 49 | void rf_message_received(uint8_t *data,uint8_t size) 50 | { 51 | //rasp.printf("rf_message_received()\r\n"); 52 | //print_tab(&rasp,data,size); 53 | if(data[rf::ind::pid] == rf::pid::dimmer) 54 | { 55 | dimmer.handle_message(data,size); 56 | } 57 | } 58 | 59 | void startup_switchon() 60 | { 61 | int vals[8]; 62 | 63 | //switch on - still might jitter depending on phase 64 | //TODO might think to sync the relay with the ISR 65 | dimmer.relay = 0; 66 | 67 | //185 - 9900 68 | for(int i=0;i<18000;i++) 69 | { 70 | for(int j=0;j<8;j++) 71 | { 72 | vals[7-j] = i - (j*1000);//first gets counter, second is shifted by 1000,... 73 | if(vals[j] < 0) 74 | { 75 | vals[j] = 0; 76 | } 77 | //the set level is protected against max so no issues for first overflowing 78 | //the set_level is also latch protected, so no influence on change light count 79 | dimmer.set_level(j,vals[j]); 80 | //if((i%1000) == 0){rasp.printf("%d ",vals[j]);} 81 | } 82 | //if((i%1000) == 0){rasp.printf("\r\n");} 83 | wait_us(80);// ~ 84 | } 85 | } 86 | 87 | void init() 88 | { 89 | 90 | uint8_t * p_UID = (uint8_t*) 0x1FFFF7E8; 91 | 92 | rasp.printf("Light Dimmer> U_ID: "); 93 | print_tab(&rasp,p_UID,12); 94 | rasp.printf("Light Dimmer> Node ID: %d\r",NODEID); 95 | 96 | tick_call.attach(&the_ticker,1); 97 | 98 | 99 | dimmer.init();//here irq is enabled 100 | 101 | startup_switchon(); 102 | 103 | hsm.init(CHANNEL); 104 | hsm.setNodeId(NODEID); 105 | rasp.printf("Light Dimmer listening at channel %d\r",CHANNEL); 106 | 107 | //hsm.print_nrf(); 108 | 109 | hsm.attach(&rf_message_received,RfMesh::CallbackType::Message); 110 | 111 | } 112 | 113 | int main() 114 | { 115 | myled = 1;//turn off 116 | 117 | init();//dimmer, hsm 118 | 119 | 120 | rasp.printf("Broadcasting reset\r\n"); 121 | hsm.broadcast(rf::pid::reset); 122 | 123 | rasp.printf("starting loop\r\n"); 124 | while(1) 125 | { 126 | myled = 0;//on 127 | wait_ms(50); 128 | myled = 1;//off 129 | wait(10); 130 | rasp.printf("Nb int : %d\r",dimmer.intCount); 131 | dimmer.intCount = 0; 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /dimmer/smt32_rfpio_firmware/mbed-os.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/mbed-os/#4153c4a69a8c9963a00c28e6b28150049e0f1a30 2 | -------------------------------------------------------------------------------- /dimmer/smt32_rfpio_firmware/mbed_settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | mbed SDK 3 | Copyright (c) 2016 ARM Limited 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | """ 17 | 18 | from os.path import join, abspath, dirname 19 | 20 | #ROOT = abspath(join(dirname(__file__), ".")) 21 | 22 | ############################################################################## 23 | # Build System Settings 24 | ############################################################################## 25 | #BUILD_DIR = abspath(join(ROOT, "build")) 26 | 27 | # ARM 28 | #ARM_PATH = "C:/Program Files/ARM" 29 | 30 | # GCC ARM 31 | #GCC_ARM_PATH = "" 32 | 33 | # GCC CodeRed 34 | #GCC_CR_PATH = "C:/code_red/RedSuite_4.2.0_349/redsuite/Tools/bin" 35 | 36 | # IAR 37 | #IAR_PATH = "C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm" 38 | 39 | # Goanna static analyser. Please overload it in private_settings.py 40 | #GOANNA_PATH = "c:/Program Files (x86)/RedLizards/Goanna Central 3.2.3/bin" 41 | 42 | #BUILD_OPTIONS = [] 43 | 44 | # mbed.org username 45 | #MBED_ORG_USER = "" 46 | -------------------------------------------------------------------------------- /dimmer/smt32_rfpio_firmware/nrf-mesh.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/nrf-mesh/#5a003180df99cc3250a238e561e6e7f2d4bd87f7 2 | -------------------------------------------------------------------------------- /dimmer/stm32_rfnode_pulser/.gitignore: -------------------------------------------------------------------------------- 1 | .temp/ 2 | BUILD/ 3 | *.pyc 4 | mbed-os/ 5 | nrf-mesh/ 6 | Servo/ 7 | safe-uart/ 8 | crc/ 9 | .settings/ 10 | .vscode/ 11 | -------------------------------------------------------------------------------- /dimmer/stm32_rfnode_pulser/.mbed: -------------------------------------------------------------------------------- 1 | TARGET=BLUEPILL_F103C8 2 | ROOT=. 3 | -------------------------------------------------------------------------------- /dimmer/stm32_rfnode_pulser/cf.bat: -------------------------------------------------------------------------------- 1 | call compile.bat 2 | call flash.bat 3 | -------------------------------------------------------------------------------- /dimmer/stm32_rfnode_pulser/compile.bat: -------------------------------------------------------------------------------- 1 | mbed compile -v --profile .\develop_nano.json -------------------------------------------------------------------------------- /dimmer/stm32_rfnode_pulser/develop_nano.json: -------------------------------------------------------------------------------- 1 | { 2 | "GCC_ARM": { 3 | "common": ["-c", "-Wall", "-Wextra", 4 | "-Wno-unused-parameter", "-Wno-missing-field-initializers", 5 | "-fmessage-length=0", "-fno-exceptions", "-fno-builtin", 6 | "-ffunction-sections", "-fdata-sections", "-funsigned-char", 7 | "-MMD", "-fno-delete-null-pointer-checks", 8 | "-fomit-frame-pointer", "-O0", "-g3"], 9 | "asm": ["-x", "assembler-with-cpp"], 10 | "c": ["-std=gnu99","-g"], 11 | "cxx": ["-std=c++11", "-fno-rtti", "-Wvla","-g"], 12 | "ld": ["-Wl,--gc-sections", "-Wl,--wrap,main", "-Wl,--wrap,_malloc_r", 13 | "-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r", 14 | "-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit", 15 | "-Wl,-n","--specs=nano.specs"] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /dimmer/stm32_rfnode_pulser/flash.bat: -------------------------------------------------------------------------------- 1 | REM $env:Path += ";C:\Users\Wass\.platformio\packages\tool-stlink" 2 | SET PATH=%PATH%;C:\Users\Wass\.platformio\packages\tool-stlink 3 | st-flash write .\BUILD\BLUEPILL_F103C8\GCC_ARM\stm32_rfnode_pulser.bin 0x08000000 -------------------------------------------------------------------------------- /dimmer/stm32_rfnode_pulser/main.cpp: -------------------------------------------------------------------------------- 1 | #include "mbed.h" 2 | 3 | 4 | 5 | Serial rasp(PB_10, PB_11, 115200); 6 | DigitalOut myled(PC_13); 7 | Ticker tick_call; 8 | 9 | DigitalOut pulser(PB_13); 10 | 11 | void the_ticker() 12 | { 13 | myled = !myled; 14 | } 15 | 16 | int main() 17 | { 18 | rasp.printf("stm32_pulser> Hello"); 19 | 20 | tick_call.attach(&the_ticker,0.2); 21 | 22 | while(1) 23 | { 24 | wait_ms(10); 25 | pulser = 1; 26 | wait_us(10); 27 | pulser = 0; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /dimmer/stm32_rfnode_pulser/mbed-os.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/mbed-os/#4153c4a69a8c9963a00c28e6b28150049e0f1a30 2 | -------------------------------------------------------------------------------- /dimmer/stm32_rfnode_pulser/mbed_settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | mbed SDK 3 | Copyright (c) 2016 ARM Limited 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | """ 17 | 18 | from os.path import join, abspath, dirname 19 | 20 | #ROOT = abspath(join(dirname(__file__), ".")) 21 | 22 | ############################################################################## 23 | # Build System Settings 24 | ############################################################################## 25 | #BUILD_DIR = abspath(join(ROOT, "build")) 26 | 27 | # ARM 28 | #ARM_PATH = "C:/Program Files/ARM" 29 | 30 | # GCC ARM 31 | #GCC_ARM_PATH = "" 32 | 33 | # GCC CodeRed 34 | #GCC_CR_PATH = "C:/code_red/RedSuite_4.2.0_349/redsuite/Tools/bin" 35 | 36 | # IAR 37 | #IAR_PATH = "C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm" 38 | 39 | # Goanna static analyser. Please overload it in private_settings.py 40 | #GOANNA_PATH = "c:/Program Files (x86)/RedLizards/Goanna Central 3.2.3/bin" 41 | 42 | #BUILD_OPTIONS = [] 43 | 44 | # mbed.org username 45 | #MBED_ORG_USER = "" 46 | -------------------------------------------------------------------------------- /joystick_servo/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /joystick_servo/.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | -------------------------------------------------------------------------------- /joystick_servo/SConstruct: -------------------------------------------------------------------------------- 1 | # - Glob() adds all the files with the extension to the list 2 | # - CPPPATH define the path where to look for source files which have include dependendcies 3 | # so that when these include files change, a recompilation of the source file is triggered 4 | # CPPPATH = ['include', '/home/project/inc'] 5 | 6 | env = Environment() 7 | env.Program( target='joy', 8 | source=[Glob('*.cpp'), 9 | [ 'pilibs/joystick.cpp', 10 | 'pilibs/serial.cpp', 11 | 'pilibs/utils.cpp', 12 | 'pilibs/log.cpp' 13 | ], 14 | ], 15 | CPPPATH = ['.','pilibs/'], 16 | CCFLAGS = ['-std=c++11'] 17 | ) 18 | -------------------------------------------------------------------------------- /joystick_servo/configfile.txt: -------------------------------------------------------------------------------- 1 | #____________________________________________________________________________________________ 2 | # ! Important ! Format ! 3 | #____________________________________________________________________________________________ 4 | # every variable starts with the beginning of the line, no spaces, no space betweem '=' sign 5 | #____________________________________________________________________________________________ 6 | 7 | # -------------- STREAMER -------------- 8 | # The "port" parameter, once defined, enables the serial port buffer update 9 | portname=/dev/ttyUSB0 10 | portbaud=115200 11 | 12 | # -------------- Log -------------- 13 | # The "logfile" is optionnal used for persistance 14 | logfile=/home/pi/share/joyLog.txt 15 | 16 | # 'level_out' is for console mode, and the 'level_file' is for the file record 17 | #Error:1, Warning:2, Info:3, Debug:4 18 | # default level_out is 19 | level_out=3 20 | level_file=2 21 | -------------------------------------------------------------------------------- /joystick_servo/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | //for usleep 3 | #include 4 | //for printf 5 | #include 6 | //for stdout 7 | #include 8 | 9 | //for abs 10 | #include 11 | 12 | #include "joystick.hpp" 13 | #include "serial.hpp" 14 | #include "log.hpp" 15 | #include "utils.hpp" 16 | 17 | 18 | #define RESET "\033[0m" 19 | #define BLACK "\033[30m" /* Black */ 20 | #define RED "\033[31m" /* Red */ 21 | #define GREEN "\033[32m" /* Green */ 22 | #define YELLOW "\033[33m" /* Yellow */ 23 | #define BLUE "\033[34m" /* Blue */ 24 | #define MAGENTA "\033[35m" /* Magenta */ 25 | #define CYAN "\033[36m" /* Cyan */ 26 | #define WHITE "\033[37m" /* White */ 27 | #define BOLDBLACK "\033[1m\033[30m" /* Bold Black */ 28 | #define BOLDRED "\033[1m\033[31m" /* Bold Red */ 29 | #define BOLDGREEN "\033[1m\033[32m" /* Bold Green */ 30 | #define BOLDYELLOW "\033[1m\033[33m" /* Bold Yellow */ 31 | #define BOLDBLUE "\033[1m\033[34m" /* Bold Blue */ 32 | #define BOLDMAGENTA "\033[1m\033[35m" /* Bold Magenta */ 33 | #define BOLDCYAN "\033[1m\033[36m" /* Bold Cyan */ 34 | #define BOLDWHITE "\033[1m\033[37m" /* Bold White */ 35 | 36 | #define CLEAR "\033[2J" // clear screen escape code 37 | 38 | //Axis 5 : 1520 - 1950 39 | 40 | void printf_tab(const char* data, int size) 41 | { 42 | char line_print[400]; 43 | sprintf(line_print,"0x %02x %02x %02x %02x %02x %02x %02x\n",data[0],data[1],data[2],data[3],data[4],data[5],data[6]); 44 | std::string line(line_print); 45 | Log::cout << line << Log::Info(); 46 | } 47 | 48 | void printf_tab2(const char* data, int size) 49 | { 50 | char line_print[400]; 51 | sprintf(line_print,"0x %02x %02x\n",data[0],data[1]); 52 | std::string line(line_print); 53 | Log::cout << line << Log::Info(); 54 | } 55 | 56 | void MapAxis(JAxis &axis,char s_id,Serial&ser) 57 | { 58 | if(axis.isUpdated()) 59 | { 60 | int val = 10000*(axis.getValue()+1)/2;//[-1,+1] => [0, 1] 61 | uint8_t data[7]; 62 | data[0] = 5; //size is 5 63 | data[1] = 'S'; //Protocol 'Servos' 64 | data[2] = s_id; //Servo Id = '1' 65 | data[3] = val / 256; //16 bit val 66 | data[4] = val % 256; 67 | printf_tab2((const char*)&data[3],2); 68 | utl::crc_set(data); 69 | //printf_tab((const char*)data,7); 70 | ser.send((const char*)(data),5+2); 71 | } 72 | } 73 | 74 | int main( int argc, char** argv ) 75 | { 76 | std::cout << "______________________Config______________________" << std::endl; 77 | strmap conf; 78 | utl::args2map(argc,argv,conf);//here is checked './configfile.txt' 79 | 80 | Log::config(conf); 81 | 82 | Serial ser(conf); // - process serial port stream 83 | 84 | Joystick joy; 85 | 86 | joy.start("/dev/input/js0"); 87 | 88 | //std::cout << MAGENTA << "Colored " << CYAN << "Text" << RESET << std::endl; 89 | 90 | while (1) 91 | { 92 | std::cout << CYAN; 93 | //Update the Joystick input 94 | if(joy.update())//multiple events will be filtered, only last would appear afterwards 95 | { 96 | //joy.printUpdates(); 97 | } 98 | 99 | MapAxis(joy.getAxis(5),1,ser);//Up 100 | 101 | joy.consumeAll(); 102 | 103 | std::cout << RESET; 104 | //display Received log 105 | if(ser.update()) 106 | { 107 | ser.processBuffer(); 108 | ser.logBuffer();//log received line 109 | } 110 | usleep (10000); 111 | 112 | } 113 | 114 | return 0; 115 | } 116 | -------------------------------------------------------------------------------- /joystick_servo/readme.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Joystick to servo on RaspberryPi linux + STM8 Board 4 | - Joytick code based on 5 | https://www.kernel.org/doc/Documentation/input/joystick-api.txt 6 | - C++ wrapper for joystick and serial port 7 | - STM8 for servo control 8 | 9 | ## Platform 10 | - PS4 Wireless controller : used with USB and wireless 11 | - Raspberry pi 3 : integrated bluetooth module 12 | - STM8S103F3 based Board, with 16bit PWM x7 channels (still not documented, priorisation on request). 13 | 14 | ## Setup: 15 | sudo apt-get install joystick 16 | ##Usage 17 | ###Compilation 18 | - first subdirectories are direct compile and makefile attempts, then scons is used for all others with SConstruct file 19 | 20 | >scons 21 | 22 | ### run 23 | >./joy 24 | 25 | ##connection with USB cable 26 | - check evironment 27 | >ls /dev/input 28 | added "event2 js0" 29 | 30 | >ls /dev/input/by-id/ 31 | added "Usb-Sony_Computer_Entertainment_Wireless_Controller-event-joystick" and " -joystick only" 32 | 33 | ##connection wireless 34 | - Disconnect the USB cable of the PS4 controller from the RaspberryPi 35 | >sudo bluetoothctl 36 | 37 | - very important the help, and general understanding of the bluetooth features, Pairing, Trusting, reconnecting,... 38 | 39 | >[bluetooth]# help 40 | 41 | >[bluetooth]# agent on 42 | 43 | >[bluetooth]# default-agent 44 | 45 | >[bluetooth]# scan on 46 | 47 | starts a scan for available devices, at this step, you should : 48 | - Switch off the PS4 console and unplug its cable so that it does not use the controlled you try to pair with the Pi 49 | - Kepp pressing the PS4 controller's "share" button, then the "Home PS" button until the light starts quickly flashing from time to time 50 | - the should appear a line in the scan 51 | 52 | >[NEW]Device 1C:66:6D:XX:XX:XX Wireless Controller 53 | 54 | - copy and paste the mac of the Wireless Controller after the connect command (XX replaced with custom values) 55 | 56 | >connect 1C:66:6D:XX:XX:XX 57 | 58 | >Attempting to connect to,..., connected : yes, paired : yes, Connection successful 59 | 60 | - you can then turn the scan off otherwise it might disturb the bluetooth communication 61 | 62 | >[bluetooth]# scan off 63 | 64 | - now the Joystick should appear again in the input list, the rest of the usage is identical to the USB connected mode 65 | 66 | >ls /dev/input 67 | > event2 js0 68 | 69 | - To switch off the PS4 controller, a long press on the home button is needed (around 10s) 70 | - Switching it on back again seams to reconnect at once, as the device is listed as trusted 71 | -------------------------------------------------------------------------------- /listen.bat: -------------------------------------------------------------------------------- 1 | REM script COM nodeid channel 2 | python raspi_mesh_server\hci_client\client.py COM4 27 10 -l -------------------------------------------------------------------------------- /nRF51_Beacon/.gitignore: -------------------------------------------------------------------------------- 1 | _build 2 | -------------------------------------------------------------------------------- /nRF51_Beacon/Makefile: -------------------------------------------------------------------------------- 1 | PROJECT_NAME := mesh_sensors_node 2 | TARGETS := nrf51822_xxaa 3 | OUTPUT_DIRECTORY := _build 4 | 5 | SDK_ROOT := ./nRF5_SDK_12.3.0_prf 6 | PROJ_DIR := . 7 | 8 | $(OUTPUT_DIRECTORY)/nrf51822_xxaa.out: \ 9 | LINKER_SCRIPT := esb_low_power_ptx_gcc_nrf51_aa.ld 10 | 11 | # Source files common to all targets 12 | SRC_FILES += \ 13 | $(SDK_ROOT)/components/libraries/log/src/nrf_log_backend_serial.c \ 14 | $(SDK_ROOT)/components/libraries/log/src/nrf_log_frontend.c \ 15 | $(SDK_ROOT)/components/libraries/util/app_error.c \ 16 | $(SDK_ROOT)/components/libraries/util/app_error_weak.c \ 17 | $(SDK_ROOT)/components/libraries/util/app_util_platform.c \ 18 | $(SDK_ROOT)/components/libraries/util/nrf_assert.c \ 19 | $(SDK_ROOT)/components/libraries/util/sdk_errors.c \ 20 | $(SDK_ROOT)/components/boards/boards.c \ 21 | $(SDK_ROOT)/components/drivers_nrf/common/nrf_drv_common.c \ 22 | $(SDK_ROOT)/components/drivers_nrf/uart/nrf_drv_uart.c \ 23 | $(PROJ_DIR)/main.c \ 24 | $(SDK_ROOT)/external/segger_rtt/RTT_Syscalls_GCC.c \ 25 | $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT.c \ 26 | $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT_printf.c \ 27 | $(SDK_ROOT)/components/proprietary_rf/esb/nrf_esb.c \ 28 | $(SDK_ROOT)/components/toolchain/gcc/gcc_startup_nrf51.S \ 29 | $(SDK_ROOT)/components/toolchain/system_nrf51.c \ 30 | 31 | # Include folders common to all targets 32 | INC_FOLDERS += \ 33 | $(SDK_ROOT)/components \ 34 | $(SDK_ROOT)/components/libraries/util \ 35 | $(SDK_ROOT)/components/toolchain/gcc \ 36 | $(SDK_ROOT)/components/drivers_nrf/uart \ 37 | ../config \ 38 | $(SDK_ROOT)/components/drivers_nrf/common \ 39 | $(SDK_ROOT)/components/proprietary_rf/esb \ 40 | $(PROJ_DIR) \ 41 | $(SDK_ROOT)/external/segger_rtt \ 42 | $(SDK_ROOT)/components/libraries/bsp \ 43 | $(SDK_ROOT)/components/drivers_nrf/nrf_soc_nosd \ 44 | $(SDK_ROOT)/components/toolchain \ 45 | $(SDK_ROOT)/components/device \ 46 | $(SDK_ROOT)/components/libraries/log \ 47 | $(SDK_ROOT)/components/boards \ 48 | $(SDK_ROOT)/components/drivers_nrf/delay \ 49 | $(SDK_ROOT)/components/toolchain/cmsis/include \ 50 | $(SDK_ROOT)/components/drivers_nrf/hal \ 51 | $(SDK_ROOT)/components/libraries/log/src \ 52 | 53 | # Libraries common to all targets 54 | LIB_FILES += \ 55 | 56 | # C flags common to all targets 57 | CFLAGS += -DNRF51 58 | CFLAGS += -DBOARD_CUSTBEACON01 59 | CFLAGS += -DESB_PRESENT 60 | CFLAGS += -DNRF51822 61 | CFLAGS += -DBSP_DEFINES_ONLY 62 | CFLAGS += -mcpu=cortex-m0 63 | CFLAGS += -mthumb -mabi=aapcs 64 | CFLAGS += -Wall -Werror -O3 -g3 65 | CFLAGS += -mfloat-abi=soft 66 | # keep every function in separate section, this allows linker to discard unused ones 67 | CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing 68 | CFLAGS += -fno-builtin --short-enums 69 | 70 | # C++ flags common to all targets 71 | CXXFLAGS += \ 72 | 73 | # Assembler flags common to all targets 74 | ASMFLAGS += -x assembler-with-cpp 75 | ASMFLAGS += -DNRF51 76 | ASMFLAGS += -DBOARD_CUSTBEACON01 77 | ASMFLAGS += -DESB_PRESENT 78 | ASMFLAGS += -DNRF51822 79 | ASMFLAGS += -DBSP_DEFINES_ONLY 80 | 81 | # Linker flags 82 | LDFLAGS += -mthumb -mabi=aapcs -L $(TEMPLATE_PATH) -T$(LINKER_SCRIPT) 83 | LDFLAGS += -mcpu=cortex-m0 84 | # let linker to dump unused sections 85 | LDFLAGS += -Wl,--gc-sections 86 | # use newlib in nano version 87 | LDFLAGS += --specs=nano.specs -lc -lnosys 88 | 89 | 90 | .PHONY: $(TARGETS) default all clean help flash 91 | 92 | # Default target - first one defined 93 | default: nrf51822_xxaa 94 | 95 | # Print all targets that can be built 96 | help: 97 | @echo following targets are available: 98 | @echo nrf51822_xxaa 99 | 100 | TEMPLATE_PATH := $(SDK_ROOT)/components/toolchain/gcc 101 | 102 | include $(TEMPLATE_PATH)/Makefile.common 103 | 104 | $(foreach target, $(TARGETS), $(call define_target, $(target))) 105 | 106 | # Flash the program 107 | flash: $(OUTPUT_DIRECTORY)/nrf51822_xxaa.hex 108 | @echo Flashing: $< 109 | nrfjprog --program $< -f nrf51 --sectorerase 110 | nrfjprog --reset -f nrf51 111 | 112 | erase: 113 | nrfjprog --eraseall -f nrf51 114 | -------------------------------------------------------------------------------- /nRF51_Beacon/debug.bat: -------------------------------------------------------------------------------- 1 | JLink.exe -device NRF51822_XXAA -SelectEmuBySN %SEG_JLEDU% -If SWD -Speed 4000 2 | -------------------------------------------------------------------------------- /nRF51_Beacon/debug.jdebug.user: -------------------------------------------------------------------------------- 1 | OpenWindow="Registers", DockArea=LEFT, x=0, y=1, w=1021, h=1409, FilterBarShown=0, 2 | OpenWindow="Console", DockArea=RIGHT, x=0, y=1, w=733, h=263, FilterBarShown=0, 3 | OpenWindow="Watched Data", DockArea=RIGHT, x=0, y=0, w=733, h=1367, FilterBarShown=0, 4 | OpenWindow="Breakpoints", DockArea=LEFT, x=0, y=0, w=1021, h=248, FilterBarShown=0, 5 | OpenWindow="Functions", DockArea=LEFT, x=0, y=1, w=1021, h=1409, FilterBarShown=1, 6 | OpenWindow="Call Stack", DockArea=RIGHT, x=0, y=1, w=733, h=263, FilterBarShown=0, 7 | OpenWindow="Disassembly", DockArea=RIGHT, x=0, y=0, w=733, h=1367, FilterBarShown=0, ExecCountersShown=0 8 | OpenToolbar="Debug", Floating=0, x=0, y=0 9 | TableHeader="Registers", SortCol="Name", SortOrder="ASCENDING", VisibleCols=["Name";"Value";"Description"], ColWidths=[246;132;1283] 10 | TableHeader="Watched Data", SortCol="Expression", SortOrder="ASCENDING", VisibleCols=["Expression";"Value";"Location";"Size";"Refresh";"Type"], ColWidths=[133;134;134;74;105;80] 11 | TableHeader="Breakpoints", SortCol="State", SortOrder="ASCENDING", VisibleCols=["State";"Location";"Permitted Impl.";"Actual Impl.";"Context";"Task Filter";"Skip #";"Condition"], ColWidths=[85;242;176;145;686;128;96;122] 12 | TableHeader="Functions", SortCol="Address", SortOrder="ASCENDING", VisibleCols=["Name";"Address";"Size";"#Insts";"Source"], ColWidths=[275;122;74;96;73] 13 | TableHeader="Call Stack", SortCol="Function", SortOrder="ASCENDING", VisibleCols=["Function";"Stack Info";"Source"], ColWidths=[182;170;288] 14 | -------------------------------------------------------------------------------- /nRF51_Beacon/esb_low_power_ptx_gcc_nrf51_aa.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x40000 9 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x4000 10 | } 11 | 12 | SECTIONS 13 | { 14 | .fs_data : 15 | { 16 | PROVIDE(__start_fs_data = .); 17 | KEEP(*(.fs_data)) 18 | PROVIDE(__stop_fs_data = .); 19 | } > RAM 20 | .pwr_mgmt_data : 21 | { 22 | PROVIDE(__start_pwr_mgmt_data = .); 23 | KEEP(*(.pwr_mgmt_data)) 24 | PROVIDE(__stop_pwr_mgmt_data = .); 25 | } > RAM 26 | } INSERT AFTER .data; 27 | 28 | INCLUDE "nrf5x_common.ld" 29 | -------------------------------------------------------------------------------- /nRF51_Beacon/jlink/jlflash.jlink: -------------------------------------------------------------------------------- 1 | loadfile _build\nrf51822_xxaa.hex 2 | exit 3 | -------------------------------------------------------------------------------- /nRF51_Beacon/jlink/power_off.jlink: -------------------------------------------------------------------------------- 1 | power off 2 | exit 3 | -------------------------------------------------------------------------------- /nRF51_Beacon/jlink/power_on.jlink: -------------------------------------------------------------------------------- 1 | power on 2 | exit 3 | -------------------------------------------------------------------------------- /nRF51_Beacon/off.bat: -------------------------------------------------------------------------------- 1 | jlink -CommandFile jlink\power_off.jlink 2 | -------------------------------------------------------------------------------- /nRF51_Beacon/on.bat: -------------------------------------------------------------------------------- 1 | jlink -CommandFile jlink\power_on.jlink 2 | -------------------------------------------------------------------------------- /nRF51_Beacon/readme.md: -------------------------------------------------------------------------------- 1 | # nRF51 Sensor Tag 2 | * Soc : nRF51822 QF AA 3 | * BMP180 4 | * MPU6050 5 | * AP3216 6 | 7 | # Board PIO connections -------------------------------------------------------------------------------- /nRF51_Beacon/test.bat: -------------------------------------------------------------------------------- 1 | nrfjprog --readregs -f nrf52 2 | -------------------------------------------------------------------------------- /nRF51_Sensors/.gitignore: -------------------------------------------------------------------------------- 1 | _build 2 | -------------------------------------------------------------------------------- /nRF51_Sensors/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "sdk_common.h": "c", 4 | "app_util.h": "c" 5 | } 6 | } -------------------------------------------------------------------------------- /nRF51_Sensors/ap3216c/ap3216c.c: -------------------------------------------------------------------------------- 1 | #include "ap3216c.h" 2 | 3 | #include "twi_master.h" 4 | #include "nrf_delay.h" 5 | 6 | uint8_t dynamic_range = 1; 7 | 8 | #define AP_DEVICE_WRITE_ADD 0x3C 9 | 10 | bool ap_write_reg(uint8_t reg_addr, uint8_t reg_val) 11 | { 12 | uint8_t w2_data[2]; 13 | 14 | w2_data[0] = reg_addr; 15 | w2_data[1] = reg_val; 16 | 17 | bool res = twi_master_transfer(AP_DEVICE_WRITE_ADD, w2_data, 2, TWI_ISSUE_STOP); 18 | 19 | return res; 20 | } 21 | 22 | bool ap_read_data(uint8_t reg_addr, uint8_t *reg_data, uint8_t count) 23 | { 24 | bool res = twi_master_transfer(AP_DEVICE_WRITE_ADD, ®_addr, 1, TWI_DONT_ISSUE_STOP); 25 | res &= twi_master_transfer(AP_DEVICE_WRITE_ADD|TWI_READ_BIT, reg_data, count, TWI_ISSUE_STOP); 26 | 27 | return res; 28 | } 29 | 30 | void ap_dump_regs() 31 | { 32 | 33 | } 34 | 35 | bool ap_test() 36 | { 37 | bool res; 38 | uint8_t reg_data[16]; 39 | reg_data[0] = 0;//write crash test 40 | res = ap_read_data( 0x00, reg_data, 16); 41 | 42 | res &= ap_read_data( 0x19, reg_data, 5); 43 | 44 | res &= ap_write_reg(0x10,0x30);//11 in bits 5:4 of ALS Configuration 45 | 46 | reg_data[0] = 0; 47 | res &= ap_read_data( 0x10, reg_data, 1); 48 | 49 | return res; 50 | } 51 | 52 | bool ap_reset() 53 | { 54 | const uint8_t AP_REG_SYS_CONF = 0x00; 55 | bool res; 56 | res = ap_write_reg(AP_REG_SYS_CONF,0x04);//SW reset 57 | nrf_delay_ms(11);//datasheet require 10 ms 58 | 59 | return res; 60 | } 61 | 62 | uint32_t last_measure = 20661; 63 | 64 | bool ap_measure_light() 65 | { 66 | const uint8_t AP_ALS_CONF = 0x10; 67 | if(last_measure < 300) 68 | { 69 | dynamic_range = 4; 70 | ap_write_reg(AP_ALS_CONF,0x30); 71 | } 72 | else if(last_measure < 1200) 73 | { 74 | dynamic_range = 3; 75 | ap_write_reg(AP_ALS_CONF,0x20); 76 | } 77 | else if(last_measure < 5100) 78 | { 79 | dynamic_range = 2; 80 | ap_write_reg(AP_ALS_CONF,0x10); 81 | } 82 | else 83 | { 84 | dynamic_range = 1; 85 | ap_write_reg(AP_ALS_CONF,0x00); 86 | } 87 | const uint8_t AP_REG_SYS_CONF = 0x00; 88 | return ap_write_reg(AP_REG_SYS_CONF,0x05);//ALS function once - power down automatically after 2.5 periods (250 ms) 89 | } 90 | 91 | bool ap_get_light(uint8_t *data) 92 | { 93 | const uint8_t AP_REG_ALS_DATA_LOW = 0x0C; 94 | //data[0] <= ALS Data Low 95 | //data[1] <= ALS Data High 96 | bool res = ap_read_data(AP_REG_ALS_DATA_LOW,data,2); 97 | uint32_t klux = data[1]; 98 | klux *=256; 99 | klux = klux + data[0]; 100 | klux *=1000; 101 | float f_klux = klux; 102 | switch(dynamic_range) 103 | { 104 | case 1:{ 105 | f_klux = f_klux * 0.35; 106 | }break; 107 | case 2:{ 108 | f_klux = f_klux * 0.0788; 109 | }break; 110 | case 3:{ 111 | f_klux = f_klux * 0.0197; 112 | }break; 113 | case 4:{ 114 | f_klux = f_klux * 0.0049; 115 | }break; 116 | } 117 | last_measure = f_klux; 118 | 119 | 120 | uint8_t *pData = (uint8_t*)&last_measure; 121 | data[0] = pData[0]; 122 | data[1] = pData[1]; 123 | data[2] = pData[2]; 124 | data[3] = pData[3]; 125 | 126 | return res; 127 | } 128 | -------------------------------------------------------------------------------- /nRF51_Sensors/ap3216c/ap3216c.h: -------------------------------------------------------------------------------- 1 | #ifndef AP3216C_H 2 | #define AP3216C_H 3 | 4 | #include 5 | #include 6 | 7 | bool ap_reset(); 8 | 9 | bool ap_measure_light(); 10 | bool ap_get_light(uint8_t *data); 11 | 12 | #endif /*AP3216C_H*/ -------------------------------------------------------------------------------- /nRF51_Sensors/beacon_project/.gitignore: -------------------------------------------------------------------------------- 1 | _build 2 | -------------------------------------------------------------------------------- /nRF51_Sensors/beacon_project/debug.jdebug.user: -------------------------------------------------------------------------------- 1 | OpenWindow="Call Stack", DockArea=RIGHT, x=0, y=1, w=733, h=263, FilterBarShown=0, 2 | OpenWindow="Watched Data", DockArea=RIGHT, x=0, y=0, w=733, h=1414, FilterBarShown=0, 3 | OpenWindow="Functions", DockArea=LEFT, x=0, y=1, w=1021, h=1410, FilterBarShown=1, 4 | OpenWindow="Disassembly", DockArea=RIGHT, x=0, y=0, w=733, h=1414, FilterBarShown=0, ExecCountersShown=0 5 | OpenWindow="Registers", DockArea=LEFT, x=0, y=1, w=1021, h=1410, FilterBarShown=0, 6 | OpenWindow="Console", DockArea=RIGHT, x=0, y=1, w=733, h=263, FilterBarShown=0, 7 | OpenWindow="Breakpoints", DockArea=LEFT, x=0, y=0, w=1021, h=294, FilterBarShown=0, 8 | OpenToolbar="Debug", Floating=0, x=0, y=0 9 | TableHeader="Call Stack", SortCol="Function", SortOrder="ASCENDING", VisibleCols=["Function";"Stack Info";"Source"], ColWidths=[182;170;381] 10 | TableHeader="Watched Data", SortCol="Expression", SortOrder="ASCENDING", VisibleCols=["Expression";"Value";"Location";"Size";"Refresh";"Type"], ColWidths=[133;134;134;74;105;153] 11 | TableHeader="Functions", SortCol="Address", SortOrder="ASCENDING", VisibleCols=["Name";"Address";"Size";"#Insts";"Source"], ColWidths=[275;122;74;96;428] 12 | TableHeader="Registers", SortCol="Name", SortOrder="ASCENDING", VisibleCols=["Name";"Value";"Description"], ColWidths=[135;132;754] 13 | TableHeader="Breakpoints", SortCol="State", SortOrder="ASCENDING", VisibleCols=["State";"Location";"Permitted Impl.";"Actual Impl.";"Context";"Task Filter";"Skip #";"Condition"], ColWidths=[85;242;176;145;686;128;96;122] 14 | -------------------------------------------------------------------------------- /nRF51_Sensors/bmp180/README.md: -------------------------------------------------------------------------------- 1 | 2 | CONTENTS OF THIS FILE 3 | ======================= 4 | * Introduction 5 | * Version 6 | * Integration details 7 | * Driver files information 8 | * Supported sensor interface 9 | * Copyright 10 | 11 | 12 | INTRODUCTION 13 | =============== 14 | - This package contains the Bosch Sensortec MEMS pressure sensor driver (sensor API) 15 | - The sensor driver package includes bmp180.h, bmp180.c and bmp180_support.c files 16 | 17 | VERSION 18 | ========= 19 | - Version of bmp180 sensor driver is: 20 | * bmp180.c - V2.0.3 21 | * bmp180.h - V2.2.2 22 | * bmp180_support.c - V1.0.4 23 | 24 | INTEGRATION DETAILS 25 | ===================== 26 | - Integrate bmp180.h and bmp180.c file in to your project. 27 | - The bmp180_support.c file contains only examples for API use cases, so it is not required to integrate into project. 28 | 29 | DRIVER FILES INFORMATION 30 | =========================== 31 | bmp180.h 32 | ----------- 33 | * This header file has the register address definition, constant definitions, data type definition and supported sensor driver calls declarations. 34 | 35 | bmp180.c 36 | ------------ 37 | * This file contains the implementation for the sensor driver APIs. 38 | 39 | bmp180_support.c 40 | ---------------------- 41 | * This file shall be used as an user guidance, here you can find samples of 42 | * Initialize the sensor with I2C communication 43 | - Add your code to the I2C bus read and bus write functions. 44 | - Return value can be chosen by yourself 45 | - API just passes that value to your application code 46 | - Add your code to the delay function 47 | * Reading the sensor read out data 48 | 49 | SUPPORTED SENSOR INTERFACE 50 | ==================================== 51 | - This pressure sensor driver supports I2C interface 52 | 53 | 54 | COPYRIGHT 55 | =========== 56 | - Copyright (C) 2008 - 2015 Bosch Sensortec GmbH 57 | 58 | 59 | -------------------------------------------------------------------------------- /nRF51_Sensors/bmp180/bmp180_app.h: -------------------------------------------------------------------------------- 1 | #ifndef BMP180_APP_H 2 | #define BMP180_APP_H 3 | 4 | #include 5 | 6 | void bmp_dump_regs();//TODO 7 | 8 | bool bmp_init(); 9 | 10 | void bmp_measure();//TODO 11 | 12 | void bmp_get_temperature(uint8_t *data); 13 | 14 | void bmp_get_pressure(uint8_t *data); 15 | 16 | #endif /*BMP180_APP_H*/ -------------------------------------------------------------------------------- /nRF51_Sensors/debug.bat: -------------------------------------------------------------------------------- 1 | JLink.exe -device NRF51822_XXAA -SelectEmuBySN %SEG_JLEDU% -If SWD -Speed 4000 2 | -------------------------------------------------------------------------------- /nRF51_Sensors/debug.jdebug.user: -------------------------------------------------------------------------------- 1 | OpenWindow="Call Stack", DockArea=RIGHT, x=0, y=1, w=733, h=267, FilterBarShown=0, 2 | OpenWindow="Watched Data", DockArea=RIGHT, x=0, y=0, w=733, h=1410, FilterBarShown=0, 3 | OpenWindow="Functions", DockArea=LEFT, x=0, y=1, w=1021, h=1430, FilterBarShown=1, 4 | OpenWindow="Disassembly", DockArea=RIGHT, x=0, y=0, w=733, h=1410, FilterBarShown=0, ExecCountersShown=0 5 | OpenWindow="Registers", DockArea=LEFT, x=0, y=1, w=1021, h=1430, FilterBarShown=0, 6 | OpenWindow="Console", DockArea=RIGHT, x=0, y=1, w=733, h=267, FilterBarShown=0, 7 | OpenWindow="Breakpoints", DockArea=LEFT, x=0, y=0, w=1021, h=274, FilterBarShown=0, 8 | OpenToolbar="Debug", Floating=0, x=0, y=0 9 | TableHeader="Call Stack", SortCol="Function", SortOrder="ASCENDING", VisibleCols=["Function";"Stack Info";"Source"], ColWidths=[182;170;381] 10 | TableHeader="Watched Data", SortCol="Expression", SortOrder="ASCENDING", VisibleCols=["Expression";"Value";"Location";"Size";"Refresh";"Type"], ColWidths=[133;134;134;74;105;153] 11 | TableHeader="Functions", SortCol="Address", SortOrder="ASCENDING", VisibleCols=["Name";"Address";"Size";"#Insts";"Source"], ColWidths=[275;122;74;96;428] 12 | TableHeader="Registers", SortCol="Name", SortOrder="ASCENDING", VisibleCols=["Name";"Value";"Description"], ColWidths=[246;132;392] 13 | TableHeader="Breakpoints", SortCol="State", SortOrder="ASCENDING", VisibleCols=["State";"Location";"Permitted Impl.";"Actual Impl.";"Context";"Task Filter";"Skip #";"Condition"], ColWidths=[85;242;176;145;686;128;96;122] 14 | -------------------------------------------------------------------------------- /nRF51_Sensors/doc/sensor_tag_sch_mpu6050.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HomeSmartMesh/IoT_Frameworks/411dfba86d012bd757b3fc4d430f1f53a979f294/nRF51_Sensors/doc/sensor_tag_sch_mpu6050.pdf -------------------------------------------------------------------------------- /nRF51_Sensors/esb_low_power_ptx_gcc_nrf51_aa.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x40000 9 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x4000 10 | } 11 | 12 | SECTIONS 13 | { 14 | .fs_data : 15 | { 16 | PROVIDE(__start_fs_data = .); 17 | KEEP(*(.fs_data)) 18 | PROVIDE(__stop_fs_data = .); 19 | } > RAM 20 | .pwr_mgmt_data : 21 | { 22 | PROVIDE(__start_pwr_mgmt_data = .); 23 | KEEP(*(.pwr_mgmt_data)) 24 | PROVIDE(__stop_pwr_mgmt_data = .); 25 | } > RAM 26 | } INSERT AFTER .data; 27 | 28 | INCLUDE "nrf5x_common.ld" 29 | -------------------------------------------------------------------------------- /nRF51_Sensors/jlflash.jlink: -------------------------------------------------------------------------------- 1 | loadfile _build\nrf51822_xxaa.hex 2 | exit 3 | -------------------------------------------------------------------------------- /nRF51_Sensors/mpu6050_app/mpu6050_app.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "mpu6050_app.h" 4 | #include "mpu6050.h" 5 | #include "mpu60x0_register_map.h" 6 | #include "twi_master.h" 7 | 8 | #ifdef NRF_LOG_USES_RTT 9 | #include "SEGGER_RTT.h" 10 | #define DEBUG_PRINTF(...) SEGGER_RTT_printf(0, __VA_ARGS__) 11 | #else 12 | #define DEBUG_PRINTF(...) 13 | #endif 14 | 15 | void mpu_dump_regs() 16 | { 17 | #ifdef NRF_LOG_USES_RTT 18 | bool res; 19 | uint8_t data_reg; 20 | res = mpu6050_register_read(MPU_REG_PWR_MGMT_1,&data_reg,1); 21 | DEBUG_PRINTF("MPU_REG_PWR_MGMT_1(%d) = 0x%02X\r\n",res,data_reg); 22 | res = mpu6050_register_read(MPU_REG_PWR_MGMT_2,&data_reg,1); 23 | DEBUG_PRINTF("MPU_REG_PWR_MGMT_2(%d) = 0x%02X\r\n",res,data_reg); 24 | 25 | #endif 26 | } 27 | 28 | void mpu_start() 29 | { 30 | #ifdef NRF_LOG_USES_RTT 31 | bool res_twi = twi_master_init(); 32 | DEBUG_PRINTF("twi_master_init(%d)\r\n",res_twi); 33 | 34 | bool res = mpu6050_init(0x69);//0x69 35 | DEBUG_PRINTF("mpu @ 0x69 => (%d)\r\n",res); 36 | #else 37 | twi_master_init(); 38 | mpu6050_init(0x69);//0x69 39 | #endif 40 | 41 | mpu_dump_regs(); 42 | 43 | //config = 6 ; Bandwidth : Accel 5 Hz, Gyro 5 Hz 44 | mpu6050_register_write(MPU_REG_CONFIG,6); 45 | //FS_SEL = 0 => 250°/s (lowest) 46 | mpu6050_register_write(MPU_REG_GYRO_CONFIG,0); // same as reset value 47 | //AFS_SEL = 0 => +- 2g (lowest) 48 | mpu6050_register_write(MPU_REG_ACCEL_CONFIG,0); // same as reset value 49 | 50 | //wakeup 51 | //0x08 : TEMP_DIS => disable temperature 52 | //0x20 : CYCLE wake up every period 53 | //0x00 : Internal 8 MHz oscillator 54 | mpu6050_register_write(MPU_REG_PWR_MGMT_1,0x28);//8 : TEMP_DIS - awake 55 | //channels standby modes 0x38 Accel ; 0x07 Gyro 56 | //LP_WAKE_CTRL 0 = 1.25 Hz 57 | mpu6050_register_write(MPU_REG_PWR_MGMT_2,0x07);//0x07 Gyro in standby 58 | 59 | } 60 | 61 | void mpu_wakeup() 62 | { 63 | //wakeup 64 | //8 : TEMP_DIS => disable temperature 65 | mpu6050_register_write(MPU_REG_PWR_MGMT_1,0x08);//8 : TEMP_DIS - awake 66 | } 67 | 68 | void mpu_sleep() 69 | { 70 | mpu6050_register_write(MPU_REG_PWR_MGMT_1,0x48);//0x48 => sleep 71 | } 72 | 73 | void mpu_get_accell_xyz(int8_t *x,int8_t *y,int8_t *z) 74 | { 75 | uint8_t accell[5]; 76 | //XH,XL ; YH,YL ; ZH,ZL 77 | mpu6050_register_read(MPU_REG_ACCEL_XOUT_H,accell,5);//need only high 78 | //DEBUG_PRINTF("0x%02X 0x%02X ; 0x%02X 0x%02X ; 0x%02X 0x%02X\r\n", 79 | // accell[0],accell[1],accell[2], 80 | // accell[3],accell[4],accell[5]); 81 | *x = accell[0]; 82 | *y = accell[2]; 83 | *z = accell[4]; 84 | } 85 | 86 | void mpu_get_accell_data(uint8_t *data) 87 | { 88 | //XH,XL ; YH,YL ; ZH,ZL 89 | mpu6050_register_read(MPU_REG_ACCEL_XOUT_H,data,6); 90 | } -------------------------------------------------------------------------------- /nRF51_Sensors/mpu6050_app/mpu6050_app.h: -------------------------------------------------------------------------------- 1 | #ifndef MPU6050_APP_H 2 | #define MPU6050_APP_H 3 | 4 | #include 5 | 6 | void mpu_dump_regs(); 7 | 8 | void mpu_start();//also wakes up 9 | 10 | void mpu_wakeup(); 11 | 12 | void mpu_sleep(); 13 | 14 | void mpu_get_accell_xyz(int8_t *x,int8_t *y,int8_t *z); 15 | void mpu_get_accell_data(uint8_t *data); 16 | 17 | #endif /*MPU6050_APP_H*/ -------------------------------------------------------------------------------- /nRF51_Sensors/readme.md: -------------------------------------------------------------------------------- 1 | # nRF51 Sensor Tag 2 | * Soc : nRF51822 QF AA 3 | * BMP180 4 | * MPU6050 5 | * AP3216 6 | 7 | # Board PIO connections 8 | 9 | [wiki](http://linksprite.com/wiki/index.php5?title=Bluetooth_4.0_BLE_Sensor_Tag/iBeacon_Station_NRF51822) 10 | -------------------------------------------------------------------------------- /nRF51_Sensors/twi_master_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, 7 | * are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form, except as embedded into a Nordic 13 | * Semiconductor ASA integrated circuit in a product or a software update for 14 | * such product, must reproduce the above copyright notice, this list of 15 | * conditions and the following disclaimer in the documentation and/or other 16 | * materials provided with the distribution. 17 | * 18 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its 19 | * contributors may be used to endorse or promote products derived from this 20 | * software without specific prior written permission. 21 | * 22 | * 4. This software, with or without modification, must only be used with a 23 | * Nordic Semiconductor ASA integrated circuit. 24 | * 25 | * 5. Any software provided in binary form under this license must not be reverse 26 | * engineered, decompiled, modified and/or disassembled. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 29 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 30 | * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 31 | * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 32 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 33 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 34 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 37 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | * 39 | */ 40 | #ifndef TWI_MASTER_CONFIG 41 | #define TWI_MASTER_CONFIG 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | #include "boards.h" 48 | #include "nrf51_bitfields.h" 49 | 50 | #define TWI_MASTER_CONFIG_CLOCK_PIN_NUMBER (I2C_SCL) 51 | #define TWI_MASTER_CONFIG_DATA_PIN_NUMBER (I2C_SDA) 52 | 53 | //TWI_FREQUENCY_FREQUENCY_K100 TWI_FREQUENCY_FREQUENCY_K400 54 | #define TWI_MASTER_CONFIG_FREQ TWI_FREQUENCY_FREQUENCY_K400 55 | 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /raspi_mesh_server/cpp_mqtt_ruler/.gitignore: -------------------------------------------------------------------------------- 1 | mqtt_ruler 2 | -------------------------------------------------------------------------------- /raspi_mesh_server/cpp_mqtt_ruler/SConstruct: -------------------------------------------------------------------------------- 1 | # - Glob() adds all the files with the extension to the list 2 | # - CPPPATH define the path where to look for source files which have include dependendcies 3 | # so that when these include files change, a recompilation of the source file is triggered 4 | # CPPPATH = ['include', '/home/project/inc'] 5 | Program('mqtt_ruler', 6 | Glob('*.cpp'), 7 | CPPPATH = ['.'], 8 | CCFLAGS = ['-std=c++11'], 9 | LIBS=['libmosquittopp'], 10 | LIBPATH='/usr/local/lib/', 11 | LINKFLAGS=[] 12 | ) 13 | -------------------------------------------------------------------------------- /raspi_mesh_server/cpp_mqtt_ruler/configfile.txt: -------------------------------------------------------------------------------- 1 | #____________________________________________________________________________________________ 2 | # ! Important ! Format ! 3 | #____________________________________________________________________________________________ 4 | # every variable starts with the beginning of the line, no spaces, no space betweem '=' sign 5 | #____________________________________________________________________________________________ 6 | 7 | # -------------- Log -------------- 8 | # The "logfile" is optionnal used for persistance 9 | logfile=/home/pi/share/mqtt_ruler_log.txt 10 | 11 | # 'level_out' is for console mode, and the 'level_file' is for the file record 12 | #Error:1, Warning:2, Info:3, Debug:4 13 | # default level_out is 14 | level_out=4 15 | level_file=2 16 | 17 | # -------------- MQTT Client -------------- 18 | #Optionnal publishing to Mqtt Broquer 19 | #Enabled when both 'mqtt_host' and 'mqtt_port' are available 20 | mqtt_host=localhost 21 | mqtt_port=1883 22 | -------------------------------------------------------------------------------- /raspi_mesh_server/cpp_mqtt_ruler/log.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2017 Wassim Filali 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | 24 | ___________________________________________________________________________________ 25 | dependencies : 26 | - bme_280 with datasheet's associated rights see bme280_server.hpp 27 | ___________________________________________________________________________________ 28 | 29 | start date : 19.02.2017 30 | 31 | logger 32 | 33 | */ 34 | 35 | #include 36 | //for file 37 | #include 38 | //for stringstream 39 | #include 40 | 41 | #include 42 | #include 43 | #include 44 | 45 | #include "utils.hpp" 46 | 47 | class Log 48 | { 49 | public: 50 | static const int loglevel_None ; 51 | static const int loglevel_Error ; 52 | static const int loglevel_Warning ; 53 | static const int loglevel_Info ; 54 | static const int loglevel_Debug ; 55 | public: 56 | static bool config(strmap &conf); 57 | public: 58 | static int fd; 59 | public: 60 | static std::ofstream logfile; 61 | static std::stringstream cout; 62 | static bool isLogFile; 63 | static bool isLogOut; 64 | static bool isReady; 65 | static int level_file; 66 | static int level_out; 67 | public: 68 | static void log(const std::string &str,const int &level); 69 | static std::string Error(); 70 | static std::string Warning(); 71 | static std::string Info(); 72 | static std::string Debug(); 73 | 74 | }; 75 | 76 | -------------------------------------------------------------------------------- /raspi_mesh_server/cpp_mqtt_ruler/test/SConstruct: -------------------------------------------------------------------------------- 1 | # - Glob() adds all the files with the extension to the list 2 | # - CPPPATH define the path where to look for source files which have include dependendcies 3 | # so that when these include files change, a recompilation of the source file is triggered 4 | # CPPPATH = ['include', '/home/project/inc'] 5 | Program('mqtt_test', 6 | Glob('*.cpp'), 7 | CPPPATH = ['.'], 8 | CCFLAGS = ['-std=c++11'], 9 | LIBS=['libmosquittopp'], 10 | LIBPATH='/usr/local/lib/', 11 | LINKFLAGS=[] 12 | ) 13 | -------------------------------------------------------------------------------- /raspi_mesh_server/cpp_mqtt_ruler/test/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2017 Wassim Filali 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | 24 | ___________________________________________________________________________________ 25 | dependencies : 26 | - Mosquitto 27 | 28 | ___________________________________________________________________________________ 29 | 30 | start date : 04.03.2017 31 | 32 | test for simplest mosquitto transactions 33 | 34 | 35 | */ 36 | 37 | 38 | //for usleep() sleep() 39 | #include 40 | //#include 41 | //for printf 42 | #include 43 | //for stdout 44 | #include 45 | //for file 46 | #include 47 | 48 | #include 49 | #include 50 | 51 | class mqtt_test : public mosqpp::mosquittopp 52 | { 53 | public: 54 | mqtt_test(const char *id, const char *host, int port); 55 | ~mqtt_test(); 56 | 57 | void say_hello(); 58 | void on_connect(int rc); 59 | void on_message(const struct mosquitto_message *message); 60 | void on_subscribe(int mid, int qos_count, const int *granted_qos); 61 | }; 62 | 63 | mqtt_test::mqtt_test(const char *id, const char *host, int port) : mosquittopp(id) 64 | { 65 | int keepalive = 60; 66 | connect(host, port, keepalive); 67 | std::cout << "Construction" << std::endl; 68 | }; 69 | 70 | mqtt_test::~mqtt_test() 71 | { 72 | } 73 | 74 | void mqtt_test::on_connect(int rc) 75 | { 76 | std::cout << "My MQTT client is Connected (" << rc << ")" << std::endl; 77 | if(rc == 0) 78 | { 79 | //subscribe(NULL, "test/topic"); 80 | } 81 | } 82 | 83 | void mqtt_test::on_message(const struct mosquitto_message *message) 84 | { 85 | std::cout << "Received message with size " << message->payloadlen << std::endl; 86 | } 87 | 88 | void mqtt_test::on_subscribe(int mid, int qos_count, const int *granted_qos) 89 | { 90 | std::cout << "My MQTT client is Subscribed id " << mid << std::endl; 91 | } 92 | 93 | void mqtt_test::say_hello() 94 | { 95 | std::string hello_str = "Hello from my test"; 96 | publish(NULL, "test/topic", hello_str.size(), hello_str.c_str()); 97 | std::cout << "published hello message " << hello_str << std::endl; 98 | } 99 | 100 | 101 | int main( int argc, char** argv ) 102 | { 103 | std::cout << "Mosquitto test" << std::endl; 104 | 105 | mosqpp::lib_init(); 106 | 107 | mqtt_test MyMqtt("TestId","localhost",1883); 108 | 109 | MyMqtt.say_hello(); 110 | 111 | int haveToReconnect; 112 | while(true) 113 | { 114 | haveToReconnect = MyMqtt.loop(); 115 | if(haveToReconnect) 116 | { 117 | MyMqtt.reconnect(); 118 | } 119 | } 120 | mosqpp::lib_cleanup(); 121 | 122 | return 0; 123 | } 124 | -------------------------------------------------------------------------------- /raspi_mesh_server/cpp_server/.gitignore: -------------------------------------------------------------------------------- 1 | streamer 2 | -------------------------------------------------------------------------------- /raspi_mesh_server/cpp_server/.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Mac", 5 | "includePath": [ 6 | "/usr/include", 7 | "/usr/local/include", 8 | "${workspaceRoot}" 9 | ], 10 | "defines": [], 11 | "intelliSenseMode": "clang-x64", 12 | "browse": { 13 | "path": [ 14 | "/usr/include", 15 | "/usr/local/include", 16 | "${workspaceRoot}" 17 | ], 18 | "limitSymbolsToIncludedHeaders": true, 19 | "databaseFilename": "" 20 | }, 21 | "macFrameworkPath": [ 22 | "/System/Library/Frameworks", 23 | "/Library/Frameworks" 24 | ] 25 | }, 26 | { 27 | "name": "Linux", 28 | "includePath": [ 29 | "/usr/include", 30 | "/usr/local/include", 31 | "${workspaceRoot}" 32 | ], 33 | "defines": [], 34 | "intelliSenseMode": "clang-x64", 35 | "browse": { 36 | "path": [ 37 | "/usr/include", 38 | "/usr/local/include", 39 | "${workspaceRoot}" 40 | ], 41 | "limitSymbolsToIncludedHeaders": true, 42 | "databaseFilename": "" 43 | } 44 | }, 45 | { 46 | "name": "Win32", 47 | "includePath": [ 48 | "${workspaceRoot}", 49 | "${workspaceRoot}/pilibs", 50 | "D:/pi/include/c++/4.9" 51 | ], 52 | "defines": [ 53 | "_DEBUG", 54 | "UNICODE" 55 | ], 56 | "intelliSenseMode": "msvc-x64", 57 | "browse": { 58 | "path": [ 59 | "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include/*", 60 | "C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/ucrt", 61 | "${workspaceRoot}" 62 | ], 63 | "limitSymbolsToIncludedHeaders": true, 64 | "databaseFilename": "" 65 | } 66 | } 67 | ], 68 | "version": 3 69 | } -------------------------------------------------------------------------------- /raspi_mesh_server/cpp_server/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "xstring": "cpp", 4 | "iosfwd": "cpp", 5 | "xtree": "cpp", 6 | "xutility": "cpp" 7 | } 8 | } -------------------------------------------------------------------------------- /raspi_mesh_server/cpp_server/LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Wassim Filali 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /raspi_mesh_server/cpp_server/SConstruct: -------------------------------------------------------------------------------- 1 | # - Glob() adds all the files with the extension to the list 2 | # - CPPPATH define the path where to look for source files which have include dependendcies 3 | # so that when these include files change, a recompilation of the source file is triggered 4 | # CPPPATH = ['include', '/home/project/inc'] 5 | 6 | 7 | 8 | env = Environment() 9 | env.Program( target='streamer', 10 | source=[Glob('*.cpp'), 11 | [ 'pilibs/serial.cpp', 12 | 'pilibs/utils.cpp', 13 | 'pilibs/mesh.cpp', 14 | 'pilibs/mqtt.cpp', 15 | 'pilibs/webserver.cpp', 16 | 'pilibs/db_mgr.cpp', 17 | 'pilibs/bme280_server.cpp', 18 | 'pilibs/log.cpp' 19 | ], 20 | ], 21 | CPPPATH = ['.','pilibs/','/usr/local/include/Poco/'], 22 | CCFLAGS = ['-std=c++11'], 23 | LIBS=['libmosquittopp','libPocoNet','libPocoUtil','libPocoFoundation'], 24 | LIBPATH='/usr/local/lib/', 25 | LINKFLAGS=['-lboost_system','-lboost_filesystem'] 26 | ) 27 | -------------------------------------------------------------------------------- /raspi_mesh_server/cpp_server/help.txt: -------------------------------------------------------------------------------- 1 | help 2 | 3 | Command line examples 4 | './streamer param1=value1 param2=value2': 5 | './streamer configfile=configfile_webserver_test.txt': 6 | 7 | Parameters: 8 | 9 | - port: the serial device to be used 10 | Mandatory 11 | e.g 'port=/dev/ttyUSB0' 12 | 13 | - logfile: file where the logged data will be saved. 14 | Optionnal 15 | e.g 'logfile=logfile.txt' 16 | 17 | - logout: e.g 'logcmd=1' 18 | Optional 19 | 20 | - configfile: 21 | Optional if not provided, an attempt is made to read config from 'configfile.txt' if available. 22 | e.g 'configfile=conf2.txt' 23 | 24 | - websocket_url: 25 | Optional to send data through websocket 26 | e.g 'websocket_url=ws://192.168.1.14:8126/rf_logger' 27 | -------------------------------------------------------------------------------- /raspi_mesh_server/cpp_server/test_logs/2017.01.22 - server.txt: -------------------------------------------------------------------------------- 1 | pi@ioserv:~/IoT_Frameworks/sensors_logger/cpp_sensors_server $ ./streamer configfile=configfile_webserver_test.txt 2 | ______________________Config______________________ 3 | configfile = configfile_webserver_test.txt 4 | wsm> => websocket_url = ws://10.0.0.2:8127/rf_logger 5 | starting server at port : 8127 6 | wsm> X : No HTTP Post Client 7 | str> X :Serial Port not configured, will not be used 8 | dbm> X :'dbloadpaths' parameter not available, databse will not be used 9 | ______________________Main Loop______________________ 10 | wbs> ------------- => New HTTP request 11 | wbs> Request from 10.0.0.2:50820 -- method: POST -- uri: /rf_logger -- version: HTTP/1.1 12 | Content-Length 63 13 | Connection Close 14 | Host 10.0.0.2:8127 15 | wbs> ---> HTTP POST Handler 16 | wbs> POST Body: 17 | {"update":{"7":{"Light":{"Times":[1485093732],"Values":[80]}}}} 18 | wbs> ------------- => New HTTP request 19 | wbs> Request from 10.0.0.2:50822 -- method: POST -- uri: /rf_logger -- version: HTTP/1.1 20 | Content-Length 204 21 | Connection Close 22 | Host 10.0.0.2:8127 23 | wbs> ---> HTTP POST Handler 24 | wbs> POST Body: 25 | {"update":{"6":{"Humidity":{"Times":[1485093733],"Values":[24.0537109375]},"Pressure":{"Times":[1485093733],"Values":[989.516418457031]},"Temperature":{"Times":[1485093733],"Values":[21.6900005340576]}}}} 26 | wbs> ------------- => New HTTP request 27 | wbs> Request from 10.0.0.2:50824 -- method: POST -- uri: /rf_logger -- version: HTTP/1.1 28 | Content-Length 63 29 | Connection Close 30 | Host 10.0.0.2:8127 31 | wbs> ---> HTTP POST Handler 32 | wbs> POST Body: 33 | {"update":{"6":{"Light":{"Times":[1485093733],"Values":[80]}}}} 34 | wbs> ------------- => New HTTP request 35 | wbs> Request from 10.0.0.2:50826 -- method: POST -- uri: /rf_logger -- version: HTTP/1.1 36 | Content-Length 202 37 | Connection Close 38 | Host 10.0.0.2:8127 39 | wbs> ---> HTTP POST Handler 40 | wbs> POST Body: 41 | {"update":{"7":{"Humidity":{"Times":[1485093736],"Values":[40.64453125]},"Pressure":{"Times":[1485093736],"Values":[989.541870117188]},"Temperature":{"Times":[1485093736],"Values":[19.2999992370605]}}}} 42 | wbs> ------------- => New HTTP request 43 | wbs> Request from 10.0.0.2:50828 -- method: POST -- uri: /rf_logger -- version: HTTP/1.1 44 | Content-Length 63 45 | Connection Close 46 | Host 10.0.0.2:8127 47 | wbs> ---> HTTP POST Handler 48 | wbs> POST Body: 49 | {"update":{"7":{"Light":{"Times":[1485093737],"Values":[88]}}}} 50 | wbs> ------------- => New HTTP request 51 | wbs> Request from 10.0.0.2:50830 -- method: POST -- uri: /rf_logger -- version: HTTP/1.1 52 | Content-Length 204 53 | Connection Close 54 | Host 10.0.0.2:8127 55 | wbs> ---> HTTP POST Handler 56 | wbs> POST Body: 57 | {"update":{"6":{"Humidity":{"Times":[1485093738],"Values":[24.0537109375]},"Pressure":{"Times":[1485093738],"Values":[989.516418457031]},"Temperature":{"Times":[1485093738],"Values":[21.6900005340576]}}}} 58 | wbs> ------------- => New HTTP request 59 | wbs> Request from 10.0.0.2:50832 -- method: POST -- uri: /rf_logger -- version: HTTP/1.1 60 | Content-Length 63 61 | Connection Close 62 | Host 10.0.0.2:8127 63 | wbs> ---> HTTP POST Handler 64 | wbs> POST Body: 65 | {"update":{"6":{"Light":{"Times":[1485093738],"Values":[88]}}}} 66 | wbs> ------------- => New HTTP request 67 | wbs> Request from 10.0.0.2:50834 -- method: POST -- uri: /rf_logger -- version: HTTP/1.1 68 | Content-Length 202 69 | Connection Close 70 | Host 10.0.0.2:8127 71 | wbs> ---> HTTP POST Handler 72 | wbs> POST Body: 73 | {"update":{"7":{"Humidity":{"Times":[1485093741],"Values":[40.64453125]},"Pressure":{"Times":[1485093741],"Values":[989.541870117188]},"Temperature":{"Times":[1485093741],"Values":[19.2999992370605]}}}} 74 | wbs> ------------- => New HTTP request 75 | wbs> Request from 10.0.0.2:50836 -- method: POST -- uri: /rf_logger -- version: HTTP/1.1 76 | Content-Length 63 77 | Connection Close 78 | Host 10.0.0.2:8127 79 | wbs> ---> HTTP POST Handler 80 | wbs> POST Body: 81 | {"update":{"7":{"Light":{"Times":[1485093741],"Values":[96]}}}} 82 | ^C 83 | 84 | -------------------------------------------------------------------------------- /raspi_mesh_server/hci_client/.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | *.pyc 3 | __pycache__ 4 | -------------------------------------------------------------------------------- /raspi_mesh_server/hci_client/cfg.py: -------------------------------------------------------------------------------- 1 | import sys,os 2 | import json 3 | import logging as log 4 | import socket 5 | 6 | # -------------------- config -------------------- 7 | def get_local_json(): 8 | """fetches the config.json file in the local directory 9 | if config_hostname.json is found it is used over the default one 10 | """ 11 | config = None 12 | dirname = os.path.dirname(sys.argv[0]) 13 | if(len(dirname) == 0): 14 | dirname = "." 15 | config_file = dirname+'/'+"config_"+socket.gethostname()+".json" 16 | if(os.path.isfile(config_file)): 17 | print("loading: ",config_file) 18 | config = json.load(open(config_file)) 19 | else: 20 | config_file = dirname+'/'+"config.json" 21 | if(os.path.isfile(config_file)): 22 | print("loading: %s",config_file) 23 | config = json.load(open(config_file)) 24 | else: 25 | print("Fatal error 'config.json' not found") 26 | return config 27 | 28 | # -------------------- config -------------------- 29 | def get_local_nodes(rel_file): 30 | """fetches the nodes.json file in the local repository 31 | - rel_file : reliative path file 32 | """ 33 | nodes = None 34 | dirname = os.path.dirname(sys.argv[0]) 35 | if(len(dirname) == 0): 36 | dirname = "." 37 | nodes_file = dirname+'/'+rel_file 38 | if(os.path.isfile(nodes_file)): 39 | print("loading: ",nodes_file) 40 | nodes = json.load(open(nodes_file)) 41 | else: 42 | print("Fatal error %s not found"%(rel_file)) 43 | return nodes 44 | 45 | def configure_log(config): 46 | log_level_map = { 47 | "Debug" :10, 48 | "Info" :20, 49 | "Warning" :30, 50 | "Error" :40, 51 | "Critical" :50 52 | } 53 | log.basicConfig( filename=config["logfile"], 54 | level=log_level_map[config["level"]], 55 | format='%(asctime)s %(name)s %(levelname)-8s %(message)s', 56 | datefmt='%d %H:%M:%S' 57 | ) 58 | log.getLogger('').addHandler(log.StreamHandler()) 59 | log.info("log started @ level:%s",config["level"]) 60 | return 61 | -------------------------------------------------------------------------------- /raspi_mesh_server/hci_client/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "serial":{ 3 | "port":"/dev/ttyUSB0" 4 | }, 5 | "mqtt":{ 6 | "host":"10.0.0.12", 7 | "port":1883, 8 | "keepalive":60, 9 | "client_id":"hci_client", 10 | "subscriptions":[ 11 | "Nodes/#" 12 | ] 13 | }, 14 | "log":{ 15 | "logfile":"/home/pi/share/hci_client.log", 16 | "level":"Debug" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /raspi_mesh_server/hci_client/config_WassDell.json: -------------------------------------------------------------------------------- 1 | { 2 | "serial":{ 3 | "port":"COM4", 4 | "baud":115200 5 | }, 6 | "mqtt":{ 7 | "host":"10.0.0.12", 8 | "port":1883, 9 | "keepalive":60, 10 | "client_id":"hci_client", 11 | "subscriptions":[ 12 | "Nodes/#" 13 | ], 14 | "enable":false 15 | }, 16 | "log":{ 17 | "logfile":"./hci_client.log", 18 | "level":"Debug" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /raspi_mesh_server/hci_client/mqtt_wrapper.py: -------------------------------------------------------------------------------- 1 | import paho.mqtt.client as mqtt 2 | import datetime 3 | import logging as log 4 | import cfg 5 | from time import sleep,time 6 | import json 7 | import socket 8 | 9 | # -------------------- mqtt events -------------------- 10 | def on_connect(lclient, userdata, flags, rc): 11 | log.info("mqtt connected with result code "+str(rc)) 12 | for sub in userdata["mqtt"]["subscriptions"]: 13 | log.info("Subscription to %s",sub) 14 | lclient.subscribe(sub) 15 | 16 | def ruler_loop_forever(): 17 | while(True): 18 | sleep(10) 19 | return 20 | 21 | 22 | def mqtt_start(config,mqtt_on_message): 23 | def mqtt_connect_retries(client): 24 | connected = False 25 | while(not connected): 26 | try: 27 | client.connect(config["mqtt"]["host"], config["mqtt"]["port"], config["mqtt"]["keepalive"]) 28 | connected = True 29 | log.info( "mqtt connected to "+config["mqtt"]["host"]+":"+str(config["mqtt"]["port"])+" with id: "+ cid ) 30 | except socket.error: 31 | log.error("socket.error will try a reconnection in 10 s") 32 | sleep(10) 33 | return 34 | clientMQTT = None 35 | if(config["mqtt"]["enable"]): 36 | cid = config["mqtt"]["client_id"] +"_"+socket.gethostname() 37 | clientMQTT = mqtt.Client(client_id=cid,userdata=config) 38 | clientMQTT.on_connect = on_connect 39 | clientMQTT.on_message = mqtt_on_message 40 | mqtt_connect_retries(clientMQTT) 41 | clientMQTT.loop_start() 42 | return clientMQTT 43 | -------------------------------------------------------------------------------- /raspi_mesh_server/hci_client/serial_wrapper.py: -------------------------------------------------------------------------------- 1 | import serial 2 | import binascii 3 | 4 | ser = serial.Serial() 5 | on_line_function = None 6 | 7 | def run(): 8 | res = None 9 | line = ser.readline().decode("utf-8") 10 | if(len(line)): 11 | line = line.replace('\r','') 12 | line = line.replace('\n','') 13 | on_line_function(line) 14 | return res 15 | 16 | def read_serial_line(): 17 | res = None 18 | line_type = ser.read() 19 | if(len(line_type)): 20 | if(line_type == 'b'): 21 | print("getting a binary line:") 22 | line_size = ser.read() 23 | line = ser.read(line_size) 24 | print(binascii.hexlify(line)) 25 | else: 26 | print("getting a text line:") 27 | #line = ser.readline().decode("utf-8")[1:] 28 | line = ser.readline() 29 | print(binascii.hexlify(line)) 30 | #print(line) 31 | return res 32 | 33 | def send(data): 34 | msg = bytearray(b'b') 35 | #print("data:",data,"type:",type(data)) 36 | if(isinstance(data,list)): 37 | msg.append(len(data)+1) 38 | for d in data: 39 | msg.append(d) 40 | else: 41 | #in this case it is one byte, so + size = 2 42 | msg.append(2) 43 | msg.append(data) 44 | #print(msg) 45 | ser.write(msg) # then comes the data 46 | return 47 | 48 | def serial_start(config,serial_on_line): 49 | global on_line_function 50 | on_line_function = serial_on_line 51 | global ser 52 | ser = serial.Serial(config["serial"]["port"], 53 | config["serial"]["baud"], 54 | timeout=0.1) 55 | print(ser.name) 56 | return ser 57 | -------------------------------------------------------------------------------- /raspi_mesh_server/py_net_gateway/.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | __pycache__ 3 | -------------------------------------------------------------------------------- /raspi_mesh_server/py_net_gateway/cfg.py: -------------------------------------------------------------------------------- 1 | import sys,os 2 | import json 3 | import logging as log 4 | 5 | # -------------------- config -------------------- 6 | def get_local_json(loca_file_name): 7 | dirname = os.path.dirname(sys.argv[0]) 8 | if(len(dirname) == 0): 9 | dirname = "." 10 | config_file = dirname+'/'+loca_file_name 11 | config = json.load(open(config_file)) 12 | return config 13 | 14 | 15 | def configure_log(config): 16 | log_level_map = { 17 | "Debug" :10, 18 | "Info" :20, 19 | "Warning" :30, 20 | "Error" :40, 21 | "Critical" :50 22 | } 23 | log.basicConfig( filename=config["logfile"], 24 | level=log_level_map[config["level"]], 25 | format='%(asctime)s %(name)s %(levelname)-8s %(message)s', 26 | datefmt='%d %H:%M:%S' 27 | ) 28 | log.getLogger('').addHandler(log.StreamHandler()) 29 | log.info("log started @ level:%s",config["level"]) 30 | return 31 | -------------------------------------------------------------------------------- /raspi_mesh_server/py_net_gateway/config_milight.json: -------------------------------------------------------------------------------- 1 | { 2 | "devices":{ 3 | "LivingRoom":{ 4 | "host":"10.0.0.8", 5 | "port":8899 6 | }, 7 | "Upstairs":{ 8 | "host":"10.0.0.6", 9 | "port":8899 10 | } 11 | }, 12 | "mapping":{ 13 | "31":{ 14 | "device" :"LivingRoom", 15 | "channel" :1 16 | }, 17 | "32":{ 18 | "device" :"LivingRoom", 19 | "channel" :2 20 | }, 21 | "33":{ 22 | "device" :"LivingRoom", 23 | "channel" :3 24 | }, 25 | "34":{ 26 | "device" :"LivingRoom", 27 | "channel" :4 28 | }, 29 | "35":{ 30 | "device" :"Upstairs", 31 | "channel" :1 32 | }, 33 | "36":{ 34 | "device" :"Upstairs", 35 | "channel" :2 36 | } 37 | }, 38 | "mqtt":{ 39 | "host":"10.0.0.12", 40 | "port":1883, 41 | "keepalive":60, 42 | "client_id":"python_milight", 43 | "subscribe":{ 44 | "Nodes" :["dimmer"] 45 | } 46 | }, 47 | "log":{ 48 | "logfile":"/home/pi/share/milight_gateway.log", 49 | "level":"Info" 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /raspi_mesh_server/py_net_gateway/config_wemo.json: -------------------------------------------------------------------------------- 1 | { 2 | "devices":{ 3 | "TvSet":{ 4 | "node":30 5 | }, 6 | "Bathroom":{ 7 | "node":37 8 | }, 9 | "Workplace":{ 10 | "node":40 11 | } 12 | }, 13 | "mqtt":{ 14 | "host":"10.0.0.12", 15 | "port":1883, 16 | "keepalive":60, 17 | "client_id":"py_wemo", 18 | "valuesTopics":{ 19 | "HeadTopic" :"Nodes/", 20 | "actions" :["power"] 21 | } 22 | }, 23 | "log":{ 24 | "logfile":"/home/pi/share/wemo.log", 25 | "level":"Info" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /raspi_mesh_server/py_net_gateway/milight_gateway.py: -------------------------------------------------------------------------------- 1 | #https://pypi.python.org/pypi/paho-mqtt/1.1 2 | import paho.mqtt.client as mqtt 3 | import json 4 | #https://github.com/McSwindler/python-milight 5 | import milight 6 | from milight import Command 7 | #just to get host name 8 | import socket 9 | from time import sleep 10 | from math import ceil 11 | import logging as log 12 | import sys,os 13 | import cfg 14 | 15 | def on_connect(lclient, userdata, flags, rc): 16 | topic_sub = "Nodes/+/dimmer" 17 | lclient.subscribe(topic_sub) 18 | log.info("Subscribed to: "+topic_sub) 19 | 20 | def on_message(client, userdata, msg): 21 | topic_parts = msg.topic.split('/') 22 | if(len(topic_parts) == 3): 23 | nodeid = topic_parts[1] 24 | if(nodeid in config["mapping"]): 25 | device_name = config["mapping"][nodeid]["device"] 26 | channel = config["mapping"][nodeid]["channel"] 27 | dimm_val = int(ceil(float(msg.payload))) 28 | if(dimm_val > 100): 29 | dimm_val = 100 30 | log.debug( "Action to Node: "+nodeid + 31 | " ; through gateway: "+device_name + 32 | " ; on channel: "+str(channel) + 33 | " ; set value: "+str(dimm_val) 34 | ) 35 | controller = milight_controllers[device_name] 36 | if(dimm_val == 0): 37 | controller.send(light.off(channel)) 38 | elif(dimm_val == 1): 39 | controller.send(light.off(channel)) 40 | sleep(0.100)#100 ms 41 | controller.send(Command(night_mode[channel])) 42 | else: 43 | controller.send(light.brightness(dimm_val,channel)) 44 | else: 45 | log.warning("Node "+nodeid+" route unknown") 46 | else: 47 | log.error("topic: "+msg.topic + "size not matching") 48 | 49 | 50 | def mqtt_connect_retries(client): 51 | connected = False 52 | while(not connected): 53 | try: 54 | client.connect(config["mqtt"]["host"], config["mqtt"]["port"], config["mqtt"]["keepalive"]) 55 | connected = True 56 | log.info( "mqtt connected to "+config["mqtt"]["host"]+":"+str(config["mqtt"]["port"])+" with id: "+ cid ) 57 | except socket.error: 58 | log.error("socket.error will try a reconnection in 10 s") 59 | sleep(10) 60 | return 61 | 62 | # -------------------- main -------------------- 63 | config = cfg.get_local_json("config_milight.json") 64 | 65 | cfg.configure_log(config["log"]) 66 | 67 | log.info("milight client started") 68 | 69 | # -------------------- Milight Client -------------------- 70 | milight_controllers = {} 71 | for device_name,device in config["devices"].items(): 72 | milight_controllers[device_name] = milight.MiLight(device) 73 | 74 | #light = milight.LightBulb(['rgbw','white','rgb']) 75 | light = milight.LightBulb(['rgbw']) 76 | night_mode = [0xC1, 0xC6, 0xC8, 0xCA, 0xCC] 77 | # -------------------- Mqtt Client -------------------- 78 | cid = config["mqtt"]["client_id"] +"_"+socket.gethostname() 79 | client = mqtt.Client(client_id=cid) 80 | client.on_connect = on_connect 81 | client.on_message = on_message 82 | 83 | mqtt_connect_retries(client) 84 | 85 | client.loop_forever() 86 | 87 | -------------------------------------------------------------------------------- /raspi_mesh_server/py_net_gateway/rasp.py: -------------------------------------------------------------------------------- 1 | import os 2 | # Return CPU temperature as a character string 3 | def getCPUtemperature(): 4 | res = os.popen('vcgencmd measure_temp').readline() 5 | return(res.replace("temp=","").replace("'C\n","")) 6 | 7 | # Return RAM information (unit=kb) 8 | # used RAM 9 | def getUsedRAM(): 10 | p = os.popen('free') 11 | i = 0 12 | while 1: 13 | i = i + 1 14 | line = p.readline() 15 | if i==2: 16 | return(line.split()[2]) 17 | 18 | #top fails on early startup "top: failed tty get" 19 | def getCPU_Avg1min(): 20 | p = os.popen("top -b -n1") 21 | line = p.readline() 22 | ind_cpu = line.find("load average:") 23 | if(ind_cpu!= -1): 24 | cpu_vals = line[ind_cpu+13:] 25 | return(cpu_vals.split(',')[0]) 26 | else: 27 | return "0" 28 | 29 | # Return % of CPU used by user as a character string 30 | def getCPUuse(): 31 | return(str(os.popen("top -n1 | awk '/Cpu\(s\):/ {print $2}'").readline().strip())) 32 | 33 | def getUsedDisk(): 34 | p = os.popen("df /") 35 | i = 0 36 | while 1: 37 | i = i +1 38 | line = p.readline() 39 | if i==2: 40 | return(line.split()[2]) 41 | 42 | def getUsedDiskDir(path): 43 | p = os.popen("sudo du --summarize "+path) 44 | line = p.readline() 45 | if(len(line)>0): 46 | return(line.split()[0]) 47 | else: 48 | return "0" 49 | -------------------------------------------------------------------------------- /raspi_mesh_server/py_net_gateway/raspi_status.py: -------------------------------------------------------------------------------- 1 | from influxdb import InfluxDBClient 2 | import datetime 3 | from time import sleep 4 | import socket 5 | import requests 6 | import rasp 7 | 8 | def raspi_loop_forever(): 9 | while(True): 10 | tnow = datetime.datetime.utcnow() 11 | value = 0 12 | posts = [ 13 | { 14 | "measurement": "cpu_load", 15 | "time": tnow, 16 | "tags":{ 17 | "host":hostname 18 | }, 19 | "fields": { 20 | "value": float(rasp.getCPU_Avg1min()) 21 | } 22 | }, 23 | { 24 | "measurement": "cpu_temp", 25 | "time": tnow, 26 | "tags":{ 27 | "host":hostname 28 | }, 29 | "fields": { 30 | "value": float(rasp.getCPUtemperature()) 31 | } 32 | }, 33 | { 34 | "measurement": "disk", 35 | "time": tnow, 36 | "tags":{ 37 | "host" :hostname, 38 | "target":"total" 39 | }, 40 | "fields": { 41 | "value": int(rasp.getUsedDisk()) 42 | } 43 | }, 44 | { 45 | "measurement": "disk", 46 | "time": tnow, 47 | "tags":{ 48 | "host" :hostname, 49 | "target":"influxdb" 50 | }, 51 | "fields": { 52 | "value": int(rasp.getUsedDiskDir("/var/lib/influxdb/data")) 53 | } 54 | }, 55 | { 56 | "measurement": "ram", 57 | "time": tnow, 58 | "tags":{ 59 | "host" :hostname 60 | }, 61 | "fields": { 62 | "value": int(rasp.getUsedRAM()) 63 | } 64 | } 65 | ] 66 | try: 67 | clientDB.write_points(posts) 68 | except requests.exceptions.ConnectionError: 69 | print("ConnectionError sample skipped @ "+str(datetime.datetime.utcnow())) 70 | sleep(60) 71 | return 72 | 73 | # -------------------- main -------------------- 74 | print("raspi client started @ :"+str(datetime.datetime.utcnow())) 75 | 76 | hostname = socket.gethostname() 77 | 78 | # -------------------- influxDB client -------------------- 79 | clientDB = InfluxDBClient( "10.0.0.12", 80 | 8086, 81 | 'root', 'root', 82 | "raspiStatus") 83 | 84 | #loop forever 85 | raspi_loop_forever() 86 | #while(True): 87 | #print("cpu temp",float(rasp.getCPUtemperature()) ) 88 | #print("used ram",int(rasp.getUsedRAM()) ) 89 | #print("cpu use",rasp.getCPU_Avg1min() ) 90 | #print("used disk /",int(rasp.getUsedDisk()) ) 91 | #print("used disk mongodb /",int(rasp.getUsedDiskDir("/var/lib/mongodb")) ) 92 | #sleep(5) 93 | -------------------------------------------------------------------------------- /raspi_mesh_server/py_net_gateway/wemo_client.py: -------------------------------------------------------------------------------- 1 | import paho.mqtt.client as mqtt 2 | from ouimeaux.environment import Environment 3 | import datetime 4 | import logging as log 5 | import cfg 6 | from time import sleep 7 | import socket 8 | 9 | # -------------------- mqtt events -------------------- 10 | def on_connect(lclient, userdata, flags, rc): 11 | log.info("mqtt connected with result code "+str(rc)) 12 | #lclient.subscribe("#") 13 | 14 | def on_message(client, userdata, msg): 15 | topic_parts = msg.topic.split('/') 16 | try: 17 | if( (len(topic_parts) == 3) and (topic_parts[0] == "Nodes") ): 18 | nodeid = topic_parts[1] 19 | sensor = topic_parts[2] 20 | measurement = "node"+nodeid 21 | value = float(str(msg.payload)) 22 | post = [ 23 | { 24 | "measurement": measurement, 25 | "time": datetime.datetime.utcnow(), 26 | "fields": { 27 | sensor: value 28 | } 29 | } 30 | ] 31 | #TODO use post 32 | log.debug(msg.topic+" "+str(msg.payload)+" posted") 33 | except ValueError: 34 | log.error(" ValueError with : "+msg.topic+" "+str(msg.payload)) 35 | 36 | 37 | # -------------------- wemo events -------------------- 38 | def on_switch(switch): 39 | log.info("Switch found! %s", switch.name) 40 | def on_motion(motion): 41 | log.info("Motion found! %s", motion.name) 42 | 43 | def wemo_start(): 44 | env = Environment(on_switch,on_motion) 45 | env.start() 46 | env.discover(seconds=3) 47 | #print("listing:") 48 | #env.list_switches() 49 | devices = {} 50 | for device_name in config["devices"]: 51 | switch = env.get_switch(device_name) 52 | #switch["node"] = config["devices"][device_name]["node"] # no support for assignment 53 | devices[device_name] = switch 54 | #print("explain()") 55 | #switch.explain() 56 | return devices 57 | 58 | def wemo_loop_forever(): 59 | while(True): 60 | for name in devices: 61 | log.debug("%s: bin state: %s",name,devices[name].basicevent.GetBinaryState()) 62 | topic = "Nodes/"+str(config["devices"][name]["node"])+"/power" 63 | power = float(devices[name].current_power)/1000 64 | clientMQTT.publish(topic,power) 65 | log.debug("%s: %s: %s",name, topic, power) 66 | sleep(10) 67 | return 68 | 69 | def mqtt_connect_retries(client): 70 | connected = False 71 | while(not connected): 72 | try: 73 | client.connect(config["mqtt"]["host"], config["mqtt"]["port"], config["mqtt"]["keepalive"]) 74 | connected = True 75 | except socket.error: 76 | log.error("socket.error will try a reconnection in 10 s") 77 | sleep(10) 78 | return 79 | 80 | def mqtt_start(): 81 | cid = config["mqtt"]["client_id"] +"_"+socket.gethostname() 82 | clientMQTT = mqtt.Client(client_id=cid) 83 | clientMQTT.on_connect = on_connect 84 | clientMQTT.on_message = on_message 85 | mqtt_connect_retries(clientMQTT) 86 | clientMQTT.loop_start() 87 | return clientMQTT 88 | 89 | # -------------------- main -------------------- 90 | config = cfg.get_local_json("config_wemo.json") 91 | 92 | cfg.configure_log(config["log"]) 93 | 94 | log.info("wemo client started") 95 | 96 | #will start a separate thread for looping 97 | clientMQTT = mqtt_start() 98 | 99 | devices = wemo_start() 100 | 101 | #loop forever 102 | wemo_loop_forever() 103 | -------------------------------------------------------------------------------- /raspi_mesh_server/ruler/.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | __pycache__ 3 | -------------------------------------------------------------------------------- /raspi_mesh_server/ruler/__pycache__/cfg.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HomeSmartMesh/IoT_Frameworks/411dfba86d012bd757b3fc4d430f1f53a979f294/raspi_mesh_server/ruler/__pycache__/cfg.cpython-36.pyc -------------------------------------------------------------------------------- /raspi_mesh_server/ruler/cfg.py: -------------------------------------------------------------------------------- 1 | import sys,os 2 | import json 3 | import logging as log 4 | 5 | # -------------------- config -------------------- 6 | def get_local_json(loca_file_name): 7 | dirname = os.path.dirname(sys.argv[0]) 8 | if(len(dirname) == 0): 9 | dirname = "." 10 | config_file = dirname+'/'+loca_file_name 11 | config = json.load(open(config_file)) 12 | return config 13 | 14 | 15 | def configure_log(config): 16 | log_level_map = { 17 | "Debug" :10, 18 | "Info" :20, 19 | "Warning" :30, 20 | "Error" :40, 21 | "Critical" :50 22 | } 23 | log.basicConfig( filename=config["logfile"], 24 | level=log_level_map[config["level"]], 25 | format='%(asctime)s %(name)s %(levelname)-8s %(message)s', 26 | datefmt='%d %H:%M:%S' 27 | ) 28 | log.getLogger('').addHandler(log.StreamHandler()) 29 | log.info("log started @ level:%s",config["level"]) 30 | return 31 | -------------------------------------------------------------------------------- /raspi_mesh_server/ruler/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "mqtt":{ 3 | "host":"10.0.0.12", 4 | "port":1883, 5 | "keepalive":60, 6 | "client_id":"py_ruler" 7 | }, 8 | "log":{ 9 | "logfile":"/home/pi/share/ruler.log", 10 | "level":"Debug" 11 | }, 12 | "rules":{ 13 | "Bathroom_Hum_Status":{ 14 | "input":"Nodes/7/humidity", 15 | "output":"jNodes/56/RGB", 16 | "description":"indicate when the bathroom is humid", 17 | "enable" : true 18 | }, 19 | "Sleeproom_Light_Up":{ 20 | "input":"Nodes/41/button", 21 | "output":"Nodes/34/dimmer", 22 | "description":"Increeses the light of the sleeping room on button press", 23 | "enable" : true 24 | }, 25 | "RGB_Tester_Single":{ 26 | "input":"Nodes/28/proximity", 27 | "output":"jNodes/24/RGB", 28 | "description":"Test the proxymity sensor with an RGB LED", 29 | "enable" : true 30 | }, 31 | "RGB_Tester_Burst":{ 32 | "input":"Nodes/28/proximity", 33 | "output":"jNodes/24/RGB", 34 | "description":"Test the proxymity sensor with an RGB LED", 35 | "enable" : false 36 | }, 37 | "Button_To_Heat_Up":{ 38 | "input":"Nodes/43/button", 39 | "output":"Nodes/28/heat", 40 | "description":"Increases the heat Up", 41 | "enable" : true 42 | }, 43 | "Button_To_Heat_Down":{ 44 | "input":"Nodes/44/button", 45 | "output":"Nodes/28/heat", 46 | "description":"Decrease the heat Down", 47 | "enable" : true 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /raspi_mesh_server/ruler/ruler.py: -------------------------------------------------------------------------------- 1 | import paho.mqtt.client as mqtt 2 | import datetime 3 | import logging as log 4 | import cfg 5 | from time import sleep,time 6 | import json 7 | import rules 8 | import socket 9 | 10 | # -------------------- mqtt events -------------------- 11 | def on_connect(lclient, userdata, flags, rc): 12 | log.info("mqtt connected with result code "+str(rc)) 13 | for rule_name,rule in config["rules"].iteritems(): 14 | log.info("Subscription for rule:%s %s -> %s",rule_name,rule["input"],rule["output"]) 15 | lclient.subscribe(rule["input"]) 16 | 17 | def on_message(client, userdata, msg): 18 | topic_parts = msg.topic.split('/') 19 | for rule_name,rule in config["rules"].iteritems(): 20 | if msg.topic == rule["input"]: 21 | if(rule["enable"]): 22 | #call the Fuction with the same name as the Rule 23 | payload = getattr(rules,rule_name)(msg.payload) 24 | if(payload): 25 | clientMQTT.publish(rule["output"],payload) 26 | 27 | 28 | def ruler_loop_forever(): 29 | while(True): 30 | sleep(10) 31 | return 32 | 33 | 34 | def mqtt_start(): 35 | def mqtt_connect_retries(client): 36 | connected = False 37 | while(not connected): 38 | try: 39 | client.connect(config["mqtt"]["host"], config["mqtt"]["port"], config["mqtt"]["keepalive"]) 40 | connected = True 41 | log.info( "mqtt connected to "+config["mqtt"]["host"]+":"+str(config["mqtt"]["port"])+" with id: "+ cid ) 42 | except socket.error: 43 | log.error("socket.error will try a reconnection in 10 s") 44 | sleep(10) 45 | return 46 | cid = config["mqtt"]["client_id"] +"_"+socket.gethostname() 47 | client = mqtt.Client(client_id=cid) 48 | clientMQTT = mqtt.Client() 49 | clientMQTT.on_connect = on_connect 50 | clientMQTT.on_message = on_message 51 | mqtt_connect_retries(clientMQTT) 52 | clientMQTT.loop_start() 53 | return clientMQTT 54 | 55 | # -------------------- main -------------------- 56 | config = cfg.get_local_json("config.json") 57 | 58 | cfg.configure_log(config["log"]) 59 | 60 | log.info("ruler started @ :"+str(datetime.datetime.utcnow())) 61 | 62 | #will start a separate thread for looping 63 | clientMQTT = mqtt_start() 64 | 65 | #loop forever 66 | ruler_loop_forever() 67 | -------------------------------------------------------------------------------- /raspi_mesh_server/ruler/rules.py: -------------------------------------------------------------------------------- 1 | import logging as log 2 | from time import time 3 | import json 4 | 5 | def static_vars(**kwargs): 6 | def decorate(func): 7 | for k in kwargs: 8 | setattr(func, k, kwargs[k]) 9 | return func 10 | return decorate 11 | 12 | def Bathroom_Hum_Status(input): 13 | red = 0 14 | green = 0 15 | blue = 0 16 | hum = float(input) 17 | 18 | if(hum < 60): 19 | green = 15 20 | else: 21 | green = 0 22 | if(hum < 50): 23 | blue = 0 24 | else: 25 | trig = (hum - 50.0) / 50.0 26 | blue = 200 * trig 27 | jColors = {"Red":red,"Green":green,"Blue":blue} 28 | return json.dumps(jColors) 29 | 30 | def RGB_Tester_Burst(input): 31 | log.info("RGB_Tester_Burst() post") 32 | return "100" 33 | 34 | @static_vars(event_time=time()) 35 | def Sleeproom_Light_Up(input): 36 | log.debug("Sleeproom_Light_Up>input(%s)",input) 37 | if(float(input) == 1.0): 38 | result = "100" 39 | else: 40 | result = None # ignored, do nothing 41 | return result 42 | 43 | @static_vars(event_time=time()) 44 | def RGB_Tester_Single(input): 45 | result = None 46 | tnow = time() 47 | delay = tnow - RGB_Tester_Single.event_time 48 | if(delay > 2): 49 | RGB_Tester_Single.event_time = tnow 50 | log.info("RGB_Tester_Single() post after %f",delay) 51 | payload = {"Red":4,"Green":1,"Blue":3} 52 | result = json.dumps(payload) 53 | else: 54 | log.debug("RGB_Tester_Single() skipped sent since %f",delay) 55 | return result 56 | 57 | def Button_To_Heat_Up(input): 58 | log.debug("Button_To_Heat_Up>input(%s)",input) 59 | if(float(input) == 1.0): 60 | result = 11 61 | else: 62 | result = None # ignored, do nothing 63 | return result 64 | 65 | def Button_To_Heat_Down(input): 66 | log.debug("Button_To_Heat_Down>input(%s)",input) 67 | if(float(input) == 1.0): 68 | result = 12 69 | else: 70 | result = None # ignored, do nothing 71 | return result 72 | -------------------------------------------------------------------------------- /raspi_mesh_server/web_d3js_viewer/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /raspi_mesh_server/web_d3js_viewer/MovingChartExample.js: -------------------------------------------------------------------------------- 1 | var limit = 60 * 1, 2 | duration = 750, 3 | now = new Date(Date.now() - duration) 4 | 5 | var width = 500, 6 | height = 200 7 | 8 | var groups = { 9 | current: { 10 | value: 0, 11 | color: 'orange', 12 | data: d3.range(limit).map(function() { 13 | return 0 14 | }) 15 | }, 16 | target: { 17 | value: 0, 18 | color: 'green', 19 | data: d3.range(limit).map(function() { 20 | return 0 21 | }) 22 | }, 23 | output: { 24 | value: 0, 25 | color: 'grey', 26 | data: d3.range(limit).map(function() { 27 | return 0 28 | }) 29 | } 30 | } 31 | 32 | var x = d3.time.scale() 33 | .domain([now - (limit - 2), now - duration]) 34 | .range([0, width]) 35 | 36 | var y = d3.scale.linear() 37 | .domain([0, 100]) 38 | .range([height, 0]) 39 | 40 | var line = d3.svg.line() 41 | .interpolate('basis') 42 | .x(function(d, i) { 43 | return x(now - (limit - 1 - i) * duration) 44 | }) 45 | .y(function(d) { 46 | return y(d) 47 | }) 48 | 49 | var svg = d3.select('.graph').append('svg') 50 | .attr('class', 'chart') 51 | .attr('width', width) 52 | .attr('height', height + 50) 53 | 54 | var axis = svg.append('g') 55 | .attr('class', 'x axis') 56 | .attr('transform', 'translate(0,' + height + ')') 57 | .call(x.axis = d3.svg.axis().scale(x).orient('bottom')) 58 | 59 | var paths = svg.append('g') 60 | 61 | for (var name in groups) { 62 | var group = groups[name] 63 | group.path = paths.append('path') 64 | .data([group.data]) 65 | .attr('class', name + ' group') 66 | .style('stroke', group.color) 67 | } 68 | 69 | function tick() { 70 | now = new Date() 71 | 72 | // Add new values 73 | for (var name in groups) { 74 | var group = groups[name] 75 | //group.data.push(group.value) // Real values arrive at irregular intervals 76 | group.data.push(20 + Math.random() * 100) 77 | group.path.attr('d', line) 78 | } 79 | 80 | // Shift domain 81 | x.domain([now - (limit - 2) * duration, now - duration]) 82 | 83 | // Slide x-axis left 84 | axis.transition() 85 | .duration(duration) 86 | .ease('linear') 87 | .call(x.axis) 88 | 89 | // Slide paths left 90 | paths.attr('transform', null) 91 | .transition() 92 | .duration(duration) 93 | .ease('linear') 94 | .attr('transform', 'translate(' + x(now - (limit - 1) * duration) + ')') 95 | .each('end', tick) 96 | 97 | // Remove oldest data point from each group 98 | for (var name in groups) { 99 | var group = groups[name] 100 | group.data.shift() 101 | } 102 | } 103 | 104 | tick(); 105 | -------------------------------------------------------------------------------- /raspi_mesh_server/web_d3js_viewer/copy_to_rpi.bat: -------------------------------------------------------------------------------- 1 | pscp -pw raspberry -r D:\Projects\IoT_Frameworks\sensors_logger\web_d3js_viewer\ pi@10.0.0.12:/var/www/html/sensors/ 2 | -------------------------------------------------------------------------------- /raspi_mesh_server/web_d3js_viewer/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | WebSocket - Sensors Viewer 6 | 7 | 15 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 |
51 |
Connecting...
52 |
53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /raspi_mesh_server/web_d3js_viewer/main.js: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // Status Panel 3 | //--------------------------------------------------------------------------- 4 | var StatusParams = 5 | { 6 | svgID : "#StatusDisp", 7 | data : 8 | [ 9 | { x: 100, y: 100, r: 20, color: "Blue", 10 | temperature : 26, light : 500, 11 | Name : "LivingRoom" 12 | }, 13 | { x: 300, y: 100, r: 20, color: "Blue", 14 | temperature : 26, light : 500, 15 | Name : "BathRoom" 16 | }, 17 | { x: 500, y: 100, r: 20, color: "Blue", 18 | temperature : 26, light : 500, 19 | Name : "Balcony" 20 | } 21 | ] 22 | }; 23 | 24 | var nmap = {6 : 0, 25 | 7 : 1, 26 | 16 : 2}; 27 | 28 | //--------------------------------------------------------------------------- 29 | // Time Chart 30 | //--------------------------------------------------------------------------- 31 | var now = Date.now(); 32 | var start_disp = now - 24*60*60*1000;//1 day 33 | var ChartsParamsList = 34 | [ 35 | { 36 | svgID : "#ChartLivTemp", 37 | scale_x_domain : [start_disp,now], 38 | scale_y_domain : [10,25], 39 | NodeId : 6, 40 | SensorName : "temperature", 41 | Label : "Livingroom Temperature °C" 42 | }, 43 | { 44 | svgID : "#ChartLivHum", 45 | scale_x_domain : [start_disp,now], 46 | scale_y_domain : [0,100], 47 | NodeId : 6, 48 | SensorName : "humidity", 49 | Label : "Livingroom Humidity %RH" 50 | }, 51 | { 52 | svgID : "#ChartBathTemp", 53 | scale_x_domain : [start_disp,now], 54 | scale_y_domain : [10,25], 55 | NodeId : 7, 56 | SensorName : "temperature", 57 | Label : "Bathroom Temperature °C" 58 | }, 59 | { 60 | svgID : "#ChartBathHum", 61 | scale_x_domain : [start_disp,now], 62 | scale_y_domain : [0,100], 63 | NodeId : 7, 64 | SensorName : "humidity", 65 | Label : "Bathroom Humidity %RH" 66 | }, 67 | { 68 | svgID : "#ChartBlacTemp", 69 | scale_x_domain : [start_disp,now], 70 | scale_y_domain : [0,35], 71 | NodeId : 16, 72 | SensorName : "temperature", 73 | Label : "Balcony Temperature °C" 74 | }, 75 | { 76 | svgID : "#ChartBalcHum", 77 | scale_x_domain : [start_disp,now], 78 | scale_y_domain : [0,100], 79 | NodeId : 16, 80 | SensorName : "humidity", 81 | Label : "Balcony Humidity %RH" 82 | }, 83 | { 84 | svgID : "#ChartRoomLight", 85 | scale_x_domain : [start_disp,now], 86 | scale_y_domain : [0,1800], 87 | NodeId : 6, 88 | SensorName : "light", 89 | Label : "Room Light" 90 | }, 91 | { 92 | svgID : "#ChartBathLight", 93 | scale_x_domain : [start_disp,now], 94 | scale_y_domain : [0,1800], 95 | NodeId : 7, 96 | SensorName : "light", 97 | Label : "Bathroom Light" 98 | } 99 | ]; 100 | //--------------------------------------------------------------------------- 101 | // Status Request 102 | //--------------------------------------------------------------------------- 103 | var statusReq = { 104 | request : 105 | { 106 | id : Math.floor(Math.random() * 10000), 107 | type : "update", 108 | NodeIds : [6,7] 109 | } 110 | }; 111 | 112 | //--------------------------------------------------------------------------- 113 | 114 | //--------------------------------------------------------------------------- 115 | // Loading modules 116 | //--------------------------------------------------------------------------- 117 | require([ "StatusPanel", //still using dirty hack global var Status 118 | "TimeChart", 119 | "websocket" 120 | ], 121 | function() 122 | { 123 | console.log("require> done"); 124 | 125 | var MyPanel = new StatusPanel(StatusParams); 126 | 127 | var MyChartList = new TimeChartsList(ChartsParamsList); 128 | 129 | var reqList = [statusReq].concat(MyChartList.getAllRequestsDuration()); 130 | 131 | initWebsocket(reqList,MyPanel,MyChartList); 132 | } 133 | ); 134 | -------------------------------------------------------------------------------- /smartio/.gitignore: -------------------------------------------------------------------------------- 1 | nodejs/node_modules/ 2 | -------------------------------------------------------------------------------- /smartio/README.md: -------------------------------------------------------------------------------- 1 | ## SmartIO a Raspberry Pi 3 2 | - RPi 3 wifi used to provide an access point with "hostapd" and "dnsmasq", see this nice [tutorial](https://frillip.com/using-your-raspberry-pi-3-as-a-wifi-access-point-with-hostapd/) 3 | - RPi 3 serves the javascript web client with ["apache2"](https://www.raspberrypi.org/documentation/remote-access/web-server/apache.md) 4 | - connect on "http://172.24.1.1/client/" 5 | 6 | 7 | 8 | ## Printed Circuit Board 9 | [The IO Expander Board wiki page](http://www.technolab.ddns.net/display/SSN/Smart+IO+Expander) 10 | 11 | 12 | 13 | ## Firmware 14 | [The IO Expander Firmware](https://github.com/wassfila/STM8_IoT_Base/tree/master/ws04_IOExpander_Sequencer/02_EESeqence_Console) 15 | converts the serial commands into PIO output status on or off. 16 | 17 | ## Web client 18 | - The client connects to the server to send and receive text commands 19 | - The client has also Leds GUI to control output with clicks that compute the command out of the desired led status 20 | 21 | 22 | ## Nodejs server 23 | The nodejs server controls the serial port and uses websockets to mirror the serial port tx and rx in text mode for the clients. 24 | Note that a [new version of nodejs](http://node-arm.herokuapp.com/node_latest_armhf.deb) has to be used (v4.x.x) for the serial_port component to be installed with npm. 25 | 26 | -------------------------------------------------------------------------------- /smartio/client/cmd/frontend.js: -------------------------------------------------------------------------------- 1 | $(function () { 2 | "use strict"; 3 | 4 | // for better performance - to avoid searching in DOM 5 | var content = $('#content'); 6 | var input = $('#input'); 7 | var status = $('#status'); 8 | 9 | // my color assigned by the server 10 | var myColor = false; 11 | // my name sent to the server 12 | var myName = false; 13 | 14 | // if user is running mozilla then use it's built-in WebSocket 15 | window.WebSocket = window.WebSocket || window.MozWebSocket; 16 | 17 | // if browser doesn't support WebSocket, just show some notification and exit 18 | if (!window.WebSocket) { 19 | content.html($('

', { text: 'Sorry, but your browser doesn\'t ' 20 | + 'support WebSockets.'} )); 21 | input.hide(); 22 | $('span').hide(); 23 | return; 24 | } 25 | 26 | // open connection 27 | var connection = new WebSocket('ws://localhost:4785'); 28 | 29 | connection.onopen = function () { 30 | // first we want users to enter their names 31 | input.removeAttr('disabled'); 32 | status.text('Serial Port On'); 33 | }; 34 | 35 | connection.onerror = function (error) { 36 | // just in there were some problems with conenction... 37 | content.html($('

', { text: 'Sorry, but there\'s some problem with your ' 38 | + 'connection or the server is down.' } )); 39 | }; 40 | 41 | // most important part - incoming messages 42 | connection.onmessage = function (message) { 43 | // try to parse JSON message. Because we know that the server always returns 44 | // JSON this should work without any problem but we should make sure that 45 | // the massage is not chunked or otherwise damaged. 46 | try { 47 | var json = JSON.parse(message.data); 48 | } catch (e) { 49 | console.log('This doesn\'t look like a valid JSON: ', message.data); 50 | return; 51 | } 52 | 53 | // NOTE: if you're not sure about the JSON structure 54 | // check the server source code above 55 | if (json.type === 'color') { // first response from the server with user's color 56 | myColor = json.data; 57 | status.text(myName + ': ').css('color', myColor); 58 | input.removeAttr('disabled').focus(); 59 | // from now user can start sending messages 60 | } else if (json.type === 'history') { // entire message history 61 | // insert every single message to the chat window 62 | for (var i=0; i < json.data.length; i++) { 63 | addMessage(json.data[i]); 64 | } 65 | } else if (json.type === 'ack') { // acknowledge of sent message 66 | input.removeAttr('disabled'); // let the user write another message 67 | addMessage(json.data); 68 | } else if (json.type === 'message') { // acknowledge of sent message 69 | input.removeAttr('disabled'); // let the user write another message 70 | addMessage(json.data); 71 | } else { 72 | console.log('Hmm..., I\'ve never seen JSON like this: ', json); 73 | } 74 | }; 75 | 76 | /** 77 | * Send mesage when user presses Enter key 78 | */ 79 | input.keydown(function(e) { 80 | if (e.keyCode === 13) { 81 | var msg = $(this).val(); 82 | if (!msg) { 83 | return; 84 | } 85 | // send the message as an ordinary text 86 | connection.send(msg); 87 | $(this).val(''); 88 | // disable the input field to make the user wait until server 89 | // sends back response 90 | input.attr('disabled', 'disabled'); 91 | 92 | // we know that the first message sent from a user their name 93 | if (myName === false) { 94 | myName = msg; 95 | } 96 | } 97 | }); 98 | 99 | /** 100 | * This method is optional. If the server wasn't able to respond to the 101 | * in 3 seconds then show some error message to notify the user that 102 | * something is wrong. 103 | */ 104 | setInterval(function() { 105 | if (connection.readyState !== 1) { 106 | status.text('Error'); 107 | input.attr('disabled', 'disabled').val('Unable to comminucate ' 108 | + 'with the WebSocket server.'); 109 | } 110 | }, 3000); 111 | 112 | /** 113 | * Add message to the chat window 114 | */ 115 | function addMessage(message) { 116 | content.prepend('

' + message + '

'); 117 | } 118 | }); -------------------------------------------------------------------------------- /smartio/client/cmd/index.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Smart IO 6 | 7 | 17 | 18 | 19 |
20 |
21 | Connecting... 22 | 23 |
24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /smartio/client/index.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Smart IO 6 | 7 | 17 | 18 | 19 |

click on the Green Leds to switch on and off, or send text commands "P" "S" "Se00" "Se0C",...

20 | 21 | 35 | 42 |
22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 |

All On

All Off

Light 0

Light 1

Light 2

Light 3

Light 4

Light 5

Light 6

Light 7

34 |
36 |
37 |
38 | Connecting... 39 | 40 |
41 |
43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /smartio/client/ledStyles.css: -------------------------------------------------------------------------------- 1 | /* more complex with blinking... on https://codepen.io/fskirschbaum/pen/MYJNaj */ 2 | 3 | .led-green-on { 4 | margin: 0 auto; 5 | width: 24px; 6 | height: 24px; 7 | background-color: #ABFF00; 8 | border-radius: 50%; 9 | box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #304701 0 -1px 9px, #89FF00 0 2px 12px; 10 | } 11 | 12 | .led-green-off { 13 | margin: 0 auto; 14 | width: 24px; 15 | height: 24px; 16 | background-color: #235000; 17 | border-radius: 50%; 18 | box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #304701 0 -1px 9px, #89FF00 0 2px 12px; 19 | } 20 | 21 | .led-all-on { 22 | margin: 0 auto; 23 | width: 32px; 24 | height: 32px; 25 | background-color: #90BB00; 26 | border-radius: 20%; 27 | box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #304701 0 -1px 9px, #89FF00 0 2px 12px; 28 | } 29 | 30 | .led-all-off { 31 | margin: 0 auto; 32 | width: 32px; 33 | height: 32px; 34 | background-color: #235000; 35 | border-radius: 20%; 36 | box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #304701 0 -1px 9px, #89FF00 0 2px 12px; 37 | } 38 | 39 | -------------------------------------------------------------------------------- /smartio/firmware/stm32_dongle/.gitignore: -------------------------------------------------------------------------------- 1 | .temp/ 2 | BUILD/ 3 | *.pyc 4 | mbed-os/ 5 | nrf-mesh/ 6 | Servo/ 7 | safe-uart/ 8 | crc/ 9 | .settings/ 10 | .vscode/ 11 | -------------------------------------------------------------------------------- /smartio/firmware/stm32_dongle/.mbed: -------------------------------------------------------------------------------- 1 | TARGET=BLUEPILL_F103C8 2 | ROOT=. 3 | -------------------------------------------------------------------------------- /smartio/firmware/stm32_dongle/Servo.lib: -------------------------------------------------------------------------------- 1 | https://developer.mbed.org/users/simon/code/Servo/#36b69a7ced07 2 | -------------------------------------------------------------------------------- /smartio/firmware/stm32_dongle/cf.bat: -------------------------------------------------------------------------------- 1 | call compile.bat 2 | call flash.bat 3 | -------------------------------------------------------------------------------- /smartio/firmware/stm32_dongle/compile.bat: -------------------------------------------------------------------------------- 1 | mbed compile -v --profile .\develop_nano.json -------------------------------------------------------------------------------- /smartio/firmware/stm32_dongle/crc.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/crc/#347fd1235c1306c9832b757d9378a7ac13ec6c49 2 | -------------------------------------------------------------------------------- /smartio/firmware/stm32_dongle/develop_nano.json: -------------------------------------------------------------------------------- 1 | { 2 | "GCC_ARM": { 3 | "common": ["-c", "-Wall", "-Wextra", 4 | "-Wno-unused-parameter", "-Wno-missing-field-initializers", 5 | "-fmessage-length=0", "-fno-exceptions", "-fno-builtin", 6 | "-ffunction-sections", "-fdata-sections", "-funsigned-char", 7 | "-MMD", "-fno-delete-null-pointer-checks", 8 | "-fomit-frame-pointer", "-Os"], 9 | "asm": ["-x", "assembler-with-cpp"], 10 | "c": ["-std=gnu99"], 11 | "cxx": ["-std=c++11", "-fno-rtti", "-Wvla"], 12 | "ld": ["-Wl,--gc-sections", "-Wl,--wrap,main", "-Wl,--wrap,_malloc_r", 13 | "-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r", 14 | "-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit", 15 | "-Wl,-n","--specs=nano.specs"] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /smartio/firmware/stm32_dongle/flash.bat: -------------------------------------------------------------------------------- 1 | REM $env:Path += ";C:\Users\Wass\.platformio\packages\tool-stlink" 2 | SET PATH=%PATH%;C:\Users\Wass\.platformio\packages\tool-stlink 3 | st-flash write .\BUILD\BLUEPILL_F103C8\GCC_ARM\stm32_dongle.bin 0x08000000 -------------------------------------------------------------------------------- /smartio/firmware/stm32_dongle/main.cpp: -------------------------------------------------------------------------------- 1 | #include "mbed.h" 2 | 3 | #include "rfmesh.h" 4 | #include "Servo.h" 5 | #include "suart.h" 6 | 7 | #define BOARD_IS_RF_DONGLE 1 8 | 9 | Serial rasp(PB_10, PB_11, 115200); 10 | DigitalOut myled(PC_13); 11 | Ticker tick_call; 12 | //nRF Modules 1:Gnd, 2:3.3v, 3:ce, 4:csn, 5:sck, 6:mosi, 7:miso, 8:irq 13 | #if BOARD_IS_RFPIO == 1 14 | //RfMesh mesh(&rasp, PA_5, PB_12, PB_13, PB_15, PB_14, PA_4); 15 | #elif BOARD_IS_RF_DONGLE ==1 16 | RfMesh mesh(&rasp, PC_15, PA_4, PA_5, PA_7, PA_6, PA_0); 17 | #endif 18 | 19 | suart com(&rasp); 20 | 21 | void the_ticker() 22 | { 23 | myled = !myled; 24 | 25 | } 26 | 27 | bool got_message = false; 28 | uint8_t payload[32]; 29 | 30 | void uart_message_received(uint8_t *data) 31 | { 32 | //rasp.printf("stm32_dongle> OK message received with %d Bytes\n",data[0]); 33 | uint8_t size = data[0]; 34 | for(int i=0;irf> Rx message (%d bytes) unused in dongle\n",size); 44 | } 45 | 46 | void init() 47 | { 48 | rasp.printf("stm32_dongle> Hello PIO Dongle\n"); 49 | 50 | tick_call.attach(&the_ticker,1); 51 | 52 | mesh.init();//left to the user for more flexibility on memory management 53 | 54 | mesh.nrf.selectChannel(22); 55 | 56 | mesh.attach(&rf_message_received,RfMesh::CallbackType::Message); 57 | 58 | com.attach(uart_message_received); 59 | 60 | } 61 | 62 | int main() 63 | { 64 | init(); 65 | 66 | while(1) 67 | { 68 | wait_ms(1); 69 | if(got_message) 70 | { 71 | rasp.printf("stm32_dongle> start transmission\n"); 72 | mesh.nrf.start_transmission(payload,payload[0]); 73 | got_message = false; 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /smartio/firmware/stm32_dongle/mbed-os.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/mbed-os/#4153c4a69a8c9963a00c28e6b28150049e0f1a30 2 | -------------------------------------------------------------------------------- /smartio/firmware/stm32_dongle/mbed_settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | mbed SDK 3 | Copyright (c) 2016 ARM Limited 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | """ 17 | 18 | from os.path import join, abspath, dirname 19 | 20 | #ROOT = abspath(join(dirname(__file__), ".")) 21 | 22 | ############################################################################## 23 | # Build System Settings 24 | ############################################################################## 25 | #BUILD_DIR = abspath(join(ROOT, "build")) 26 | 27 | # ARM 28 | #ARM_PATH = "C:/Program Files/ARM" 29 | 30 | # GCC ARM 31 | #GCC_ARM_PATH = "" 32 | 33 | # GCC CodeRed 34 | #GCC_CR_PATH = "C:/code_red/RedSuite_4.2.0_349/redsuite/Tools/bin" 35 | 36 | # IAR 37 | #IAR_PATH = "C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm" 38 | 39 | # Goanna static analyser. Please overload it in private_settings.py 40 | #GOANNA_PATH = "c:/Program Files (x86)/RedLizards/Goanna Central 3.2.3/bin" 41 | 42 | #BUILD_OPTIONS = [] 43 | 44 | # mbed.org username 45 | #MBED_ORG_USER = "" 46 | -------------------------------------------------------------------------------- /smartio/firmware/stm32_dongle/nrf-mesh.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/nrf-mesh/#e36a1cf12dc887878626f315ccb4e97d1768acd3 2 | -------------------------------------------------------------------------------- /smartio/firmware/stm32_dongle/safe-uart.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/safe-uart/#49096221f4b0482110a099232cab591627e1f63c 2 | -------------------------------------------------------------------------------- /smartio/firmware/stm32_rfio/.gitignore: -------------------------------------------------------------------------------- 1 | .temp/ 2 | BUILD/ 3 | *.pyc 4 | mbed-os/ 5 | nrf-mesh/ 6 | Servo/ 7 | safe-uart/ 8 | crc/ 9 | .settings/ 10 | .vscode/ 11 | -------------------------------------------------------------------------------- /smartio/firmware/stm32_rfio/.mbed: -------------------------------------------------------------------------------- 1 | TARGET=BLUEPILL_F103C8 2 | ROOT=. 3 | -------------------------------------------------------------------------------- /smartio/firmware/stm32_rfio/Servo.lib: -------------------------------------------------------------------------------- 1 | https://developer.mbed.org/users/simon/code/Servo/#36b69a7ced07 2 | -------------------------------------------------------------------------------- /smartio/firmware/stm32_rfio/cf.bat: -------------------------------------------------------------------------------- 1 | call compile.bat 2 | call flash.bat 3 | -------------------------------------------------------------------------------- /smartio/firmware/stm32_rfio/compile.bat: -------------------------------------------------------------------------------- 1 | mbed compile -v --profile .\develop_nano.json -------------------------------------------------------------------------------- /smartio/firmware/stm32_rfio/crc.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/crc/#347fd1235c1306c9832b757d9378a7ac13ec6c49 2 | -------------------------------------------------------------------------------- /smartio/firmware/stm32_rfio/develop_nano.json: -------------------------------------------------------------------------------- 1 | { 2 | "GCC_ARM": { 3 | "common": ["-c", "-Wall", "-Wextra", 4 | "-Wno-unused-parameter", "-Wno-missing-field-initializers", 5 | "-fmessage-length=0", "-fno-exceptions", "-fno-builtin", 6 | "-ffunction-sections", "-fdata-sections", "-funsigned-char", 7 | "-MMD", "-fno-delete-null-pointer-checks", 8 | "-fomit-frame-pointer", "-Os"], 9 | "asm": ["-x", "assembler-with-cpp"], 10 | "c": ["-std=gnu99"], 11 | "cxx": ["-std=c++11", "-fno-rtti", "-Wvla"], 12 | "ld": ["-Wl,--gc-sections", "-Wl,--wrap,main", "-Wl,--wrap,_malloc_r", 13 | "-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r", 14 | "-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit", 15 | "-Wl,-n","--specs=nano.specs"] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /smartio/firmware/stm32_rfio/flash.bat: -------------------------------------------------------------------------------- 1 | REM $env:Path += ";C:\Users\Wass\.platformio\packages\tool-stlink" 2 | SET PATH=%PATH%;C:\Users\Wass\.platformio\packages\tool-stlink 3 | st-flash write .\BUILD\BLUEPILL_F103C8\GCC_ARM\stm32_rfio.bin 0x08000000 -------------------------------------------------------------------------------- /smartio/firmware/stm32_rfio/main.cpp: -------------------------------------------------------------------------------- 1 | #include "mbed.h" 2 | 3 | #include "rfmesh.h" 4 | #include "Servo.h" 5 | #include "suart.h" 6 | 7 | Serial rasp(PB_10, PB_11, 115200); 8 | DigitalOut myled(PC_13); 9 | Ticker tick_call; 10 | //nRF Modules 1:Gnd, 2:3.3v, 3:ce, 4:csn, 5:sck, 6:mosi, 7:miso, 8:irq 11 | //RFPIO Layout !!!! 12 | RfMesh mesh(&rasp, PA_5, PB_12, PB_13, PB_15, PB_14, PA_4); 13 | 14 | Servo ser_m11(PA_8); 15 | Servo ser_m12(PA_9); 16 | Servo ser_m13(PA_10); 17 | Servo ser_m14(PA_11); 18 | Servo ser_m21(PA_15); 19 | Servo ser_m22(PB_3); 20 | Servo ser_m31(PB_4); 21 | Servo *msr[7]; 22 | 23 | DigitalOut pio_u1(PB_5); 24 | DigitalOut pio_u2(PB_6); 25 | DigitalOut pio_u3(PB_7); 26 | DigitalOut pio_u4(PB_8); 27 | DigitalOut pio_u5(PB_9); 28 | DigitalOut pio_u6(PB_1); 29 | DigitalOut pio_u7(PB_0); 30 | DigitalOut pio_u8(PA_7); 31 | DigitalOut *mio[8]; 32 | 33 | void the_ticker() 34 | { 35 | myled = !myled; 36 | 37 | } 38 | 39 | void rf_message_received(uint8_t *data,uint8_t size) 40 | { 41 | rasp.printf("rf>Rx message Handler : 0x"); 42 | for(int i = 0; i < size; i++) 43 | { 44 | rasp.printf(" %02x",data[i]); 45 | } 46 | rasp.printf("\r\n"); 47 | } 48 | 49 | void init() 50 | { 51 | wait_ms(100); 52 | 53 | msr[0] = &ser_m11; 54 | msr[1] = &ser_m12; 55 | msr[2] = &ser_m13; 56 | msr[3] = &ser_m14; 57 | msr[4] = &ser_m21; 58 | msr[5] = &ser_m22; 59 | msr[6] = &ser_m31; 60 | 61 | mio[0] = &pio_u1; 62 | mio[1] = &pio_u2; 63 | mio[2] = &pio_u3; 64 | mio[3] = &pio_u4; 65 | mio[4] = &pio_u5; 66 | mio[5] = &pio_u6; 67 | mio[6] = &pio_u7; 68 | mio[7] = &pio_u8; 69 | 70 | 71 | rasp.printf("Hello RFPIO\n"); 72 | 73 | tick_call.attach(&the_ticker,1); 74 | 75 | mesh.init();//left to the user for more flexibility on memory management 76 | 77 | rasp.printf("selectChannel(22)\n"); 78 | mesh.nrf.selectChannel(22); 79 | 80 | mesh.attach(&rf_message_received,RfMesh::CallbackType::Message); 81 | 82 | } 83 | 84 | int main() 85 | { 86 | init(); 87 | 88 | while(1) 89 | { 90 | for(int i=0;i<7;i++) 91 | { 92 | (*msr[i]) = 1; 93 | } 94 | for(int i=0;i<7;i++) 95 | { 96 | (*mio[i]) = 1; 97 | } 98 | wait(1.0); 99 | for(int i=0;i<7;i++) 100 | { 101 | (*msr[i]) = 0; 102 | } 103 | for(int i=0;i<7;i++) 104 | { 105 | (*mio[i]) = 0; 106 | } 107 | wait(1.0); 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /smartio/firmware/stm32_rfio/mbed-os.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/mbed-os/#4153c4a69a8c9963a00c28e6b28150049e0f1a30 2 | -------------------------------------------------------------------------------- /smartio/firmware/stm32_rfio/mbed_settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | mbed SDK 3 | Copyright (c) 2016 ARM Limited 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | """ 17 | 18 | from os.path import join, abspath, dirname 19 | 20 | #ROOT = abspath(join(dirname(__file__), ".")) 21 | 22 | ############################################################################## 23 | # Build System Settings 24 | ############################################################################## 25 | #BUILD_DIR = abspath(join(ROOT, "build")) 26 | 27 | # ARM 28 | #ARM_PATH = "C:/Program Files/ARM" 29 | 30 | # GCC ARM 31 | #GCC_ARM_PATH = "" 32 | 33 | # GCC CodeRed 34 | #GCC_CR_PATH = "C:/code_red/RedSuite_4.2.0_349/redsuite/Tools/bin" 35 | 36 | # IAR 37 | #IAR_PATH = "C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm" 38 | 39 | # Goanna static analyser. Please overload it in private_settings.py 40 | #GOANNA_PATH = "c:/Program Files (x86)/RedLizards/Goanna Central 3.2.3/bin" 41 | 42 | #BUILD_OPTIONS = [] 43 | 44 | # mbed.org username 45 | #MBED_ORG_USER = "" 46 | -------------------------------------------------------------------------------- /smartio/firmware/stm32_rfio/nrf-mesh.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/nrf-mesh/#be7666522dcf7cdbcb0bc6b93ae83341322ef677 -------------------------------------------------------------------------------- /smartio/firmware/stm32_rfio/safe-uart.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/safe-uart/#610e32cbc3285941b771a149defe521fdb42ad2c 2 | -------------------------------------------------------------------------------- /smartio/nodejs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "serialtest", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "wassfila", 10 | "license": "ISC", 11 | "dependencies": { 12 | "serial": "0.0.9", 13 | "serialport": "^4.0.1", 14 | "websocket": "1.0.23" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /smartio/nodejs/readme.md: -------------------------------------------------------------------------------- 1 | - "npm install" here to retrieve node_modules 2 | - run with "node serial_server.js" 3 | -------------------------------------------------------------------------------- /smartio/picpp/.gitignore: -------------------------------------------------------------------------------- 1 | rfpio 2 | -------------------------------------------------------------------------------- /smartio/picpp/SConstruct: -------------------------------------------------------------------------------- 1 | # - Glob() adds all the files with the extension to the list 2 | # - CPPPATH define the path where to look for source files which have include dependendcies 3 | # so that when these include files change, a recompilation of the source file is triggered 4 | # CPPPATH = ['include', '/home/project/inc'] 5 | 6 | env = Environment() 7 | env.Program( target='rfpio', 8 | source=[Glob('*.cpp'), 9 | [ 'pilibs/joystick.cpp', 10 | 'pilibs/serial.cpp', 11 | 'pilibs/utils.cpp', 12 | 'pilibs/log.cpp' 13 | ], 14 | ], 15 | CPPPATH = ['.','pilibs/'], 16 | CCFLAGS = ['-std=c++11'] 17 | ) 18 | -------------------------------------------------------------------------------- /smartio/picpp/configfile.txt: -------------------------------------------------------------------------------- 1 | #____________________________________________________________________________________________ 2 | # ! Important ! Format ! 3 | #____________________________________________________________________________________________ 4 | # every variable starts with the beginning of the line, no spaces, no space betweem '=' sign 5 | #____________________________________________________________________________________________ 6 | 7 | # -------------- STREAMER -------------- 8 | # The "port" parameter, once defined, enables the serial port buffer update 9 | portname=/dev/ttyUSB0 10 | portbaud=115200 11 | 12 | # -------------- Log -------------- 13 | # The "logfile" is optionnal used for persistance 14 | logfile=/home/pi/share/smartio_picpp.txt 15 | 16 | # 'level_out' is for console mode, and the 'level_file' is for the file record 17 | #Error:1, Warning:2, Info:3, Debug:4 18 | # default level_out is 19 | level_out=3 20 | level_file=2 21 | -------------------------------------------------------------------------------- /smartio/picpp/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | //for usleep 3 | #include 4 | //for printf 5 | #include 6 | //for stdout 7 | #include 8 | 9 | //for abs 10 | #include 11 | 12 | #include "joystick.hpp" 13 | #include "serial.hpp" 14 | #include "log.hpp" 15 | #include "utils.hpp" 16 | 17 | 18 | #define RESET "\033[0m" 19 | #define BLACK "\033[30m" /* Black */ 20 | #define RED "\033[31m" /* Red */ 21 | #define GREEN "\033[32m" /* Green */ 22 | #define YELLOW "\033[33m" /* Yellow */ 23 | #define BLUE "\033[34m" /* Blue */ 24 | #define MAGENTA "\033[35m" /* Magenta */ 25 | #define CYAN "\033[36m" /* Cyan */ 26 | #define WHITE "\033[37m" /* White */ 27 | #define BOLDBLACK "\033[1m\033[30m" /* Bold Black */ 28 | #define BOLDRED "\033[1m\033[31m" /* Bold Red */ 29 | #define BOLDGREEN "\033[1m\033[32m" /* Bold Green */ 30 | #define BOLDYELLOW "\033[1m\033[33m" /* Bold Yellow */ 31 | #define BOLDBLUE "\033[1m\033[34m" /* Bold Blue */ 32 | #define BOLDMAGENTA "\033[1m\033[35m" /* Bold Magenta */ 33 | #define BOLDCYAN "\033[1m\033[36m" /* Bold Cyan */ 34 | #define BOLDWHITE "\033[1m\033[37m" /* Bold White */ 35 | 36 | #define CLEAR "\033[2J" // clear screen escape code 37 | 38 | //Axis 5 : 1520 - 1950 39 | 40 | void printf_tab(const char* data, int size) 41 | { 42 | char line_print[400]; 43 | sprintf(line_print,"0x %02x %02x %02x %02x %02x %02x %02x\n",data[0],data[1],data[2],data[3],data[4],data[5],data[6]); 44 | std::string line(line_print); 45 | Log::cout << line << Log::Info(); 46 | } 47 | 48 | void printf_tab2(const char* data, int size) 49 | { 50 | char line_print[400]; 51 | sprintf(line_print,"0x %02x %02x\n",data[0],data[1]); 52 | std::string line(line_print); 53 | Log::cout << line << Log::Info(); 54 | } 55 | 56 | void MapAxis(JAxis &axis,char s_id,Serial&ser) 57 | { 58 | if(axis.isUpdated()) 59 | { 60 | int val = 10000*(axis.getValue()+1)/2;//[-1,+1] => [0, 1] 61 | uint8_t data[7]; 62 | data[0] = 5; //size is 5 63 | data[1] = 'S'; //Protocol 'Servos' 64 | data[2] = s_id; //Servo Id = '1' 65 | data[3] = val / 256; //16 bit val 66 | data[4] = val % 256; 67 | printf_tab2((const char*)&data[3],2); 68 | utl::crc_set(data); 69 | //printf_tab((const char*)data,7); 70 | ser.send((const char*)(data),5+2); 71 | } 72 | } 73 | 74 | void TestCom(Serial&ser) 75 | { 76 | int val = 55555;//[-1,+1] => [0, 1] 77 | uint8_t data[7]; 78 | data[0] = 5; //size is 5 79 | data[1] = 'S'; //Protocol 'Servos' 80 | data[2] = 1; //Servo Id = '1' 81 | data[3] = val / 256; //16 bit val 82 | data[4] = val % 256; 83 | //printf_tab2((const char*)&data[3],2); 84 | utl::crc_set(data); 85 | printf_tab((const char*)data,7); 86 | ser.send((const char*)(data),5+2); 87 | } 88 | 89 | 90 | int main( int argc, char** argv ) 91 | { 92 | std::cout << "______________________Config______________________" << std::endl; 93 | strmap conf; 94 | utl::args2map(argc,argv,conf);//here is checked './configfile.txt' 95 | 96 | Log::config(conf); 97 | 98 | Serial ser(conf); // - process serial port stream 99 | 100 | Joystick joy; 101 | 102 | //joy.start("/dev/input/js0"); 103 | 104 | //std::cout << MAGENTA << "Colored " << CYAN << "Text" << RESET << std::endl; 105 | 106 | usleep(1000000); 107 | TestCom(ser); 108 | 109 | while (1) 110 | { 111 | std::cout << CYAN; 112 | //Update the Joystick input 113 | #if 0 114 | if(joy.update())//multiple events will be filtered, only last would appear afterwards 115 | { 116 | //joy.printUpdates(); 117 | } 118 | MapAxis(joy.getAxis(5),1,ser);//Up 119 | joy.consumeAll(); 120 | #endif 121 | 122 | 123 | std::cout << RESET; 124 | //display Received log 125 | if(ser.update()) 126 | { 127 | ser.processBuffer(); 128 | ser.logBuffer();//log received line 129 | } 130 | usleep (10000); 131 | 132 | } 133 | 134 | return 0; 135 | } 136 | -------------------------------------------------------------------------------- /stm32_rf_dongle/action/.gitignore: -------------------------------------------------------------------------------- 1 | .temp/ 2 | BUILD/ 3 | *.pyc 4 | mbed-os/ 5 | nrf-mesh/ 6 | crc/ 7 | APDS9960/ 8 | ws2812B/ 9 | BME280/ 10 | -------------------------------------------------------------------------------- /stm32_rf_dongle/action/.mbed: -------------------------------------------------------------------------------- 1 | TARGET=BLUEPILL_F103C8 2 | ROOT=. 3 | -------------------------------------------------------------------------------- /stm32_rf_dongle/action/APDS9960.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/APDS9960/#7dfb597d66420b47cdd4a2574cdfa69d1fb083eb 2 | -------------------------------------------------------------------------------- /stm32_rf_dongle/action/cf.bat: -------------------------------------------------------------------------------- 1 | call compile.bat 2 | call flash.bat 3 | -------------------------------------------------------------------------------- /stm32_rf_dongle/action/compile.bat: -------------------------------------------------------------------------------- 1 | mbed compile -v --profile .\develop_nano.json -------------------------------------------------------------------------------- /stm32_rf_dongle/action/config_flash.bat: -------------------------------------------------------------------------------- 1 | REM $env:Path += ";C:\Users\Wass\.platformio\packages\tool-stlink" 2 | SET PATH=%PATH%;C:\Users\Wass\.platformio\packages\tool-stlink 3 | REM 0x0800FC00 is the adress of the last block 0..63 4 | st-flash write .\BUILD\BLUEPILL_F103C8\GCC_ARM\config.bin 0x0800FC00 5 | -------------------------------------------------------------------------------- /stm32_rf_dongle/action/config_read.bat: -------------------------------------------------------------------------------- 1 | REM $env:Path += ";C:\Users\Wass\.platformio\packages\tool-stlink" 2 | SET PATH=%PATH%;C:\Users\Wass\.platformio\packages\tool-stlink 3 | REM 0x0800FC00 is the adress of the last block 0..63 4 | st-flash read .\BUILD\BLUEPILL_F103C8\GCC_ARM\config.bin 0x0800FC00 0x400 5 | -------------------------------------------------------------------------------- /stm32_rf_dongle/action/crc.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/crc/#22593a25b890efbe1a6a6482d58237c28a0d94ea 2 | -------------------------------------------------------------------------------- /stm32_rf_dongle/action/develop_nano.json: -------------------------------------------------------------------------------- 1 | { 2 | "GCC_ARM": { 3 | "common": ["-c", "-Wall", "-Wextra", 4 | "-Wno-unused-parameter", "-Wno-missing-field-initializers", 5 | "-fmessage-length=0", "-fno-exceptions", "-fno-builtin", 6 | "-ffunction-sections", "-fdata-sections", "-funsigned-char", 7 | "-MMD", "-fno-delete-null-pointer-checks", 8 | "-fomit-frame-pointer", "-Os", "-g0"], 9 | "asm": ["-x", "assembler-with-cpp"], 10 | "c": ["-std=gnu99","-g0"], 11 | "cxx": ["-std=c++11", "-fno-rtti", "-Wvla","-g0"], 12 | "ld": ["-Wl,--gc-sections", "-Wl,--wrap,main", "-Wl,--wrap,_malloc_r", 13 | "-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r", 14 | "-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit", 15 | "-Wl,-n","--specs=nano.specs"] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /stm32_rf_dongle/action/flash.bat: -------------------------------------------------------------------------------- 1 | REM $env:Path += ";C:\Users\Wass\.platformio\packages\tool-stlink" 2 | SET PATH=%PATH%;C:\Users\Wass\.platformio\packages\tool-stlink 3 | st-flash write .\BUILD\BLUEPILL_F103C8\GCC_ARM\action.bin 0x08000000 -------------------------------------------------------------------------------- /stm32_rf_dongle/action/mbed-os.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/mbed-os/#4153c4a69a8c9963a00c28e6b28150049e0f1a30 2 | -------------------------------------------------------------------------------- /stm32_rf_dongle/action/mbed_settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | mbed SDK 3 | Copyright (c) 2016 ARM Limited 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | """ 17 | 18 | from os.path import join, abspath, dirname 19 | 20 | #ROOT = abspath(join(dirname(__file__), ".")) 21 | 22 | ############################################################################## 23 | # Build System Settings 24 | ############################################################################## 25 | #BUILD_DIR = abspath(join(ROOT, "build")) 26 | 27 | # ARM 28 | #ARM_PATH = "C:/Program Files/ARM" 29 | 30 | # GCC ARM 31 | #GCC_ARM_PATH = "" 32 | 33 | # GCC CodeRed 34 | #GCC_CR_PATH = "C:/code_red/RedSuite_4.2.0_349/redsuite/Tools/bin" 35 | 36 | # IAR 37 | #IAR_PATH = "C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm" 38 | 39 | # Goanna static analyser. Please overload it in private_settings.py 40 | #GOANNA_PATH = "c:/Program Files (x86)/RedLizards/Goanna Central 3.2.3/bin" 41 | 42 | #BUILD_OPTIONS = [] 43 | 44 | # mbed.org username 45 | #MBED_ORG_USER = "" 46 | -------------------------------------------------------------------------------- /stm32_rf_dongle/action/nrf-mesh.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/nrf-mesh/#d2be6ed0563a042cac8339a1d92eeb551dd81d6f 2 | -------------------------------------------------------------------------------- /stm32_rf_dongle/action/talk/talk.h: -------------------------------------------------------------------------------- 1 | /** @file WS2812B.h 2 | * 3 | * @author Wassim FILALI 4 | * Inferred from the Datasheet 5 | * 6 | * 7 | * @compiler gcc for STM32 8 | * 9 | * 10 | * started on local project on 10.10.2015 11 | * this file was created for refactoring on 03.01.2016 12 | * takeover for STM32 on 02.12.2017 13 | * $Date: 14 | * $Revision: 15 | * 16 | */ 17 | 18 | #ifndef __talk__ 19 | #define __talk__ 20 | 21 | #include "mbed.h" 22 | #include "rfmesh.h" 23 | #include "ws2812B.h" 24 | 25 | typedef struct 26 | { 27 | uint8_t id; 28 | uint8_t status; 29 | }partner_t; 30 | 31 | 32 | namespace talk 33 | { 34 | uint8_t const offline = 0x0; 35 | uint8_t const idle = 0x1; 36 | uint8_t const speak = 0x2; 37 | uint8_t const listen = 0x3; 38 | uint8_t const requesting = 0x4; 39 | uint8_t const requested_from = 0x5; 40 | 41 | uint8_t const online = 0xF; 42 | } 43 | 44 | 45 | class talk_node 46 | { 47 | public: 48 | talk_node(RfMesh* p_mesh,Serial* p_ser,ws2812B *p_led,uint8_t l_id); 49 | void self_acted(); 50 | void other_acted(); 51 | void broadcast(uint8_t *data,uint8_t size); 52 | void message(uint8_t *data,uint8_t size); 53 | 54 | void add_node(uint8_t wake_id); 55 | void get_nodes(uint8_t *data); 56 | uint8_t get_status(); 57 | 58 | private: 59 | RfMesh* mesh; 60 | Serial* ser; 61 | ws2812B* led; 62 | uint8_t node_id; 63 | 64 | void send_list(uint8_t target); 65 | void set_color(uint8_t r,uint8_t g,uint8_t b); 66 | void set_low(); 67 | void set_red(); 68 | void set_green(); 69 | void set_blue(); 70 | void set_yellow(); 71 | void set_orange(); 72 | void set_status(uint8_t st); 73 | uint8_t whos_in_state(uint8_t st); 74 | void update_node(uint8_t wake_id,uint8_t st); 75 | 76 | }; 77 | 78 | #endif /*__talk__*/ 79 | -------------------------------------------------------------------------------- /stm32_rf_dongle/action/ws2812B.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/ws2812B/#6a87648f43924991bd136a59007234b826f35e2c 2 | -------------------------------------------------------------------------------- /stm32_rf_dongle/cyclic_ping/.gitignore: -------------------------------------------------------------------------------- 1 | .temp/ 2 | BUILD/ 3 | *.pyc 4 | mbed-os/ 5 | nrf-mesh/ 6 | Servo/ 7 | safe-uart/ 8 | crc/ 9 | .settings/ 10 | .vscode/ 11 | -------------------------------------------------------------------------------- /stm32_rf_dongle/cyclic_ping/.mbed: -------------------------------------------------------------------------------- 1 | TARGET=BLUEPILL_F103C8 2 | ROOT=. 3 | -------------------------------------------------------------------------------- /stm32_rf_dongle/cyclic_ping/cf.bat: -------------------------------------------------------------------------------- 1 | call compile.bat 2 | call flash.bat 3 | -------------------------------------------------------------------------------- /stm32_rf_dongle/cyclic_ping/compile.bat: -------------------------------------------------------------------------------- 1 | mbed compile -v --profile .\develop_nano.json -------------------------------------------------------------------------------- /stm32_rf_dongle/cyclic_ping/crc.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/crc/#22593a25b890efbe1a6a6482d58237c28a0d94ea 2 | -------------------------------------------------------------------------------- /stm32_rf_dongle/cyclic_ping/develop_nano.json: -------------------------------------------------------------------------------- 1 | { 2 | "GCC_ARM": { 3 | "common": ["-c", "-Wall", "-Wextra", 4 | "-Wno-unused-parameter", "-Wno-missing-field-initializers", 5 | "-fmessage-length=0", "-fno-exceptions", "-fno-builtin", 6 | "-ffunction-sections", "-fdata-sections", "-funsigned-char", 7 | "-MMD", "-fno-delete-null-pointer-checks", 8 | "-fomit-frame-pointer", "-O0", "-g3"], 9 | "asm": ["-x", "assembler-with-cpp"], 10 | "c": ["-std=gnu99","-g"], 11 | "cxx": ["-std=c++11", "-fno-rtti", "-Wvla","-g"], 12 | "ld": ["-Wl,--gc-sections", "-Wl,--wrap,main", "-Wl,--wrap,_malloc_r", 13 | "-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r", 14 | "-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit", 15 | "-Wl,-n","--specs=nano.specs"] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /stm32_rf_dongle/cyclic_ping/flash.bat: -------------------------------------------------------------------------------- 1 | REM $env:Path += ";C:\Users\Wass\.platformio\packages\tool-stlink" 2 | SET PATH=%PATH%;C:\Users\Wass\.platformio\packages\tool-stlink 3 | st-flash write .\BUILD\BLUEPILL_F103C8\GCC_ARM\cyclic_ping.bin 0x08000000 -------------------------------------------------------------------------------- /stm32_rf_dongle/cyclic_ping/main.cpp: -------------------------------------------------------------------------------- 1 | #include "mbed.h" 2 | 3 | #include "rfmesh.h" 4 | #include "protocol.h" 5 | #include "utils.h" 6 | 7 | //------------------------------------- CONFIG ----------------------------------------- 8 | const uint8_t CHANNEL = 10; 9 | const uint8_t NODEID = 65; 10 | //-------------------------------------------------------------------------------------- 11 | 12 | Serial rasp(PB_10, PB_11, 115200); 13 | Proto prf(&rasp); 14 | DigitalOut myled(PC_13); 15 | Ticker tick_call; 16 | //nRF Modules 1:Gnd, 2:3.3v, 3:ce, 4:csn, 5:sck, 6:mosi, 7:miso, 8:irq 17 | RfMesh hsm(&rasp,1, PC_15, PA_4, PA_5, PA_7, PA_6, PA_0); 18 | 19 | uint8_t payload[32]; 20 | 21 | void the_ticker() 22 | { 23 | myled = !myled; 24 | } 25 | 26 | void init() 27 | { 28 | 29 | uint8_t * p_UID = (uint8_t*) 0x1FFFF7E8; 30 | 31 | rasp.printf("pinger> U_ID: "); 32 | print_tab(&rasp,p_UID,12); 33 | rasp.printf("pinger> Node ID: %d\r",NODEID); 34 | 35 | rasp.printf("pinger> Hi\n"); 36 | 37 | tick_call.attach(&the_ticker,1); 38 | 39 | hsm.init(CHANNEL); 40 | rasp.printf("pinger listening at channel %d\r",CHANNEL); 41 | hsm.setNodeId(NODEID); 42 | 43 | hsm.setRetries(0); 44 | hsm.setAckDelay(0); 45 | 46 | hsm.print_nrf(); 47 | 48 | } 49 | 50 | int main() 51 | { 52 | init(); 53 | 54 | while(1) 55 | { 56 | wait_ms(100); 57 | hsm.broadcast(rf::pid::reset); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /stm32_rf_dongle/cyclic_ping/mbed-os.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/mbed-os/#4153c4a69a8c9963a00c28e6b28150049e0f1a30 2 | -------------------------------------------------------------------------------- /stm32_rf_dongle/cyclic_ping/mbed_settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | mbed SDK 3 | Copyright (c) 2016 ARM Limited 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | """ 17 | 18 | from os.path import join, abspath, dirname 19 | 20 | #ROOT = abspath(join(dirname(__file__), ".")) 21 | 22 | ############################################################################## 23 | # Build System Settings 24 | ############################################################################## 25 | #BUILD_DIR = abspath(join(ROOT, "build")) 26 | 27 | # ARM 28 | #ARM_PATH = "C:/Program Files/ARM" 29 | 30 | # GCC ARM 31 | #GCC_ARM_PATH = "" 32 | 33 | # GCC CodeRed 34 | #GCC_CR_PATH = "C:/code_red/RedSuite_4.2.0_349/redsuite/Tools/bin" 35 | 36 | # IAR 37 | #IAR_PATH = "C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm" 38 | 39 | # Goanna static analyser. Please overload it in private_settings.py 40 | #GOANNA_PATH = "c:/Program Files (x86)/RedLizards/Goanna Central 3.2.3/bin" 41 | 42 | #BUILD_OPTIONS = [] 43 | 44 | # mbed.org username 45 | #MBED_ORG_USER = "" 46 | -------------------------------------------------------------------------------- /stm32_rf_dongle/cyclic_ping/nrf-mesh.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/nrf-mesh/#9c81311a8e750e0405b2011bcf31ac4612910092 2 | -------------------------------------------------------------------------------- /stm32_rf_dongle/host_controller_interface/.gitignore: -------------------------------------------------------------------------------- 1 | .temp/ 2 | BUILD/ 3 | *.pyc 4 | mbed-os/ 5 | nrf-mesh/ 6 | safe-uart/ 7 | crc/ 8 | .settings/ 9 | .vscode/ 10 | -------------------------------------------------------------------------------- /stm32_rf_dongle/host_controller_interface/.mbed: -------------------------------------------------------------------------------- 1 | TARGET=BLUEPILL_F103C8 2 | ROOT=. 3 | -------------------------------------------------------------------------------- /stm32_rf_dongle/host_controller_interface/cf.bat: -------------------------------------------------------------------------------- 1 | call compile.bat 2 | call flash.bat 3 | -------------------------------------------------------------------------------- /stm32_rf_dongle/host_controller_interface/compile.bat: -------------------------------------------------------------------------------- 1 | mbed compile -v --profile .\develop_nano.json -------------------------------------------------------------------------------- /stm32_rf_dongle/host_controller_interface/config_flash.bat: -------------------------------------------------------------------------------- 1 | REM $env:Path += ";C:\Users\Wass\.platformio\packages\tool-stlink" 2 | SET PATH=%PATH%;C:\Users\Wass\.platformio\packages\tool-stlink 3 | REM 0x0800FC00 is the adress of the last block 0..63 4 | st-flash write .\BUILD\BLUEPILL_F103C8\GCC_ARM\config.bin 0x0800FC00 5 | -------------------------------------------------------------------------------- /stm32_rf_dongle/host_controller_interface/config_read.bat: -------------------------------------------------------------------------------- 1 | REM $env:Path += ";C:\Users\Wass\.platformio\packages\tool-stlink" 2 | SET PATH=%PATH%;C:\Users\Wass\.platformio\packages\tool-stlink 3 | REM 0x0800FC00 is the adress of the last block 0..63 4 | st-flash read .\BUILD\BLUEPILL_F103C8\GCC_ARM\config.bin 0x0800FC00 0x400 5 | -------------------------------------------------------------------------------- /stm32_rf_dongle/host_controller_interface/crc.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/crc/#22593a25b890efbe1a6a6482d58237c28a0d94ea 2 | -------------------------------------------------------------------------------- /stm32_rf_dongle/host_controller_interface/develop_nano.json: -------------------------------------------------------------------------------- 1 | { 2 | "GCC_ARM": { 3 | "common": ["-c", "-Wall", "-Wextra", 4 | "-Wno-unused-parameter", "-Wno-missing-field-initializers", 5 | "-fmessage-length=0", "-fno-exceptions", "-fno-builtin", 6 | "-ffunction-sections", "-fdata-sections", "-funsigned-char", 7 | "-MMD", "-fno-delete-null-pointer-checks", 8 | "-fomit-frame-pointer", "-Os", "-g0"], 9 | "asm": ["-x", "assembler-with-cpp"], 10 | "c": ["-std=gnu99","-g0"], 11 | "cxx": ["-std=c++11", "-fno-rtti", "-Wvla","-g0"], 12 | "ld": ["-Wl,--gc-sections", "-Wl,--wrap,main", "-Wl,--wrap,_malloc_r", 13 | "-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r", 14 | "-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit", 15 | "-Wl,-n","--specs=nano.specs"] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /stm32_rf_dongle/host_controller_interface/flash.bat: -------------------------------------------------------------------------------- 1 | REM $env:Path += ";C:\Users\Wass\.platformio\packages\tool-stlink" 2 | SET PATH=%PATH%;C:\Users\Wass\.platformio\packages\tool-stlink 3 | st-flash write .\BUILD\BLUEPILL_F103C8\GCC_ARM\host_controller_interface.bin 0x08000000 4 | -------------------------------------------------------------------------------- /stm32_rf_dongle/host_controller_interface/mbed-os.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/mbed-os/#4153c4a69a8c9963a00c28e6b28150049e0f1a30 2 | -------------------------------------------------------------------------------- /stm32_rf_dongle/host_controller_interface/mbed_settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | mbed SDK 3 | Copyright (c) 2016 ARM Limited 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | """ 17 | 18 | from os.path import join, abspath, dirname 19 | 20 | #ROOT = abspath(join(dirname(__file__), ".")) 21 | 22 | ############################################################################## 23 | # Build System Settings 24 | ############################################################################## 25 | #BUILD_DIR = abspath(join(ROOT, "build")) 26 | 27 | # ARM 28 | #ARM_PATH = "C:/Program Files/ARM" 29 | 30 | # GCC ARM 31 | #GCC_ARM_PATH = "" 32 | 33 | # GCC CodeRed 34 | #GCC_CR_PATH = "C:/code_red/RedSuite_4.2.0_349/redsuite/Tools/bin" 35 | 36 | # IAR 37 | #IAR_PATH = "C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm" 38 | 39 | # Goanna static analyser. Please overload it in private_settings.py 40 | #GOANNA_PATH = "c:/Program Files (x86)/RedLizards/Goanna Central 3.2.3/bin" 41 | 42 | #BUILD_OPTIONS = [] 43 | 44 | # mbed.org username 45 | #MBED_ORG_USER = "" 46 | -------------------------------------------------------------------------------- /stm32_rf_dongle/host_controller_interface/nrf-mesh.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/nrf-mesh/#9c81311a8e750e0405b2011bcf31ac4612910092 2 | -------------------------------------------------------------------------------- /stm32_rf_dongle/host_controller_interface/safe-uart.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/safe-uart/#fa8ce43aa78e2d292bf726209d87b4430172f8d6 2 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_bridge/.gitignore: -------------------------------------------------------------------------------- 1 | .temp/ 2 | BUILD/ 3 | *.pyc 4 | mbed-os/ 5 | nrf-mesh/ 6 | crc/ 7 | APDS_9960/ 8 | ws2812B/ 9 | BME280/ 10 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_bridge/.mbed: -------------------------------------------------------------------------------- 1 | TARGET=BLUEPILL_F103C8 2 | ROOT=. 3 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_bridge/.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Mac", 5 | "includePath": [ 6 | "/usr/include", 7 | "/usr/local/include", 8 | "${workspaceRoot}" 9 | ], 10 | "defines": [], 11 | "intelliSenseMode": "clang-x64", 12 | "browse": { 13 | "path": [ 14 | "/usr/include", 15 | "/usr/local/include", 16 | "${workspaceRoot}" 17 | ], 18 | "limitSymbolsToIncludedHeaders": true, 19 | "databaseFilename": "" 20 | }, 21 | "macFrameworkPath": [ 22 | "/System/Library/Frameworks", 23 | "/Library/Frameworks" 24 | ] 25 | }, 26 | { 27 | "name": "Linux", 28 | "includePath": [ 29 | "/usr/include", 30 | "/usr/local/include", 31 | "${workspaceRoot}" 32 | ], 33 | "defines": [], 34 | "intelliSenseMode": "clang-x64", 35 | "browse": { 36 | "path": [ 37 | "/usr/include", 38 | "/usr/local/include", 39 | "${workspaceRoot}" 40 | ], 41 | "limitSymbolsToIncludedHeaders": true, 42 | "databaseFilename": "" 43 | } 44 | }, 45 | { 46 | "name": "Win32", 47 | "includePath": [ 48 | "${workspaceRoot}/mbed-os", 49 | "${workspaceRoot}" 50 | ], 51 | "defines": [ 52 | "_DEBUG", 53 | "UNICODE" 54 | ], 55 | "intelliSenseMode": "msvc-x64", 56 | "browse": { 57 | "path": [ 58 | "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include/*", 59 | "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/atlmfc/include/*", 60 | "C:/Program Files (x86)/Windows Kits/8.1/Include/um", 61 | "C:/Program Files (x86)/Windows Kits/8.1/Include/shared", 62 | "C:/Program Files (x86)/Windows Kits/8.1/Include/winrt", 63 | "${workspaceRoot}" 64 | ], 65 | "limitSymbolsToIncludedHeaders": true, 66 | "databaseFilename": "" 67 | } 68 | }, 69 | { 70 | "name": "arm_gcc", 71 | "includePath": [ 72 | "${workspaceRoot}/mbed-os/drivers/Serial.h", 73 | "C:/Program Files (x86)/GNU Tools ARM Embedded/6 2017-q1-update/arm-none-eabi/include/c++/6.3.1/arm-none-eabi/thumb/v8-m.main/fpv5/hard", 74 | "C:/Program Files (x86)/GNU Tools ARM Embedded/6 2017-q1-update/lib/gcc/arm-none-eabi/6.3.1/include", 75 | "${workspaceRoot}/mbed-os", 76 | "${workspaceRoot}", 77 | "${workspaceRoot}/safe-uart", 78 | "${workspaceRoot}/nrf-mesh", 79 | "C:/Program Files (x86)/GNU Tools ARM Embedded/6 2017-q1-update/arm-none-eabi/include/c++/6.3.1", 80 | "C:/Program Files (x86)/GNU Tools ARM Embedded/6 2017-q1-update/arm-none-eabi/include", 81 | "${workspaceRoot}/crc", 82 | "${workspaceRoot}/mbed-os/targets/TARGET_STM/TARGET_STM32F1", 83 | "${workspaceRoot}/mbed-os/targets/TARGET_STM/TARGET_STM32F1/TARGET_BLUEPILL_F103C8", 84 | "${workspaceRoot}/mbed-os/targets/TARGET_STM/TARGET_STM32F1/TARGET_BLUEPILL_F103C8/device", 85 | "${workspaceRoot}/mbed-os/cmsis", 86 | "${workspaceRoot}/mbed-os/targets/TARGET_STM/TARGET_STM32F1/device", 87 | "${workspaceRoot}/mbed-os/targets/TARGET_STM", 88 | "${workspaceRoot}/mbed-os/hal" 89 | ], 90 | "defines": [ 91 | "_DEBUG", 92 | "UNICODE" 93 | ], 94 | "intelliSenseMode": "msvc-x64", 95 | "browse": { 96 | "path": [ 97 | "${workspaceRoot}" 98 | ], 99 | "limitSymbolsToIncludedHeaders": true, 100 | "databaseFilename": "" 101 | } 102 | } 103 | ], 104 | "version": 3 105 | } -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_bridge/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "ios": "cpp", 4 | "xlocale": "cpp" 5 | }, 6 | "C_Cpp.errorSquiggles": "Disabled" 7 | } -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_bridge/APDS9960.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/APDS9960/#7dfb597d66420b47cdd4a2574cdfa69d1fb083eb 2 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_bridge/BME280.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/bme280#c685f5e95d869f3788700dafa58ca21846208f57 2 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_bridge/cf.bat: -------------------------------------------------------------------------------- 1 | call compile.bat 2 | call flash.bat 3 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_bridge/compile.bat: -------------------------------------------------------------------------------- 1 | mbed compile -v --profile .\develop_nano.json -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_bridge/config_flash.bat: -------------------------------------------------------------------------------- 1 | REM $env:Path += ";C:\Users\Wass\.platformio\packages\tool-stlink" 2 | SET PATH=%PATH%;C:\Users\Wass\.platformio\packages\tool-stlink 3 | REM 0x0800FC00 is the adress of the last block 0..63 4 | st-flash write .\BUILD\BLUEPILL_F103C8\GCC_ARM\config.bin 0x0800FC00 5 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_bridge/config_read.bat: -------------------------------------------------------------------------------- 1 | REM $env:Path += ";C:\Users\Wass\.platformio\packages\tool-stlink" 2 | SET PATH=%PATH%;C:\Users\Wass\.platformio\packages\tool-stlink 3 | REM 0x0800FC00 is the adress of the last block 0..63 4 | st-flash read .\BUILD\BLUEPILL_F103C8\GCC_ARM\config.bin 0x0800FC00 0x400 5 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_bridge/crc.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/crc/#22593a25b890efbe1a6a6482d58237c28a0d94ea 2 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_bridge/develop_nano.json: -------------------------------------------------------------------------------- 1 | { 2 | "GCC_ARM": { 3 | "common": ["-c", "-Wall", "-Wextra", 4 | "-Wno-unused-parameter", "-Wno-missing-field-initializers", 5 | "-fmessage-length=0", "-fno-exceptions", "-fno-builtin", 6 | "-ffunction-sections", "-fdata-sections", "-funsigned-char", 7 | "-MMD", "-fno-delete-null-pointer-checks", 8 | "-fomit-frame-pointer", "-Os", "-g0"], 9 | "asm": ["-x", "assembler-with-cpp"], 10 | "c": ["-std=gnu99","-g0"], 11 | "cxx": ["-std=c++11", "-fno-rtti", "-Wvla","-g0"], 12 | "ld": ["-Wl,--gc-sections", "-Wl,--wrap,main", "-Wl,--wrap,_malloc_r", 13 | "-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r", 14 | "-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit", 15 | "-Wl,-n","--specs=nano.specs"] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_bridge/flash.bat: -------------------------------------------------------------------------------- 1 | REM $env:Path += ";C:\Users\Wass\.platformio\packages\tool-stlink" 2 | SET PATH=%PATH%;C:\Users\Wass\.platformio\packages\tool-stlink 3 | st-flash write .\BUILD\BLUEPILL_F103C8\GCC_ARM\rf_bridge.bin 0x08000000 -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_bridge/mbed-os.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/mbed-os/#4153c4a69a8c9963a00c28e6b28150049e0f1a30 2 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_bridge/mbed_settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | mbed SDK 3 | Copyright (c) 2016 ARM Limited 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | """ 17 | 18 | from os.path import join, abspath, dirname 19 | 20 | #ROOT = abspath(join(dirname(__file__), ".")) 21 | 22 | ############################################################################## 23 | # Build System Settings 24 | ############################################################################## 25 | #BUILD_DIR = abspath(join(ROOT, "build")) 26 | 27 | # ARM 28 | #ARM_PATH = "C:/Program Files/ARM" 29 | 30 | # GCC ARM 31 | #GCC_ARM_PATH = "" 32 | 33 | # GCC CodeRed 34 | #GCC_CR_PATH = "C:/code_red/RedSuite_4.2.0_349/redsuite/Tools/bin" 35 | 36 | # IAR 37 | #IAR_PATH = "C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm" 38 | 39 | # Goanna static analyser. Please overload it in private_settings.py 40 | #GOANNA_PATH = "c:/Program Files (x86)/RedLizards/Goanna Central 3.2.3/bin" 41 | 42 | #BUILD_OPTIONS = [] 43 | 44 | # mbed.org username 45 | #MBED_ORG_USER = "" 46 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_bridge/nrf-mesh.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/nrf-mesh/#3788f4769a9d0aec2c886345ac394c2de7fe272f 2 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_bridge/ws2812B.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/ws2812B/#6a87648f43924991bd136a59007234b826f35e2c 2 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_heater/.gitignore: -------------------------------------------------------------------------------- 1 | .temp/ 2 | BUILD/ 3 | *.pyc 4 | mbed-os/ 5 | nrf-mesh/ 6 | Servo/ 7 | safe-uart/ 8 | crc/ 9 | .settings/ 10 | .vscode/ 11 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_heater/.mbed: -------------------------------------------------------------------------------- 1 | TARGET=BLUEPILL_F103C8 2 | ROOT=. 3 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_heater/cf.bat: -------------------------------------------------------------------------------- 1 | call compile.bat 2 | call flash.bat 3 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_heater/compile.bat: -------------------------------------------------------------------------------- 1 | mbed compile -v --profile .\develop_nano.json -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_heater/config_flash.bat: -------------------------------------------------------------------------------- 1 | REM $env:Path += ";C:\Users\Wass\.platformio\packages\tool-stlink" 2 | SET PATH=%PATH%;C:\Users\Wass\.platformio\packages\tool-stlink 3 | REM 0x0800FC00 is the adress of the last block 0..63 4 | st-flash write .\BUILD\BLUEPILL_F103C8\GCC_ARM\config.bin 0x0800FC00 5 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_heater/config_read.bat: -------------------------------------------------------------------------------- 1 | REM $env:Path += ";C:\Users\Wass\.platformio\packages\tool-stlink" 2 | SET PATH=%PATH%;C:\Users\Wass\.platformio\packages\tool-stlink 3 | REM 0x0800FC00 is the adress of the last block 0..63 4 | st-flash read .\BUILD\BLUEPILL_F103C8\GCC_ARM\config.bin 0x0800FC00 0x400 5 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_heater/crc.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/crc/#22593a25b890efbe1a6a6482d58237c28a0d94ea 2 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_heater/develop_nano.json: -------------------------------------------------------------------------------- 1 | { 2 | "GCC_ARM": { 3 | "common": ["-c", "-Wall", "-Wextra", 4 | "-Wno-unused-parameter", "-Wno-missing-field-initializers", 5 | "-fmessage-length=0", "-fno-exceptions", "-fno-builtin", 6 | "-ffunction-sections", "-fdata-sections", "-funsigned-char", 7 | "-MMD", "-fno-delete-null-pointer-checks", 8 | "-fomit-frame-pointer", "-O0", "-g3"], 9 | "asm": ["-x", "assembler-with-cpp"], 10 | "c": ["-std=gnu99","-g"], 11 | "cxx": ["-std=c++11", "-fno-rtti", "-Wvla","-g"], 12 | "ld": ["-Wl,--gc-sections", "-Wl,--wrap,main", "-Wl,--wrap,_malloc_r", 13 | "-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r", 14 | "-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit", 15 | "-Wl,-n","--specs=nano.specs"] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_heater/flash.bat: -------------------------------------------------------------------------------- 1 | REM $env:Path += ";C:\Users\Wass\.platformio\packages\tool-stlink" 2 | SET PATH=%PATH%;C:\Users\Wass\.platformio\packages\tool-stlink 3 | st-flash write .\BUILD\BLUEPILL_F103C8\GCC_ARM\rf_heater.bin 0x08000000 -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_heater/mbed-os.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/mbed-os/#4153c4a69a8c9963a00c28e6b28150049e0f1a30 2 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_heater/mbed_settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | mbed SDK 3 | Copyright (c) 2016 ARM Limited 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | """ 17 | 18 | from os.path import join, abspath, dirname 19 | 20 | #ROOT = abspath(join(dirname(__file__), ".")) 21 | 22 | ############################################################################## 23 | # Build System Settings 24 | ############################################################################## 25 | #BUILD_DIR = abspath(join(ROOT, "build")) 26 | 27 | # ARM 28 | #ARM_PATH = "C:/Program Files/ARM" 29 | 30 | # GCC ARM 31 | #GCC_ARM_PATH = "" 32 | 33 | # GCC CodeRed 34 | #GCC_CR_PATH = "C:/code_red/RedSuite_4.2.0_349/redsuite/Tools/bin" 35 | 36 | # IAR 37 | #IAR_PATH = "C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm" 38 | 39 | # Goanna static analyser. Please overload it in private_settings.py 40 | #GOANNA_PATH = "c:/Program Files (x86)/RedLizards/Goanna Central 3.2.3/bin" 41 | 42 | #BUILD_OPTIONS = [] 43 | 44 | # mbed.org username 45 | #MBED_ORG_USER = "" 46 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_heater/nrf-mesh.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/nrf-mesh/#0f3eeb27e8638f237e5ffc71ea6a3e996563d374 2 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_sniffer/.gitignore: -------------------------------------------------------------------------------- 1 | .temp/ 2 | BUILD/ 3 | *.pyc 4 | mbed-os/ 5 | nrf-mesh/ 6 | Servo/ 7 | safe-uart/ 8 | crc/ 9 | .settings/ 10 | .vscode/ 11 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_sniffer/.mbed: -------------------------------------------------------------------------------- 1 | TARGET=BLUEPILL_F103C8 2 | ROOT=. 3 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_sniffer/cf.bat: -------------------------------------------------------------------------------- 1 | call compile.bat 2 | call flash.bat 3 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_sniffer/compile.bat: -------------------------------------------------------------------------------- 1 | mbed compile -v --profile .\develop_nano.json -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_sniffer/config_flash.bat: -------------------------------------------------------------------------------- 1 | REM $env:Path += ";C:\Users\Wass\.platformio\packages\tool-stlink" 2 | SET PATH=%PATH%;C:\Users\Wass\.platformio\packages\tool-stlink 3 | REM 0x0800FC00 is the adress of the last block 0..63 4 | st-flash write .\BUILD\BLUEPILL_F103C8\GCC_ARM\config.bin 0x0800FC00 5 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_sniffer/config_read.bat: -------------------------------------------------------------------------------- 1 | REM $env:Path += ";C:\Users\Wass\.platformio\packages\tool-stlink" 2 | SET PATH=%PATH%;C:\Users\Wass\.platformio\packages\tool-stlink 3 | REM 0x0800FC00 is the adress of the last block 0..63 4 | st-flash read .\BUILD\BLUEPILL_F103C8\GCC_ARM\config.bin 0x0800FC00 0x400 5 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_sniffer/crc.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/crc/#22593a25b890efbe1a6a6482d58237c28a0d94ea 2 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_sniffer/develop_nano.json: -------------------------------------------------------------------------------- 1 | { 2 | "GCC_ARM": { 3 | "common": ["-c", "-Wall", "-Wextra", 4 | "-Wno-unused-parameter", "-Wno-missing-field-initializers", 5 | "-fmessage-length=0", "-fno-exceptions", "-fno-builtin", 6 | "-ffunction-sections", "-fdata-sections", "-funsigned-char", 7 | "-MMD", "-fno-delete-null-pointer-checks", 8 | "-fomit-frame-pointer", "-O0", "-g3"], 9 | "asm": ["-x", "assembler-with-cpp"], 10 | "c": ["-std=gnu99","-g"], 11 | "cxx": ["-std=c++11", "-fno-rtti", "-Wvla","-g"], 12 | "ld": ["-Wl,--gc-sections", "-Wl,--wrap,main", "-Wl,--wrap,_malloc_r", 13 | "-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r", 14 | "-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit", 15 | "-Wl,-n","--specs=nano.specs"] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_sniffer/flash.bat: -------------------------------------------------------------------------------- 1 | REM $env:Path += ";C:\Users\Wass\.platformio\packages\tool-stlink" 2 | SET PATH=%PATH%;C:\Users\Wass\.platformio\packages\tool-stlink 3 | st-flash write .\BUILD\BLUEPILL_F103C8\GCC_ARM\rf_sniffer.bin 0x08000000 -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_sniffer/main.cpp: -------------------------------------------------------------------------------- 1 | #include "mbed.h" 2 | 3 | #include "rfmesh.h" 4 | #include "protocol.h" 5 | #include "utils.h" 6 | 7 | //------------------------------------- CONFIG ----------------------------------------- 8 | #define FLASH_HEADER 0x0800FFF0 9 | #define F_NODEID *(uint8_t *) FLASH_HEADER 10 | //#define F_CHANNEL *(uint8_t *) (FLASH_HEADER+0x01) 11 | //issue hexeditor failure 12 | #define F_CHANNEL 10 13 | 14 | #define RF_BOARD_DONGLE 1 15 | #define RF_BOARD_PIO 0 16 | //-------------------------------------------------------------------------------------- 17 | Serial rasp(PB_10, PB_11, 115200); 18 | 19 | #if (RF_BOARD_DONGLE == 1) 20 | uint8_t spi_module = 1; 21 | //nRF Modules 1:Gnd, 2:3.3v, 3:ce, 4:csn, 5:sck, 6:mosi, 7:miso, 8:irq 22 | RfMesh hsm(&rasp,spi_module, PC_15, PA_4, PA_5, PA_7, PA_6, PA_0); 23 | #elif (RF_BOARD_PIO == 1) 24 | uint8_t spi_module = 2; 25 | #endif 26 | 27 | DigitalOut myled(PC_13); 28 | Ticker tick_call; 29 | 30 | void rf_sniffed(uint8_t *data,uint8_t size) 31 | { 32 | rasp.printf("sniff: "); print_tab(&rasp,data,size); 33 | } 34 | 35 | void the_ticker() 36 | { 37 | myled = !myled; 38 | } 39 | 40 | void init() 41 | { 42 | 43 | uint8_t * p_UID = (uint8_t*) 0x1FFFF7E8; 44 | 45 | rasp.printf("stm32 sniffer> U_ID: "); 46 | print_tab(&rasp,p_UID,12); 47 | rasp.printf("stm32 sniffer> Node ID: %d\r",F_NODEID); 48 | 49 | tick_call.attach(&the_ticker,1); 50 | 51 | hsm.init(F_CHANNEL); 52 | rasp.printf("stm32 sniffer> listening to Mesh 2.0 at channel %d\r",F_CHANNEL); 53 | hsm.setNodeId(F_NODEID); 54 | 55 | hsm.attach(&rf_sniffed,RfMesh::CallbackType::Sniff); 56 | 57 | } 58 | 59 | int main() 60 | { 61 | init(); 62 | 63 | while(1) 64 | { 65 | wait_ms(1); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_sniffer/mbed-os.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/mbed-os/#4153c4a69a8c9963a00c28e6b28150049e0f1a30 2 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_sniffer/mbed_settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | mbed SDK 3 | Copyright (c) 2016 ARM Limited 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | """ 17 | 18 | from os.path import join, abspath, dirname 19 | 20 | #ROOT = abspath(join(dirname(__file__), ".")) 21 | 22 | ############################################################################## 23 | # Build System Settings 24 | ############################################################################## 25 | #BUILD_DIR = abspath(join(ROOT, "build")) 26 | 27 | # ARM 28 | #ARM_PATH = "C:/Program Files/ARM" 29 | 30 | # GCC ARM 31 | #GCC_ARM_PATH = "" 32 | 33 | # GCC CodeRed 34 | #GCC_CR_PATH = "C:/code_red/RedSuite_4.2.0_349/redsuite/Tools/bin" 35 | 36 | # IAR 37 | #IAR_PATH = "C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm" 38 | 39 | # Goanna static analyser. Please overload it in private_settings.py 40 | #GOANNA_PATH = "c:/Program Files (x86)/RedLizards/Goanna Central 3.2.3/bin" 41 | 42 | #BUILD_OPTIONS = [] 43 | 44 | # mbed.org username 45 | #MBED_ORG_USER = "" 46 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_sniffer/nrf-mesh.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/nrf-mesh/#0f3eeb27e8638f237e5ffc71ea6a3e996563d374 2 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_sniffer/safe-uart.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/safe-uart/#d65d996e383bb2f26cf5b5063eef875407dd888d 2 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_timing.txt: -------------------------------------------------------------------------------- 1 | ----------------- SPI direct write,SPI 10MHz,Ping 32 B ----------------- 2 | transmit_Rx() : 492 us 3 | start_transmission() : 140 us 4 | wait_transmit() : 315 us 5 | setMode() : 36 us 6 | 7 | write_buffer() : 57 us 8 | ce cesn write add : 8 us 9 | buffer reg : 33 us 10 | csn ce wait : 16 us 11 | 12 | without ACK : 13 | nrf_irq() : 177 us 14 | readBuffer() : 80 us 15 | readbuffer->crc : 40 us 16 | crc_check() : 36 us 17 | 18 | 19 | 20 | 21 | ----------------- Ping 4 B ----------------- 22 | user send -> user rx callback : 2.013 ms 23 | start_tx -> rx_irq : 0.917 ms 24 | chip enable -> rx_irq : 283 us 25 | 26 | send_msg (4B) : 1.051 ms 27 | msg copy (4B) : 3.5 us 28 | set CRC (4B) : 7 us 29 | send_retries(0,0) : 1.04 ms 30 | 31 | send_retries() : 1.042 ms 32 | transmit_Rx() : 1.038 ms 33 | 34 | transmit_Rx() : 1.041 ms 35 | start_transmission(): 657 us 36 | wait_transmit() : 182 us 37 | setMode() : 201 us 38 | 39 | start_transmission() : 658 us 40 | write reg, set mode : 309 us 41 | write_buffer() : 326 us 42 | ce pulse : 23 us 43 | 44 | reception 45 | nrf_irq -> rf_message_handler : 1.06 ms 46 | rf_message_handler() : 787 us 47 | rf_message_handler -> exit : 32 us 48 | 49 | rf_message_handler() 50 | empty callback : 3.5 us 51 | --> crc : 2 us 52 | crc check (4B) : 7.5 us 53 | --> send ack : 4.5 us 54 | send_ack() : 766 us 55 | 56 | ----------------- Ping 32 B ----------------- 57 | nrf_irq() : 1.909 ms 58 | readBuffer() : 901 us 59 | crc_check() : 35 us 60 | send_ack() : 766 us 61 | 62 | transmit_Rx() : 2.312 ms 63 | start_transmission(): 1.802 ms 64 | wait_transmit() : 302 us 65 | setMode() : 208 us 66 | 67 | start_transmission() : 1.802 ms 68 | write reg, set mode : 311 us 69 | write_buffer() : 1.466 ms 70 | ce pulse : 25 us 71 | 72 | ----------------- SPI 10MHz Ping 32 B ----------------- 73 | nrf_irq() : 1.543 ms 74 | readBuffer() : 686 us 75 | 76 | 77 | start_transmission() 78 | write_buffer() : 1.240 us 79 | 80 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_uart_interface/.gitignore: -------------------------------------------------------------------------------- 1 | .temp/ 2 | BUILD/ 3 | *.pyc 4 | mbed-os/ 5 | nrf-mesh/ 6 | Servo/ 7 | safe-uart/ 8 | crc/ 9 | .settings/ 10 | .vscode/ 11 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_uart_interface/.mbed: -------------------------------------------------------------------------------- 1 | TARGET=BLUEPILL_F103C8 2 | ROOT=. 3 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_uart_interface/cf.bat: -------------------------------------------------------------------------------- 1 | call compile.bat 2 | call flash.bat 3 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_uart_interface/compile.bat: -------------------------------------------------------------------------------- 1 | mbed compile -v --profile .\develop_nano.json -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_uart_interface/config_flash.bat: -------------------------------------------------------------------------------- 1 | REM $env:Path += ";C:\Users\Wass\.platformio\packages\tool-stlink" 2 | SET PATH=%PATH%;C:\Users\Wass\.platformio\packages\tool-stlink 3 | REM 0x0800FC00 is the adress of the last block 0..63 4 | st-flash write .\BUILD\BLUEPILL_F103C8\GCC_ARM\config.bin 0x0800FC00 5 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_uart_interface/config_read.bat: -------------------------------------------------------------------------------- 1 | REM $env:Path += ";C:\Users\Wass\.platformio\packages\tool-stlink" 2 | SET PATH=%PATH%;C:\Users\Wass\.platformio\packages\tool-stlink 3 | REM 0x0800FC00 is the adress of the last block 0..63 4 | st-flash read .\BUILD\BLUEPILL_F103C8\GCC_ARM\config.bin 0x0800FC00 0x400 5 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_uart_interface/crc.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/crc/#22593a25b890efbe1a6a6482d58237c28a0d94ea 2 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_uart_interface/develop_nano.json: -------------------------------------------------------------------------------- 1 | { 2 | "GCC_ARM": { 3 | "common": ["-c", "-Wall", "-Wextra", 4 | "-Wno-unused-parameter", "-Wno-missing-field-initializers", 5 | "-fmessage-length=0", "-fno-exceptions", "-fno-builtin", 6 | "-ffunction-sections", "-fdata-sections", "-funsigned-char", 7 | "-MMD", "-fno-delete-null-pointer-checks", 8 | "-fomit-frame-pointer", "-Os", "-g0"], 9 | "asm": ["-x", "assembler-with-cpp"], 10 | "c": ["-std=gnu99","-g0"], 11 | "cxx": ["-std=c++11", "-fno-rtti", "-Wvla","-g0"], 12 | "ld": ["-Wl,--gc-sections", "-Wl,--wrap,main", "-Wl,--wrap,_malloc_r", 13 | "-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r", 14 | "-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit", 15 | "-Wl,-n","--specs=nano.specs"] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_uart_interface/flash.bat: -------------------------------------------------------------------------------- 1 | REM $env:Path += ";C:\Users\Wass\.platformio\packages\tool-stlink" 2 | SET PATH=%PATH%;C:\Users\Wass\.platformio\packages\tool-stlink 3 | st-flash write .\BUILD\BLUEPILL_F103C8\GCC_ARM\rf_uart_interface.bin 0x08000000 -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_uart_interface/mbed-os.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/mbed-os/#4153c4a69a8c9963a00c28e6b28150049e0f1a30 2 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_uart_interface/mbed_settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | mbed SDK 3 | Copyright (c) 2016 ARM Limited 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | """ 17 | 18 | from os.path import join, abspath, dirname 19 | 20 | #ROOT = abspath(join(dirname(__file__), ".")) 21 | 22 | ############################################################################## 23 | # Build System Settings 24 | ############################################################################## 25 | #BUILD_DIR = abspath(join(ROOT, "build")) 26 | 27 | # ARM 28 | #ARM_PATH = "C:/Program Files/ARM" 29 | 30 | # GCC ARM 31 | #GCC_ARM_PATH = "" 32 | 33 | # GCC CodeRed 34 | #GCC_CR_PATH = "C:/code_red/RedSuite_4.2.0_349/redsuite/Tools/bin" 35 | 36 | # IAR 37 | #IAR_PATH = "C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm" 38 | 39 | # Goanna static analyser. Please overload it in private_settings.py 40 | #GOANNA_PATH = "c:/Program Files (x86)/RedLizards/Goanna Central 3.2.3/bin" 41 | 42 | #BUILD_OPTIONS = [] 43 | 44 | # mbed.org username 45 | #MBED_ORG_USER = "" 46 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_uart_interface/nrf-mesh.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/nrf-mesh/#0f3eeb27e8638f237e5ffc71ea6a3e996563d374 2 | -------------------------------------------------------------------------------- /stm32_rf_dongle/rf_uart_interface/safe-uart.lib: -------------------------------------------------------------------------------- 1 | https://github.com/STM32Libs/safe-uart/#fa8ce43aa78e2d292bf726209d87b4430172f8d6 2 | -------------------------------------------------------------------------------- /tools/.gitignore: -------------------------------------------------------------------------------- 1 | nrf52_public.c 2 | app_dfu_package.zip 3 | settings.hex 4 | -------------------------------------------------------------------------------- /tools/cfg.py: -------------------------------------------------------------------------------- 1 | import sys,os 2 | import json 3 | import socket 4 | from collections import OrderedDict 5 | 6 | # -------------------- config -------------------- 7 | def get_local_json(): 8 | """fetches the config.json file in the local directory 9 | if config_hostname.json is found it is used over the default one 10 | """ 11 | config = None 12 | dirname = os.path.dirname(sys.argv[0]) 13 | if(len(dirname) == 0): 14 | dirname = "." 15 | config_file = dirname+'/'+"config_"+socket.gethostname()+".json" 16 | if(os.path.isfile(config_file)): 17 | #print("loading: ",config_file) 18 | config = json.load(open(config_file)) 19 | else: 20 | config_file = dirname+'/'+"config.json" 21 | if(os.path.isfile(config_file)): 22 | #print("loading: %s",config_file) 23 | config = json.load(open(config_file)) 24 | else: 25 | print("Fatal error 'config.json' not found") 26 | return config 27 | 28 | # -------------------- config -------------------- 29 | def get_json(nodes_file): 30 | nodes = json.load(open(nodes_file),object_pairs_hook=OrderedDict) 31 | return nodes 32 | -------------------------------------------------------------------------------- /tools/off.bat: -------------------------------------------------------------------------------- 1 | cd /D "%~dp0" 2 | C:/Python27/python.exe -c "from uicr import *;jlink.power_off()" 3 | -------------------------------------------------------------------------------- /tools/on.bat: -------------------------------------------------------------------------------- 1 | cd /D "%~dp0" 2 | C:/Python27/python.exe -c "from uicr import *;jlink.power_on()" 3 | -------------------------------------------------------------------------------- /tools/package.bat: -------------------------------------------------------------------------------- 1 | nrfutil pkg generate --hw-version 52 --sd-req 0x80 --application-version 3 --application ..\applications\nrf52_sensortag\_build\nrf52832_xxaa.hex --key-file "%VAULT%\nrf52_priv.pem" app_dfu_package.zip -------------------------------------------------------------------------------- /tools/private.bat: -------------------------------------------------------------------------------- 1 | nrfutil keys generate %VAULT%\nrf52_priv.pem -------------------------------------------------------------------------------- /tools/public.bat: -------------------------------------------------------------------------------- 1 | nrfutil keys display --key pk --format code %VAULT%\nrf52_priv.pem --out_file nrf52_public.c -------------------------------------------------------------------------------- /tools/read.bat: -------------------------------------------------------------------------------- 1 | C:\Python27\python.exe -c "from uicr import *;start();read_id();read_config()" 2 | -------------------------------------------------------------------------------- /tools/uicr_map.json: -------------------------------------------------------------------------------- 1 | { 2 | "mesh_id" : "CUSTOMER_0", 3 | "channel" : "CUSTOMER_1", 4 | "sleep" : "CUSTOMER_2", 5 | "is_listening" : "CUSTOMER_3", 6 | "is_router" : "CUSTOMER_4", 7 | "is_rf_cmd" : "CUSTOMER_5", 8 | "is_rf2uart" : "CUSTOMER_6", 9 | "is_uart_cmd" : "CUSTOMER_7", 10 | "rtx_timeout" : "CUSTOMER_8", 11 | "rtx_max_timeout": "CUSTOMER_9", 12 | "rtx_count" : "CUSTOMER_10" 13 | } 14 | -------------------------------------------------------------------------------- /tools/write.bat: -------------------------------------------------------------------------------- 1 | C:\Python27\python.exe -c "from uicr import *;start();read_id();write_config()" 2 | --------------------------------------------------------------------------------