├── .gitmodules ├── ArduinoIDE ├── ESP8266 │ ├── README.md │ ├── official-demo │ │ ├── AnydataToggle │ │ │ ├── AnydataToggle.ino │ │ │ ├── anydata_0.h │ │ │ ├── anydata_1.h │ │ │ ├── prebuild │ │ │ │ ├── bin │ │ │ │ │ └── bin.zip │ │ │ │ ├── gen_h.bat │ │ │ │ └── json │ │ │ │ │ ├── anydata_0.json │ │ │ │ │ ├── anydata_1.json │ │ │ │ │ └── toggle_2.json │ │ │ └── toggle_2.h │ │ ├── IoTmanager │ │ │ └── IoTmanager.ino │ │ ├── IoTmanager2 │ │ │ └── IoTmanager2.ino │ │ ├── IoTmanager3 │ │ │ └── IoTmanager3.ino │ │ ├── IoTmanager4 │ │ │ └── IoTmanager4.ino │ │ ├── IoTmanager5 │ │ │ └── IoTmanager5.ino │ │ ├── PushNotifications │ │ │ └── PushNotifications.ino │ │ ├── README.md │ │ └── anydata │ │ │ └── anydata.ino │ └── users-demo │ │ ├── README.md │ │ └── bmp180 │ │ ├── Adafruit-BMP085 │ │ ├── Adafruit_BMP085.cpp │ │ ├── Adafruit_BMP085.h │ │ ├── BMP085.cpp │ │ ├── BMP085.h │ │ ├── COPYING │ │ ├── COPYING.LESSER │ │ ├── INSTALL.txt │ │ ├── README.txt │ │ ├── examples │ │ │ ├── .svn │ │ │ │ ├── all-wcprops │ │ │ │ └── entries │ │ │ ├── BMP085_output │ │ │ │ ├── .svn │ │ │ │ │ ├── all-wcprops │ │ │ │ │ ├── entries │ │ │ │ │ └── text-base │ │ │ │ │ │ └── BMP085_output.ino.svn-base │ │ │ │ └── BMP085_output.ino │ │ │ ├── BMP085_test1 │ │ │ │ ├── .svn │ │ │ │ │ ├── all-wcprops │ │ │ │ │ ├── entries │ │ │ │ │ └── text-base │ │ │ │ │ │ └── BMP085_test1.ino.svn-base │ │ │ │ └── BMP085_test1.ino │ │ │ ├── BMP085_test2 │ │ │ │ ├── .svn │ │ │ │ │ ├── all-wcprops │ │ │ │ │ ├── entries │ │ │ │ │ └── text-base │ │ │ │ │ │ └── BMP085_test2.ino.svn-base │ │ │ │ └── BMP085_test2.ino │ │ │ └── BMP085test │ │ │ │ └── BMP085test.ino │ │ ├── keywords.txt │ │ └── library.properties │ │ ├── README.md │ │ └── bmp180.ino └── README.md ├── LICENSE ├── README.md ├── node.js ├── official-demo │ ├── .gitignore │ ├── README.md │ ├── boiler.js │ ├── bulb.js │ ├── chart.js │ ├── clear-retain.js │ ├── config.js │ ├── demo.js │ ├── display-value.js │ ├── fillgauge.js │ ├── gauge.js │ ├── home.js │ ├── joystick-btn.js │ ├── linear.js │ ├── markdown.js │ ├── package.json │ ├── simple-btn.js │ ├── speech.js │ ├── toggle.js │ └── v2 │ │ ├── .gitignore │ │ ├── README.md │ │ ├── demo1.js │ │ └── package.json └── users │ └── willey_ │ └── saver.js ├── platformio ├── heater │ ├── .gitignore │ ├── .travis.yml │ ├── extra_script.py │ ├── lib │ │ ├── readme.txt │ │ └── widgets │ │ │ ├── line01_00.h │ │ │ ├── line02_01.h │ │ │ ├── line02_02.h │ │ │ ├── line02_03.h │ │ │ ├── line03_04.h │ │ │ ├── line04_05.h │ │ │ ├── line04_06.h │ │ │ ├── line04_07.h │ │ │ ├── line05_08.h │ │ │ └── line06_09.h │ ├── platformio.ini │ ├── prebuild │ │ ├── bin │ │ │ └── bin.zip │ │ ├── gen_h.bat │ │ └── json │ │ │ ├── line01_00.json │ │ │ ├── line02_01.json │ │ │ ├── line02_02.json │ │ │ ├── line02_03.json │ │ │ ├── line03_04.json │ │ │ ├── line04_05.json │ │ │ ├── line04_06.json │ │ │ ├── line04_07.json │ │ │ ├── line05_08.json │ │ │ └── line06_09.json │ ├── readme.md │ └── src │ │ └── heater.ino ├── home │ ├── .gitignore │ ├── .travis.yml │ ├── lib │ │ └── readme.txt │ ├── platformio.ini │ ├── readme.md │ └── src │ │ └── value.ino └── rv9yw_fill_gauge │ ├── lib │ └── readme.txt │ ├── platformio.ini │ ├── readme.md │ └── src │ └── value.ino ├── python ├── .gitignore ├── README.md ├── main.py ├── push.py └── sensor │ ├── __init__.py │ ├── la.py │ ├── la15.py │ ├── la5.py │ ├── mem.py │ ├── sdcard.py │ └── temp.py └── utils └── json2h ├── README ├── bin ├── linux │ └── json2h └── windows │ └── json2h.zip ├── json2h.pro ├── main.cpp └── samples ├── test1.json └── test1.json.h /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "bash/users/RaspyIot"] 2 | path = bash/users/RaspyIot 3 | url = https://github.com/bigjohnson/RaspyIot.git 4 | -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/README.md: -------------------------------------------------------------------------------- 1 | ### official-demo - sketches from IoT Manager developers 2 | ### users-demo - users sketches 3 | -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/official-demo/AnydataToggle/anydata_0.h: -------------------------------------------------------------------------------- 1 | const char anydata_0_json[] = { 2 | 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x69, 0x64, 0x22, 0x20, 0x20, 0x20, 3 | 0x20, 0x20, 0x3a, 0x20, 0x22, 0x30, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 4 | 0x22, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x20, 0x3a, 0x20, 0x22, 5 | 0x4d, 0x79, 0x20, 0x48, 0x6f, 0x6d, 0x65, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 6 | 0x20, 0x22, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x22, 0x20, 0x3a, 0x20, 7 | 0x22, 0x61, 0x6e, 0x79, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2c, 0x0d, 0x0a, 8 | 0x20, 0x20, 0x22, 0x70, 0x61, 0x67, 0x65, 0x22, 0x20, 0x20, 0x20, 0x3a, 9 | 0x20, 0x22, 0x4b, 0x69, 0x74, 0x63, 0x68, 0x65, 0x6e, 0x22, 0x2c, 0x0d, 10 | 0x0a, 0x20, 0x20, 0x22, 0x70, 0x61, 0x67, 0x65, 0x49, 0x64, 0x22, 0x20, 11 | 0x3a, 0x20, 0x31, 0x30, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x74, 0x6f, 12 | 0x70, 0x69, 0x63, 0x22, 0x20, 0x20, 0x3a, 0x20, 0x22, 0x2f, 0x49, 0x6f, 13 | 0x54, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2f, 0x64, 0x65, 0x76, 14 | 0x32, 0x32, 0x2f, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x30, 0x22, 0x2c, 15 | 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x31, 0x22, 16 | 0x20, 0x3a, 0x20, 0x22, 0x69, 0x74, 0x65, 0x6d, 0x20, 0x6e, 0x6f, 0x2d, 17 | 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 18 | 0x22, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x32, 0x22, 0x20, 0x3a, 0x20, 0x22, 19 | 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x34, 0x30, 20 | 0x70, 0x78, 0x3b, 0x6c, 0x69, 0x6e, 0x65, 0x2d, 0x68, 0x65, 0x69, 0x67, 21 | 0x68, 0x74, 0x3a, 0x33, 0x65, 0x6d, 0x3b, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 22 | 0x20, 0x22, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x33, 0x22, 0x20, 0x3a, 0x20, 23 | 0x22, 0x63, 0x61, 0x6c, 0x6d, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x63, 24 | 0x65, 0x6e, 0x74, 0x65, 0x72, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 25 | 0x73, 0x74, 0x79, 0x6c, 0x65, 0x33, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x66, 26 | 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x34, 0x30, 0x70, 27 | 0x78, 0x3b, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x77, 0x65, 0x69, 0x67, 0x68, 28 | 0x74, 0x3a, 0x62, 0x6f, 0x6c, 0x64, 0x3b, 0x22, 0x0d, 0x0a, 0x7d, 0x0d, 29 | 0x0a, 0x00 30 | }; 31 | const int anydata_0_len = 326; 32 | -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/official-demo/AnydataToggle/anydata_1.h: -------------------------------------------------------------------------------- 1 | const char anydata_1_json[] = { 2 | 0x7b, 0x0a, 0x20, 0x20, 0x22, 0x69, 0x64, 0x22, 0x20, 0x20, 0x20, 0x20, 3 | 0x20, 0x3a, 0x20, 0x22, 0x31, 0x22, 0x2c, 0x0a, 0x20, 0x20, 0x22, 0x64, 4 | 0x65, 0x73, 0x63, 0x72, 0x22, 0x20, 0x20, 0x3a, 0x20, 0x22, 0x41, 0x44, 5 | 0x43, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x2c, 0x0a, 0x20, 0x20, 6 | 0x22, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x22, 0x20, 0x3a, 0x20, 0x22, 7 | 0x61, 0x6e, 0x79, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2c, 0x0a, 0x20, 0x20, 8 | 0x22, 0x70, 0x61, 0x67, 0x65, 0x22, 0x20, 0x20, 0x20, 0x3a, 0x20, 0x22, 9 | 0x4b, 0x69, 0x74, 0x63, 0x68, 0x65, 0x6e, 0x22, 0x2c, 0x0a, 0x20, 0x20, 10 | 0x22, 0x70, 0x61, 0x67, 0x65, 0x49, 0x64, 0x22, 0x20, 0x3a, 0x20, 0x31, 11 | 0x30, 0x2c, 0x0a, 0x20, 0x20, 0x22, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x22, 12 | 0x20, 0x20, 0x3a, 0x20, 0x22, 0x2f, 0x49, 0x6f, 0x54, 0x6d, 0x61, 0x6e, 13 | 0x61, 0x67, 0x65, 0x72, 0x2f, 0x64, 0x65, 0x76, 0x32, 0x32, 0x2f, 0x77, 14 | 0x69, 0x64, 0x67, 0x65, 0x74, 0x31, 0x22, 0x2c, 0x0a, 0x20, 0x20, 0x22, 15 | 0x63, 0x6c, 0x61, 0x73, 0x73, 0x31, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x69, 16 | 0x74, 0x65, 0x6d, 0x20, 0x6e, 0x6f, 0x2d, 0x62, 0x6f, 0x72, 0x64, 0x65, 17 | 0x72, 0x22, 0x2c, 0x0a, 0x20, 0x20, 0x22, 0x73, 0x74, 0x79, 0x6c, 0x65, 18 | 0x32, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 19 | 0x69, 0x7a, 0x65, 0x3a, 0x32, 0x38, 0x70, 0x78, 0x3b, 0x66, 0x6c, 0x6f, 20 | 0x61, 0x74, 0x3a, 0x6c, 0x65, 0x66, 0x74, 0x3b, 0x6c, 0x69, 0x6e, 0x65, 21 | 0x2d, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x33, 0x65, 0x6d, 0x22, 22 | 0x2c, 0x0a, 0x20, 0x20, 0x22, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x33, 0x22, 23 | 0x20, 0x3a, 0x20, 0x22, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x64, 24 | 0x2d, 0x62, 0x67, 0x20, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x20, 0x70, 0x61, 25 | 0x64, 0x64, 0x69, 0x6e, 0x67, 0x2d, 0x6c, 0x65, 0x66, 0x74, 0x20, 0x70, 26 | 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x2d, 0x72, 0x69, 0x67, 0x68, 0x74, 27 | 0x20, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x65, 0x64, 0x22, 0x2c, 0x0a, 0x20, 28 | 0x20, 0x22, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x33, 0x22, 0x20, 0x3a, 0x20, 29 | 0x22, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x34, 30 | 0x30, 0x70, 0x78, 0x3b, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x77, 0x65, 0x69, 31 | 0x67, 0x68, 0x74, 0x3a, 0x62, 0x6f, 0x6c, 0x64, 0x3b, 0x66, 0x6c, 0x6f, 32 | 0x61, 0x74, 0x3a, 0x72, 0x69, 0x67, 0x68, 0x74, 0x3b, 0x6c, 0x69, 0x6e, 33 | 0x65, 0x2d, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x31, 0x2e, 0x35, 34 | 0x65, 0x6d, 0x3b, 0x22, 0x0a, 0x7d, 0x0a, 0x00 35 | }; 36 | const int anydata_1_len = 392; 37 | -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/official-demo/AnydataToggle/prebuild/bin/bin.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4refr0nt/iot-manager-demo/5ceed46ccf538e5bac9b92a03452eed21d27f74f/ArduinoIDE/ESP8266/official-demo/AnydataToggle/prebuild/bin/bin.zip -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/official-demo/AnydataToggle/prebuild/gen_h.bat: -------------------------------------------------------------------------------- 1 | @Echo off 2 | cls 3 | echo. 4 | echo. 5 | echo ----------------------------------------- 6 | echo JSON to .h header files converter 7 | echo ----------------------------------------- 8 | echo. 9 | md temp >nul 10 | echo. 11 | echo ......................................... 12 | for %%f in (json/*.*) do ( 13 | echo Processing: %%f 14 | copy json\%%f temp\%%~nf.j >nul 15 | bin\echo -n -e \0000 >> temp\%%~nf.j 16 | bin\xxd -i temp\%%~nf.j > temp\%%~nf.x 17 | bin\sed "s/unsigned char temp_%%~nf\_j\[\]\ =/const char %%~nf_json[] =/" temp\%%~nf.x | sed "s/unsigned int temp_%%~nf\_j\_len/const int %%~nf\_len/" > ..\%%~nf.h 18 | echo Resulting : %%~nf.h 19 | echo ......................................... 20 | ) 21 | echo. 22 | del /Q /S temp\*.j >nul 23 | del /Q /S temp\*.x >nul 24 | rd temp >nul 25 | echo ----------------------------------------- 26 | echo Done. 27 | echo ----------------------------------------- 28 | -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/official-demo/AnydataToggle/prebuild/json/anydata_0.json: -------------------------------------------------------------------------------- 1 | { 2 | "id" : "0", 3 | "status" : "My Home", 4 | "widget" : "anydata", 5 | "page" : "Kitchen", 6 | "pageId" : 10, 7 | "topic" : "/IoTmanager/dev22/widget0", 8 | "class1" : "item no-border", 9 | "style2" : "font-size:40px;line-height:3em;", 10 | "class3" : "calm text-center", 11 | "style3" : "font-size:40px;font-weight:bold;" 12 | } 13 | -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/official-demo/AnydataToggle/prebuild/json/anydata_1.json: -------------------------------------------------------------------------------- 1 | { 2 | "id" : "1", 3 | "descr" : "ADC value", 4 | "widget" : "anydata", 5 | "page" : "Kitchen", 6 | "pageId" : 10, 7 | "topic" : "/IoTmanager/dev22/widget1", 8 | "class1" : "item no-border", 9 | "style2" : "font-size:28px;float:left;line-height:3em", 10 | "class3" : "balanced-bg light padding-left padding-right rounded", 11 | "style3" : "font-size:40px;font-weight:bold;float:right;line-height:1.5em;" 12 | } 13 | -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/official-demo/AnydataToggle/prebuild/json/toggle_2.json: -------------------------------------------------------------------------------- 1 | { 2 | "id" : "2", 3 | "descr" : "Kitchen lamp", 4 | "page" : "Kitchen", 5 | "pageId" : 10, 6 | "widget" : "toggle", 7 | "topic" : "/IoTmanager/dev22/widget2", 8 | "iconClass" : "ion-ios-flame", 9 | "iconClassOff": "ion-ios-flame-outline", 10 | "iconStyle" : "font-size:30px;color:#ff3d3d;", 11 | "iconStyleOff": "font-size:30px;color:#eee;", 12 | "descrStyle" : "font-size:20px;line-height:1.5em;" 13 | } 14 | -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/official-demo/AnydataToggle/toggle_2.h: -------------------------------------------------------------------------------- 1 | const char toggle_2_json[] = { 2 | 0x7b, 0x0a, 0x20, 0x20, 0x22, 0x69, 0x64, 0x22, 0x20, 0x20, 0x20, 0x20, 3 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3a, 0x20, 0x22, 0x32, 0x22, 0x2c, 4 | 0x0a, 0x20, 0x20, 0x22, 0x64, 0x65, 0x73, 0x63, 0x72, 0x22, 0x20, 0x20, 5 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x3a, 0x20, 0x22, 0x4b, 0x69, 0x74, 0x63, 6 | 0x68, 0x65, 0x6e, 0x20, 0x6c, 0x61, 0x6d, 0x70, 0x22, 0x2c, 0x0a, 0x20, 7 | 0x20, 0x22, 0x70, 0x61, 0x67, 0x65, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 8 | 0x20, 0x20, 0x20, 0x3a, 0x20, 0x22, 0x4b, 0x69, 0x74, 0x63, 0x68, 0x65, 9 | 0x6e, 0x22, 0x2c, 0x0a, 0x20, 0x20, 0x22, 0x70, 0x61, 0x67, 0x65, 0x49, 10 | 0x64, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3a, 0x20, 0x31, 0x30, 11 | 0x2c, 0x0a, 0x20, 0x20, 0x22, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x22, 12 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3a, 0x20, 0x22, 0x74, 0x6f, 0x67, 13 | 0x67, 0x6c, 0x65, 0x22, 0x2c, 0x0a, 0x20, 0x20, 0x22, 0x74, 0x6f, 0x70, 14 | 0x69, 0x63, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3a, 0x20, 15 | 0x22, 0x2f, 0x49, 0x6f, 0x54, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 16 | 0x2f, 0x64, 0x65, 0x76, 0x32, 0x32, 0x2f, 0x77, 0x69, 0x64, 0x67, 0x65, 17 | 0x74, 0x32, 0x22, 0x2c, 0x0a, 0x20, 0x20, 0x22, 0x69, 0x63, 0x6f, 0x6e, 18 | 0x43, 0x6c, 0x61, 0x73, 0x73, 0x22, 0x20, 0x20, 0x20, 0x3a, 0x20, 0x22, 19 | 0x69, 0x6f, 0x6e, 0x2d, 0x69, 0x6f, 0x73, 0x2d, 0x66, 0x6c, 0x61, 0x6d, 20 | 0x65, 0x22, 0x2c, 0x0a, 0x20, 0x20, 0x22, 0x69, 0x63, 0x6f, 0x6e, 0x43, 21 | 0x6c, 0x61, 0x73, 0x73, 0x4f, 0x66, 0x66, 0x22, 0x3a, 0x20, 0x22, 0x69, 22 | 0x6f, 0x6e, 0x2d, 0x69, 0x6f, 0x73, 0x2d, 0x66, 0x6c, 0x61, 0x6d, 0x65, 23 | 0x2d, 0x6f, 0x75, 0x74, 0x6c, 0x69, 0x6e, 0x65, 0x22, 0x2c, 0x0a, 0x20, 24 | 0x20, 0x22, 0x69, 0x63, 0x6f, 0x6e, 0x53, 0x74, 0x79, 0x6c, 0x65, 0x22, 25 | 0x20, 0x20, 0x20, 0x3a, 0x20, 0x22, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 26 | 0x69, 0x7a, 0x65, 0x3a, 0x33, 0x30, 0x70, 0x78, 0x3b, 0x63, 0x6f, 0x6c, 27 | 0x6f, 0x72, 0x3a, 0x23, 0x66, 0x66, 0x33, 0x64, 0x33, 0x64, 0x3b, 0x22, 28 | 0x2c, 0x0a, 0x20, 0x20, 0x22, 0x69, 0x63, 0x6f, 0x6e, 0x53, 0x74, 0x79, 29 | 0x6c, 0x65, 0x4f, 0x66, 0x66, 0x22, 0x3a, 0x20, 0x22, 0x66, 0x6f, 0x6e, 30 | 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x33, 0x30, 0x70, 0x78, 0x3b, 31 | 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x23, 0x65, 0x65, 0x65, 0x3b, 0x22, 32 | 0x2c, 0x0a, 0x20, 0x20, 0x22, 0x64, 0x65, 0x73, 0x63, 0x72, 0x53, 0x74, 33 | 0x79, 0x6c, 0x65, 0x22, 0x20, 0x20, 0x3a, 0x20, 0x22, 0x66, 0x6f, 0x6e, 34 | 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x32, 0x30, 0x70, 0x78, 0x3b, 35 | 0x6c, 0x69, 0x6e, 0x65, 0x2d, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 36 | 0x31, 0x2e, 0x35, 0x65, 0x6d, 0x3b, 0x22, 0x0a, 0x7d, 0x0a, 0x00 37 | }; 38 | const int toggle_2_len = 419; 39 | -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/official-demo/IoTmanager4/IoTmanager4.ino: -------------------------------------------------------------------------------- 1 | /* 2 | IoT Manager mqtt device client https://play.google.com/store/apps/details?id=ru.esp8266.iotmanager 3 | Based on Basic MQTT example with Authentication 4 | PubSubClient library v 1.91.1 https://github.com/Imroy/pubsubclient 5 | - connects to an MQTT server, providing userdescr and password 6 | - publishes config to the topic "/IoTmanager/config/deviceID/" 7 | - subscribes to the topic "/IoTmanager/hello" ("hello" messages from mobile device) 8 | 9 | Tested with Arduino IDE 1.6.7 + ESP8266 Community Edition v 2.1.0-rc1 and PubSubClient library v 1.91.1 https://github.com/Imroy/pubsubclient 10 | ArduinoJson library 5.0.7 https://github.com/bblanchon/ArduinoJson 11 | 12 | sketch version : 1.0 13 | IoT Manager : 1.4.6 and above 14 | 15 | display-value widget demo 16 | 17 |
- class1 and style1 for 1 div (all widget) 18 |
descr
- class2 and style2 for 2 div (description) 19 |
- class3 and style3 for 3 div (svg) 20 | 21 |
22 |
23 | 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | const char *ssid = "IoT"; // cannot be longer than 32 characters! 32 | const char *pass = "12345678"; // WiFi password 33 | 34 | String prefix = "/IoTmanager"; // global prefix for all topics - must be some as mobile device 35 | String deviceID = "dev04"; // thing ID - unique device id in our project 36 | 37 | WiFiClient wclient; 38 | 39 | // config for cloud mqtt broker by DNS hostname ( for example, cloudmqtt.com use: m20.cloudmqtt.com - EU, m11.cloudmqtt.com - USA ) 40 | String mqttServerName = "m11.cloudmqtt.com"; // for cloud broker - by hostname, from CloudMQTT account data 41 | int mqttport = 10927; // default 1883, but CloudMQTT.com use other, for example: 13191, 23191 (SSL), 33191 (WebSockets) - use from CloudMQTT account data 42 | String mqttuser = "test"; // from CloudMQTT account data 43 | String mqttpass = "test"; // from CloudMQTT account data 44 | PubSubClient client(wclient, mqttServerName, mqttport); // for cloud broker - by hostname 45 | 46 | 47 | // config for local mqtt broker by IP address 48 | //IPAddress server(192, 168, 1, 100); // for local broker - by address 49 | //int mqttport = 1883; // default 1883 50 | //String mqttuser = ""; // from broker config 51 | //String mqttpass = ""; // from broker config 52 | //PubSubClient client(wclient, server, mqttport); // for local broker - by address 53 | 54 | String val; 55 | String ids = ""; 56 | int newValue, newtime, oldtime, freeheap; 57 | 58 | const int nWidgets = 1; 59 | String sTopic [nWidgets]; 60 | String stat [nWidgets]; 61 | int pin [nWidgets]; 62 | String thing_config[nWidgets]; 63 | StaticJsonBuffer<1024> jsonBuffer; 64 | JsonObject& json_status = jsonBuffer.createObject(); 65 | String string_status; 66 | 67 | void FreeHEAP() { 68 | if ( ESP.getFreeHeap() < freeheap ) { 69 | if ( ( freeheap != 100000) ) { 70 | Serial.print("Memory leak detected! old free heap = "); 71 | Serial.print(freeheap); 72 | Serial.print(", new value = "); 73 | Serial.println(ESP.getFreeHeap()); 74 | } 75 | freeheap = ESP.getFreeHeap(); 76 | } 77 | } 78 | 79 | String setStatus ( String s ) { 80 | json_status["status"] = s; 81 | string_status = ""; 82 | json_status.printTo(string_status); 83 | return string_status; 84 | } 85 | String setStatus ( int s ) { 86 | json_status["status"] = s; 87 | string_status = ""; 88 | json_status.printTo(string_status); 89 | return string_status; 90 | } 91 | void initVar() { 92 | 93 | pin [0] = A0; // ADC 94 | sTopic[0] = prefix + "/" + deviceID + "/ADC"; 95 | stat [0] = setStatus (0); 96 | 97 | JsonObject& root = jsonBuffer.createObject(); 98 | JsonObject& cfg = jsonBuffer.createObject(); 99 | 100 | root["id"] = 0; 101 | root["page"] = "ADC"; 102 | root["widget"] = "display-value"; 103 | root["class1"] = "item no-border"; // class for 1st div 104 | root["style1"] = ""; // style for 1st div 105 | root["descr"] = "DisplayValue"; // text for description 106 | root["class2"] = "balanced"; // class for description from Widgets Guide - Color classes 107 | root["style2"] = "font-size:20px;float:left;padding-top:10px;font-weight:bold;"; // style for description 108 | root["topic"] = sTopic[0]; 109 | root["class3"] = ""; // class for 3 div - SVG 110 | root["style3"] = "float:right;"; // style for 3 div - SVG 111 | root["height"] = "40"; // SVG height without "px" 112 | root["color"] = "#52FF00"; // color for active segments 113 | root["inactive_color"] = "#414141"; // color for inactive segments 114 | root["digits_count"] = 5; // how many digits 115 | 116 | root.printTo(thing_config[0]); 117 | } 118 | void pubStatus(String t, String payload) { 119 | if (client.publish(t + "/status", payload)) { 120 | Serial.println("Publish new status for " + t + ", value: " + payload); 121 | } else { 122 | Serial.println("Publish new status for " + t + " FAIL!"); 123 | } 124 | FreeHEAP(); 125 | } 126 | void pubConfig() { 127 | bool success; 128 | success = client.publish(MQTT::Publish(prefix, deviceID).set_qos(1)); 129 | if (success) { 130 | delay(500); 131 | for (int i = 0; i < nWidgets; i = i + 1) { 132 | success = client.publish(MQTT::Publish(prefix + "/" + deviceID + "/config", thing_config[i]).set_qos(1)); 133 | if (success) { 134 | Serial.println("Publish config: Success (" + thing_config[i] + ")"); 135 | } else { 136 | Serial.println("Publish config FAIL! (" + thing_config[i] + ")"); 137 | } 138 | delay(150); 139 | } 140 | } 141 | if (success) { 142 | Serial.println("Publish config: Success"); 143 | } else { 144 | Serial.println("Publish config: FAIL"); 145 | } 146 | 147 | stat[0] = setStatus( analogRead(pin[0]) ); 148 | 149 | for (int i = 0; i < nWidgets; i = i + 1) { 150 | pubStatus(sTopic[i], stat[i]); 151 | delay(100); 152 | } 153 | } 154 | void callback(const MQTT::Publish& sub) { 155 | Serial.print("Get data from subscribed topic "); 156 | Serial.print(sub.topic()); 157 | Serial.print(" => "); 158 | Serial.println(sub.payload_string()); 159 | 160 | if ( sub.payload_string() == "HELLO" ) { // handshaking 161 | pubConfig(); 162 | } 163 | } 164 | 165 | void setup() { 166 | WiFi.mode(WIFI_STA); 167 | initVar(); 168 | oldtime = 0; 169 | Serial.begin(115200); 170 | delay(10); 171 | Serial.println(); 172 | Serial.println(); 173 | Serial.println("MQTT client started."); 174 | FreeHEAP(); 175 | freeheap = 100000; 176 | WiFi.disconnect(); 177 | WiFi.printDiag(Serial); 178 | } 179 | 180 | void loop() { 181 | if (WiFi.status() != WL_CONNECTED) { 182 | Serial.print("Connecting via WiFi to "); 183 | Serial.print(ssid); 184 | Serial.println("..."); 185 | 186 | WiFi.begin(ssid, pass); 187 | 188 | if (WiFi.waitForConnectResult() != WL_CONNECTED) { 189 | return; 190 | } 191 | 192 | Serial.println(""); 193 | Serial.println("WiFi connect: Success"); 194 | Serial.print("IP address: "); 195 | Serial.println(WiFi.localIP()); 196 | } 197 | 198 | if (WiFi.status() == WL_CONNECTED) { 199 | if (!client.connected()) { 200 | Serial.println("Connecting to MQTT server ..."); 201 | bool success; 202 | if (mqttuser.length() > 0) { 203 | success = client.connect( MQTT::Connect( deviceID ).set_auth(mqttuser, mqttpass) ); 204 | } else { 205 | success = client.connect( deviceID ); 206 | } 207 | if (success) { 208 | client.set_callback(callback); 209 | Serial.println("Connect to MQTT server: Success"); 210 | client.subscribe(prefix); // for receiving HELLO messages and handshaking 211 | pubConfig(); 212 | } else { 213 | Serial.println("Connect to MQTT server: FAIL"); 214 | delay(1000); 215 | } 216 | } 217 | 218 | if (client.connected()) { 219 | newtime = millis(); 220 | if (newtime - oldtime > 10000) { // read ADC and publish data every 10 sec 221 | stat[0] = setStatus( analogRead( pin[0] ) ); 222 | pubStatus(sTopic[0], stat[0] ); 223 | oldtime = newtime; 224 | } 225 | client.loop(); 226 | } 227 | } 228 | } 229 | -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/official-demo/PushNotifications/PushNotifications.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Push notification for IoT Manager 3 | 4 | v 1.0 5 | 6 | Test on Arduino IDE 1.8.1 7 | 8 | Based on "HTTP over TLS (HTTPS) example" sketch 9 | 10 | This example demonstrates how to use 11 | WiFiClientSecure class to access HTTPS API. 12 | We fetch and display the status of 13 | esp8266/Arduino project continuous integration 14 | build. 15 | 16 | Created by Ivan Grokhotkov, 2015. 17 | This example is in public domain. 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | /* user parameters */ 24 | 25 | const char* ssid = "IoT"; 26 | const char* password = "12345678"; 27 | 28 | // IDS - unique device id from IoT Manager application: Start IoT Manager, goto "Statistic" and press "Send ids to email" 29 | // Also, you can get ids via MQTT after HELLO message. 30 | // ids will be always changed after IoT Manager reinstall on mobile device 31 | 32 | String ids = "91433959-a3f5-4cc1-aa28-22a6467b52f3"; // its not real IDS, please change 33 | 34 | /* end of user parameters */ 35 | 36 | 37 | 38 | const char* host = "onesignal.com"; 39 | const int httpsPort = 443; 40 | String url = "/api/v1/notifications"; 41 | 42 | void push(String msg) { 43 | // Use WiFiClientSecure class to create TLS connection 44 | WiFiClientSecure client; 45 | 46 | Serial.print("PUSH: connecting to "); 47 | Serial.println(host); 48 | 49 | if (!client.connect(host, httpsPort)) { 50 | Serial.println("connection failed"); 51 | return; 52 | } 53 | Serial.println("PUSH: try to send push notification..."); 54 | 55 | // please, do not change app_id - its IoT Manager id at onesignal.com 56 | // more info at https://documentation.onesignal.com/v3.0/reference#create-notification 57 | 58 | String data = "{\"app_id\": \"8871958c-5f52-11e5-8f7a-c36f5770ade9\",\"include_player_ids\":[\"" + ids + "\"],\"android_group\":\"IoT Manager\",\"contents\": {\"en\": \"" + msg + "\"}}"; 59 | 60 | Serial.print("PUSH: requesting URL: "); 61 | Serial.println(url); 62 | 63 | client.println(String("POST ") + url + " HTTP/1.1"); 64 | client.print("Host:"); 65 | client.println(host); 66 | client.println("User-Agent: esp8266.Arduino.IoTmanager"); 67 | client.print("Content-Length: "); 68 | client.println(data.length()); 69 | client.println("Content-Type: application/json"); 70 | client.println("Connection: close"); 71 | client.println(); 72 | client.println(data); 73 | 74 | Serial.println("PUSH: done. Restart esp8266 for push again."); 75 | } 76 | 77 | void setup() { 78 | Serial.begin(115200); 79 | Serial.println(); 80 | Serial.println("Push notification for IoT Manager"); 81 | Serial.println(); 82 | Serial.print("PUSH: connecting to "); 83 | Serial.println(ssid); 84 | WiFi.begin(ssid, password); 85 | while (WiFi.status() != WL_CONNECTED) { 86 | delay(500); 87 | Serial.print("."); 88 | } 89 | Serial.println(""); 90 | Serial.println("PUSH: WiFi connected"); 91 | 92 | push("test message"); 93 | } 94 | 95 | void loop() { 96 | } 97 | -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/official-demo/README.md: -------------------------------------------------------------------------------- 1 | ## Demo sketches from IoT developes 2 | 3 | ### PushNotifications 4 | 5 | simple demo for sending to mobile push notififications from your IoT devices 6 | 7 | ### IoTmanager 8 | 9 | toggle, range, small-badge widgets demo 10 | 11 | ### IoTmanager2 12 | 13 | toggle, range, small-badge and power-button widgets demo 14 | 15 | ### IoTmanager3 16 | 17 | fillgauge widget demo 18 | 19 | ### IoTmanager4 20 | 21 | display-value widget demo 22 | 23 | ### IoTmanager5 24 | 25 | simple-btn widget demo 26 | 27 | ### anydata 28 | 29 | anydata widget demo with DS18B20 30 | 31 | ### AnydataToggle 32 | 33 | anydata+toggle widgets demo with JSON > .h converter 34 | -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/users-demo/README.md: -------------------------------------------------------------------------------- 1 | ### Users demo sketches 2 | -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/users-demo/bmp180/Adafruit-BMP085/Adafruit_BMP085.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | This is a library for the Adafruit BMP085/BMP180 Barometric Pressure + Temp sensor 3 | 4 | Designed specifically to work with the Adafruit BMP085 or BMP180 Breakout 5 | ----> http://www.adafruit.com/products/391 6 | ----> http://www.adafruit.com/products/1603 7 | 8 | These displays use I2C to communicate, 2 pins are required to 9 | interface 10 | Adafruit invests time and resources providing this open source code, 11 | please support Adafruit and open-source hardware by purchasing 12 | products from Adafruit! 13 | 14 | Written by Limor Fried/Ladyada for Adafruit Industries. 15 | BSD license, all text above must be included in any redistribution 16 | ****************************************************/ 17 | 18 | #include "Adafruit_BMP085.h" 19 | 20 | Adafruit_BMP085::Adafruit_BMP085() { 21 | } 22 | 23 | 24 | boolean Adafruit_BMP085::begin(uint8_t mode) { 25 | if (mode > BMP085_ULTRAHIGHRES) 26 | mode = BMP085_ULTRAHIGHRES; 27 | oversampling = mode; 28 | 29 | Wire.begin(); 30 | 31 | if (read8(0xD0) != 0x55) return false; 32 | 33 | /* read calibration data */ 34 | ac1 = read16(BMP085_CAL_AC1); 35 | ac2 = read16(BMP085_CAL_AC2); 36 | ac3 = read16(BMP085_CAL_AC3); 37 | ac4 = read16(BMP085_CAL_AC4); 38 | ac5 = read16(BMP085_CAL_AC5); 39 | ac6 = read16(BMP085_CAL_AC6); 40 | 41 | b1 = read16(BMP085_CAL_B1); 42 | b2 = read16(BMP085_CAL_B2); 43 | 44 | mb = read16(BMP085_CAL_MB); 45 | mc = read16(BMP085_CAL_MC); 46 | md = read16(BMP085_CAL_MD); 47 | #if (BMP085_DEBUG == 1) 48 | Serial.print("ac1 = "); Serial.println(ac1, DEC); 49 | Serial.print("ac2 = "); Serial.println(ac2, DEC); 50 | Serial.print("ac3 = "); Serial.println(ac3, DEC); 51 | Serial.print("ac4 = "); Serial.println(ac4, DEC); 52 | Serial.print("ac5 = "); Serial.println(ac5, DEC); 53 | Serial.print("ac6 = "); Serial.println(ac6, DEC); 54 | 55 | Serial.print("b1 = "); Serial.println(b1, DEC); 56 | Serial.print("b2 = "); Serial.println(b2, DEC); 57 | 58 | Serial.print("mb = "); Serial.println(mb, DEC); 59 | Serial.print("mc = "); Serial.println(mc, DEC); 60 | Serial.print("md = "); Serial.println(md, DEC); 61 | #endif 62 | 63 | return true; 64 | } 65 | 66 | int32_t Adafruit_BMP085::computeB5(int32_t UT) { 67 | int32_t X1 = (UT - (int32_t)ac6) * ((int32_t)ac5) >> 15; 68 | int32_t X2 = ((int32_t)mc << 11) / (X1+(int32_t)md); 69 | return X1 + X2; 70 | } 71 | 72 | uint16_t Adafruit_BMP085::readRawTemperature(void) { 73 | write8(BMP085_CONTROL, BMP085_READTEMPCMD); 74 | delay(5); 75 | #if BMP085_DEBUG == 1 76 | Serial.print("Raw temp: "); Serial.println(read16(BMP085_TEMPDATA)); 77 | #endif 78 | return read16(BMP085_TEMPDATA); 79 | } 80 | 81 | uint32_t Adafruit_BMP085::readRawPressure(void) { 82 | uint32_t raw; 83 | 84 | write8(BMP085_CONTROL, BMP085_READPRESSURECMD + (oversampling << 6)); 85 | 86 | if (oversampling == BMP085_ULTRALOWPOWER) 87 | delay(5); 88 | else if (oversampling == BMP085_STANDARD) 89 | delay(8); 90 | else if (oversampling == BMP085_HIGHRES) 91 | delay(14); 92 | else 93 | delay(26); 94 | 95 | raw = read16(BMP085_PRESSUREDATA); 96 | 97 | raw <<= 8; 98 | raw |= read8(BMP085_PRESSUREDATA+2); 99 | raw >>= (8 - oversampling); 100 | 101 | /* this pull broke stuff, look at it later? 102 | if (oversampling==0) { 103 | raw <<= 8; 104 | raw |= read8(BMP085_PRESSUREDATA+2); 105 | raw >>= (8 - oversampling); 106 | } 107 | */ 108 | 109 | #if BMP085_DEBUG == 1 110 | Serial.print("Raw pressure: "); Serial.println(raw); 111 | #endif 112 | return raw; 113 | } 114 | 115 | 116 | int32_t Adafruit_BMP085::readPressure(void) { 117 | int32_t UT, UP, B3, B5, B6, X1, X2, X3, p; 118 | uint32_t B4, B7; 119 | 120 | UT = readRawTemperature(); 121 | UP = readRawPressure(); 122 | 123 | #if BMP085_DEBUG == 1 124 | // use datasheet numbers! 125 | UT = 27898; 126 | UP = 23843; 127 | ac6 = 23153; 128 | ac5 = 32757; 129 | mc = -8711; 130 | md = 2868; 131 | b1 = 6190; 132 | b2 = 4; 133 | ac3 = -14383; 134 | ac2 = -72; 135 | ac1 = 408; 136 | ac4 = 32741; 137 | oversampling = 0; 138 | #endif 139 | 140 | B5 = computeB5(UT); 141 | 142 | #if BMP085_DEBUG == 1 143 | Serial.print("X1 = "); Serial.println(X1); 144 | Serial.print("X2 = "); Serial.println(X2); 145 | Serial.print("B5 = "); Serial.println(B5); 146 | #endif 147 | 148 | // do pressure calcs 149 | B6 = B5 - 4000; 150 | X1 = ((int32_t)b2 * ( (B6 * B6)>>12 )) >> 11; 151 | X2 = ((int32_t)ac2 * B6) >> 11; 152 | X3 = X1 + X2; 153 | B3 = ((((int32_t)ac1*4 + X3) << oversampling) + 2) / 4; 154 | 155 | #if BMP085_DEBUG == 1 156 | Serial.print("B6 = "); Serial.println(B6); 157 | Serial.print("X1 = "); Serial.println(X1); 158 | Serial.print("X2 = "); Serial.println(X2); 159 | Serial.print("B3 = "); Serial.println(B3); 160 | #endif 161 | 162 | X1 = ((int32_t)ac3 * B6) >> 13; 163 | X2 = ((int32_t)b1 * ((B6 * B6) >> 12)) >> 16; 164 | X3 = ((X1 + X2) + 2) >> 2; 165 | B4 = ((uint32_t)ac4 * (uint32_t)(X3 + 32768)) >> 15; 166 | B7 = ((uint32_t)UP - B3) * (uint32_t)( 50000UL >> oversampling ); 167 | 168 | #if BMP085_DEBUG == 1 169 | Serial.print("X1 = "); Serial.println(X1); 170 | Serial.print("X2 = "); Serial.println(X2); 171 | Serial.print("B4 = "); Serial.println(B4); 172 | Serial.print("B7 = "); Serial.println(B7); 173 | #endif 174 | 175 | if (B7 < 0x80000000) { 176 | p = (B7 * 2) / B4; 177 | } else { 178 | p = (B7 / B4) * 2; 179 | } 180 | X1 = (p >> 8) * (p >> 8); 181 | X1 = (X1 * 3038) >> 16; 182 | X2 = (-7357 * p) >> 16; 183 | 184 | #if BMP085_DEBUG == 1 185 | Serial.print("p = "); Serial.println(p); 186 | Serial.print("X1 = "); Serial.println(X1); 187 | Serial.print("X2 = "); Serial.println(X2); 188 | #endif 189 | 190 | p = p + ((X1 + X2 + (int32_t)3791)>>4); 191 | #if BMP085_DEBUG == 1 192 | Serial.print("p = "); Serial.println(p); 193 | #endif 194 | return p; 195 | } 196 | 197 | int32_t Adafruit_BMP085::readSealevelPressure(float altitude_meters) { 198 | float pressure = readPressure(); 199 | return (int32_t)(pressure / pow(1.0-altitude_meters/44330, 5.255)); 200 | } 201 | 202 | float Adafruit_BMP085::readTemperature(void) { 203 | int32_t UT, B5; // following ds convention 204 | float temp; 205 | 206 | UT = readRawTemperature(); 207 | 208 | #if BMP085_DEBUG == 1 209 | // use datasheet numbers! 210 | UT = 27898; 211 | ac6 = 23153; 212 | ac5 = 32757; 213 | mc = -8711; 214 | md = 2868; 215 | #endif 216 | 217 | B5 = computeB5(UT); 218 | temp = (B5+8) >> 4; 219 | temp /= 10; 220 | 221 | return temp; 222 | } 223 | 224 | float Adafruit_BMP085::readAltitude(float sealevelPressure) { 225 | float altitude; 226 | 227 | float pressure = readPressure(); 228 | 229 | altitude = 44330 * (1.0 - pow(pressure /sealevelPressure,0.1903)); 230 | 231 | return altitude; 232 | } 233 | 234 | 235 | /*********************************************************************/ 236 | 237 | uint8_t Adafruit_BMP085::read8(uint8_t a) { 238 | uint8_t ret; 239 | 240 | Wire.beginTransmission(BMP085_I2CADDR); // start transmission to device 241 | #if (ARDUINO >= 100) 242 | Wire.write(a); // sends register address to read from 243 | #else 244 | Wire.send(a); // sends register address to read from 245 | #endif 246 | Wire.endTransmission(); // end transmission 247 | 248 | Wire.beginTransmission(BMP085_I2CADDR); // start transmission to device 249 | Wire.requestFrom(BMP085_I2CADDR, 1);// send data n-bytes read 250 | #if (ARDUINO >= 100) 251 | ret = Wire.read(); // receive DATA 252 | #else 253 | ret = Wire.receive(); // receive DATA 254 | #endif 255 | Wire.endTransmission(); // end transmission 256 | 257 | return ret; 258 | } 259 | 260 | uint16_t Adafruit_BMP085::read16(uint8_t a) { 261 | uint16_t ret; 262 | 263 | Wire.beginTransmission(BMP085_I2CADDR); // start transmission to device 264 | #if (ARDUINO >= 100) 265 | Wire.write(a); // sends register address to read from 266 | #else 267 | Wire.send(a); // sends register address to read from 268 | #endif 269 | Wire.endTransmission(); // end transmission 270 | 271 | Wire.beginTransmission(BMP085_I2CADDR); // start transmission to device 272 | Wire.requestFrom(BMP085_I2CADDR, 2);// send data n-bytes read 273 | #if (ARDUINO >= 100) 274 | ret = Wire.read(); // receive DATA 275 | ret <<= 8; 276 | ret |= Wire.read(); // receive DATA 277 | #else 278 | ret = Wire.receive(); // receive DATA 279 | ret <<= 8; 280 | ret |= Wire.receive(); // receive DATA 281 | #endif 282 | Wire.endTransmission(); // end transmission 283 | 284 | return ret; 285 | } 286 | 287 | void Adafruit_BMP085::write8(uint8_t a, uint8_t d) { 288 | Wire.beginTransmission(BMP085_I2CADDR); // start transmission to device 289 | #if (ARDUINO >= 100) 290 | Wire.write(a); // sends register address to read from 291 | Wire.write(d); // write data 292 | #else 293 | Wire.send(a); // sends register address to read from 294 | Wire.send(d); // write data 295 | #endif 296 | Wire.endTransmission(); // end transmission 297 | } 298 | -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/users-demo/bmp180/Adafruit-BMP085/Adafruit_BMP085.h: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | This is a library for the Adafruit BMP085/BMP180 Barometric Pressure + Temp sensor 3 | 4 | Designed specifically to work with the Adafruit BMP085 or BMP180 Breakout 5 | ----> http://www.adafruit.com/products/391 6 | ----> http://www.adafruit.com/products/1603 7 | 8 | These displays use I2C to communicate, 2 pins are required to 9 | interface 10 | Adafruit invests time and resources providing this open source code, 11 | please support Adafruit and open-source hardware by purchasing 12 | products from Adafruit! 13 | 14 | Written by Limor Fried/Ladyada for Adafruit Industries. 15 | BSD license, all text above must be included in any redistribution 16 | ****************************************************/ 17 | 18 | #ifndef ADAFRUIT_BMP085_H 19 | #define ADAFRUIT_BMP085_H 20 | 21 | #if (ARDUINO >= 100) 22 | #include "Arduino.h" 23 | #else 24 | #include "WProgram.h" 25 | #endif 26 | #include "Wire.h" 27 | 28 | #define BMP085_DEBUG 0 29 | 30 | #define BMP085_I2CADDR 0x77 31 | 32 | #define BMP085_ULTRALOWPOWER 0 33 | #define BMP085_STANDARD 1 34 | #define BMP085_HIGHRES 2 35 | #define BMP085_ULTRAHIGHRES 3 36 | #define BMP085_CAL_AC1 0xAA // R Calibration data (16 bits) 37 | #define BMP085_CAL_AC2 0xAC // R Calibration data (16 bits) 38 | #define BMP085_CAL_AC3 0xAE // R Calibration data (16 bits) 39 | #define BMP085_CAL_AC4 0xB0 // R Calibration data (16 bits) 40 | #define BMP085_CAL_AC5 0xB2 // R Calibration data (16 bits) 41 | #define BMP085_CAL_AC6 0xB4 // R Calibration data (16 bits) 42 | #define BMP085_CAL_B1 0xB6 // R Calibration data (16 bits) 43 | #define BMP085_CAL_B2 0xB8 // R Calibration data (16 bits) 44 | #define BMP085_CAL_MB 0xBA // R Calibration data (16 bits) 45 | #define BMP085_CAL_MC 0xBC // R Calibration data (16 bits) 46 | #define BMP085_CAL_MD 0xBE // R Calibration data (16 bits) 47 | 48 | #define BMP085_CONTROL 0xF4 49 | #define BMP085_TEMPDATA 0xF6 50 | #define BMP085_PRESSUREDATA 0xF6 51 | #define BMP085_READTEMPCMD 0x2E 52 | #define BMP085_READPRESSURECMD 0x34 53 | 54 | 55 | class Adafruit_BMP085 { 56 | public: 57 | Adafruit_BMP085(); 58 | boolean begin(uint8_t mode = BMP085_ULTRAHIGHRES); // by default go highres 59 | float readTemperature(void); 60 | int32_t readPressure(void); 61 | int32_t readSealevelPressure(float altitude_meters = 0); 62 | float readAltitude(float sealevelPressure = 101325); // std atmosphere 63 | uint16_t readRawTemperature(void); 64 | uint32_t readRawPressure(void); 65 | 66 | private: 67 | int32_t computeB5(int32_t UT); 68 | uint8_t read8(uint8_t addr); 69 | uint16_t read16(uint8_t addr); 70 | void write8(uint8_t addr, uint8_t data); 71 | 72 | uint8_t oversampling; 73 | 74 | int16_t ac1, ac2, ac3, b1, b2, mb, mc, md; 75 | uint16_t ac4, ac5, ac6; 76 | }; 77 | 78 | 79 | #endif // ADAFRUIT_BMP085_H 80 | -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/users-demo/bmp180/Adafruit-BMP085/BMP085.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4refr0nt/iot-manager-demo/5ceed46ccf538e5bac9b92a03452eed21d27f74f/ArduinoIDE/ESP8266/users-demo/bmp180/Adafruit-BMP085/BMP085.cpp -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/users-demo/bmp180/Adafruit-BMP085/BMP085.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4refr0nt/iot-manager-demo/5ceed46ccf538e5bac9b92a03452eed21d27f74f/ArduinoIDE/ESP8266/users-demo/bmp180/Adafruit-BMP085/BMP085.h -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/users-demo/bmp180/Adafruit-BMP085/COPYING.LESSER: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/users-demo/bmp180/Adafruit-BMP085/INSTALL.txt: -------------------------------------------------------------------------------- 1 | Copy the whole directory which contain this file into the folder "libraries" inside the Arduino sketchbook folder. 2 | 3 | You can understand the location of your sketchbook folder from the Arduino IDE clicking on File -> Preferences: the "sketchbook location" is what you are looking for. 4 | 5 | In case you don't have an "libraries" folder there just create an empty one. 6 | 7 | 8 | For more informations see: 9 | http://www.arduino.cc/en/Reference/Libraries -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/users-demo/bmp180/Adafruit-BMP085/README.txt: -------------------------------------------------------------------------------- 1 | This is a library for the Adafruit BMP085/BMP180 Barometric Pressure + Temp sensor 2 | 3 | Designed specifically to work with the Adafruit BMP085 or BMP180 Breakout 4 | ----> http://www.adafruit.com/products/391 5 | ----> http://www.adafruit.com/products/1603 6 | 7 | These displays use I2C to communicate, 2 pins are required to interface 8 | Adafruit invests time and resources providing this open source code, 9 | please support Adafruit and open-source hardware by purchasing 10 | products from Adafruit! 11 | 12 | Check out the links above for our tutorials and wiring diagrams 13 | 14 | Adafruit invests time and resources providing this open source code, 15 | please support Adafruit and open-source hardware by purchasing 16 | products from Adafruit! 17 | 18 | Written by Limor Fried/Ladyada for Adafruit Industries. 19 | BSD license, all text above must be included in any redistribution 20 | 21 | To download. click the DOWNLOAD ZIP button, rename the uncompressed folder Adafruit_BMP085. 22 | Check that the Adafruit_BMP085 folder contains Adafruit_BMP085.cpp and Adafruit_BMP085.h 23 | 24 | Place the Adafruit_BMP085 library folder your arduinosketchfolder/libraries/ folder. 25 | You may need to create the libraries subfolder if its your first library. Restart the IDE. 26 | 27 | We also have a great tutorial on Arduino library installation at: 28 | http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/users-demo/bmp180/Adafruit-BMP085/examples/.svn/all-wcprops: -------------------------------------------------------------------------------- 1 | K 25 2 | svn:wc:ra_dav:version-url 3 | V 31 4 | /svn/!svn/ver/26/trunk/examples 5 | END 6 | -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/users-demo/bmp180/Adafruit-BMP085/examples/.svn/entries: -------------------------------------------------------------------------------- 1 | 10 2 | 3 | dir 4 | 27 5 | https://bmp085driver.googlecode.com/svn/trunk/examples 6 | https://bmp085driver.googlecode.com/svn 7 | 8 | 9 | 10 | 2011-03-26T00:15:08.173336Z 11 | 26 12 | fil.vieira@gmail.com 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 43391e3e-6b59-17a6-64d1-a79cdfe6ffa7 28 | 29 | BMP085_test1 30 | dir 31 | 32 | BMP085_output 33 | dir 34 | 35 | BMP085_test2 36 | dir 37 | 38 | -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/users-demo/bmp180/Adafruit-BMP085/examples/BMP085_output/.svn/all-wcprops: -------------------------------------------------------------------------------- 1 | K 25 2 | svn:wc:ra_dav:version-url 3 | V 45 4 | /svn/!svn/ver/17/trunk/examples/BMP085_output 5 | END 6 | BMP085_output.ino 7 | K 25 8 | svn:wc:ra_dav:version-url 9 | V 63 10 | /svn/!svn/ver/29/trunk/examples/BMP085_output/BMP085_output.ino 11 | END 12 | -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/users-demo/bmp180/Adafruit-BMP085/examples/BMP085_output/.svn/entries: -------------------------------------------------------------------------------- 1 | 10 2 | 3 | dir 4 | 27 5 | https://bmp085driver.googlecode.com/svn/trunk/examples/BMP085_output 6 | https://bmp085driver.googlecode.com/svn 7 | 8 | 9 | 10 | 2011-02-24T20:58:33.861619Z 11 | 17 12 | fil.vieira@gmail.com 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 43391e3e-6b59-17a6-64d1-a79cdfe6ffa7 28 | 29 | BMP085_output.ino 30 | file 31 | 29 32 | 33 | 34 | 35 | 2012-01-07T00:56:32.099970Z 36 | 6604abbe572397458b5306851e1aa502 37 | 2012-01-07T01:19:23.863090Z 38 | 29 39 | fil.vieira@gmail.com 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 2755 62 | 63 | BMP085_output.pde 64 | file 65 | 29 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | deleted 86 | 87 | -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/users-demo/bmp180/Adafruit-BMP085/examples/BMP085_output/.svn/text-base/BMP085_output.ino.svn-base: -------------------------------------------------------------------------------- 1 | // BMP085_output 2 | // by Filipe Vieira 3 | // Simple example of library usage with almost every BMP085 and lib features being used. 4 | 5 | #include 6 | #include 7 | 8 | BMP085 dps = BMP085(); 9 | long Temperature = 0, Pressure = 0, Altitude = 0; 10 | 11 | void setup(void) { 12 | Serial.begin(9600); 13 | Wire.begin(); 14 | delay(1000); 15 | 16 | dps.init(); 17 | 18 | showall(); 19 | 20 | Serial.println("Registers dump"); 21 | Serial.println("=========================================================="); 22 | dumpRegisters(); 23 | Serial.println("Calibration data"); 24 | Serial.println("=========================================================="); 25 | dps.dumpCalData(); 26 | 27 | delay(5000); 28 | } 29 | 30 | 31 | void loop(void) { 32 | dps.getTemperature(&Temperature); 33 | dps.getPressure(&Pressure); 34 | dps.getAltitude(&Altitude); 35 | 36 | Serial.print("Temp(C):"); 37 | Serial.print(Temperature); 38 | Serial.print(" Alt(cm):"); 39 | Serial.print(Altitude); 40 | Serial.print(" Pressure(Pa):"); 41 | Serial.println(Pressure); 42 | } 43 | 44 | void showall(void) { 45 | Serial.println("Current BMP085 settings"); 46 | Serial.println("=========================================================="); 47 | Serial.print("device address = 0x"); 48 | Serial.println(dps.getDevAddr(), HEX); 49 | Serial.print("Mode = "); 50 | switch (dps.getMode()) { 51 | case MODE_ULTRA_LOW_POWER: 52 | Serial.println("MODE_ULTRA_LOW_POWER"); 53 | break; 54 | case MODE_STANDARD: 55 | Serial.println("MODE_STANDARD"); 56 | break; 57 | case MODE_HIGHRES: 58 | Serial.println("MODE_HIGHRES"); 59 | break; 60 | case MODE_ULTRA_HIGHRES: 61 | Serial.println("MODE_ULTRA_HIGHRES"); 62 | break; 63 | } 64 | } 65 | 66 | void dumpRegisters() { 67 | byte ValidRegisterAddr[]={0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,0xF6,0xF7,0xF8,0xF9}; 68 | byte _b, i, totregisters = sizeof(ValidRegisterAddr); 69 | Serial.println("---dump start---"); 70 | Serial.println("Register address|Register data"); 71 | Serial.println("Reg.address(hex,dec) Reg.data(bin,hex,dec)"); 72 | for (i=0;i=0; i--) 92 | Serial.print(val >> i & 1, BIN); 93 | } 94 | /* void print_unit16(uint16_t val){ 95 | int i; 96 | for(i=15; i>=0; i--) 97 | Serial.print(val >> i & 1, BIN); 98 | } 99 | */ -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/users-demo/bmp180/Adafruit-BMP085/examples/BMP085_output/BMP085_output.ino: -------------------------------------------------------------------------------- 1 | // BMP085_output 2 | // by Filipe Vieira 3 | // Simple example of library usage with almost every BMP085 and lib features being used. 4 | 5 | #include 6 | #include 7 | 8 | BMP085 dps = BMP085(); 9 | long Temperature = 0, Pressure = 0, Altitude = 0; 10 | 11 | void setup(void) { 12 | Serial.begin(9600); 13 | Wire.begin(); 14 | delay(1000); 15 | 16 | dps.init(); 17 | 18 | showall(); 19 | 20 | Serial.println("Registers dump"); 21 | Serial.println("=========================================================="); 22 | dumpRegisters(); 23 | Serial.println("Calibration data"); 24 | Serial.println("=========================================================="); 25 | dps.dumpCalData(); 26 | 27 | delay(5000); 28 | } 29 | 30 | 31 | void loop(void) { 32 | dps.getTemperature(&Temperature); 33 | dps.getPressure(&Pressure); 34 | dps.getAltitude(&Altitude); 35 | 36 | Serial.print("Temp(C):"); 37 | Serial.print(Temperature); 38 | Serial.print(" Alt(cm):"); 39 | Serial.print(Altitude); 40 | Serial.print(" Pressure(Pa):"); 41 | Serial.println(Pressure); 42 | } 43 | 44 | void showall(void) { 45 | Serial.println("Current BMP085 settings"); 46 | Serial.println("=========================================================="); 47 | Serial.print("device address = 0x"); 48 | Serial.println(dps.getDevAddr(), HEX); 49 | Serial.print("Mode = "); 50 | switch (dps.getMode()) { 51 | case MODE_ULTRA_LOW_POWER: 52 | Serial.println("MODE_ULTRA_LOW_POWER"); 53 | break; 54 | case MODE_STANDARD: 55 | Serial.println("MODE_STANDARD"); 56 | break; 57 | case MODE_HIGHRES: 58 | Serial.println("MODE_HIGHRES"); 59 | break; 60 | case MODE_ULTRA_HIGHRES: 61 | Serial.println("MODE_ULTRA_HIGHRES"); 62 | break; 63 | } 64 | } 65 | 66 | void dumpRegisters() { 67 | byte ValidRegisterAddr[]={0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,0xF6,0xF7,0xF8,0xF9}; 68 | byte _b, i, totregisters = sizeof(ValidRegisterAddr); 69 | Serial.println("---dump start---"); 70 | Serial.println("Register address|Register data"); 71 | Serial.println("Reg.address(hex,dec) Reg.data(bin,hex,dec)"); 72 | for (i=0;i=0; i--) 92 | Serial.print(val >> i & 1, BIN); 93 | } 94 | /* void print_unit16(uint16_t val){ 95 | int i; 96 | for(i=15; i>=0; i--) 97 | Serial.print(val >> i & 1, BIN); 98 | } 99 | */ -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/users-demo/bmp180/Adafruit-BMP085/examples/BMP085_test1/.svn/all-wcprops: -------------------------------------------------------------------------------- 1 | K 25 2 | svn:wc:ra_dav:version-url 3 | V 44 4 | /svn/!svn/ver/26/trunk/examples/BMP085_test1 5 | END 6 | BMP085_test1.ino 7 | K 25 8 | svn:wc:ra_dav:version-url 9 | V 61 10 | /svn/!svn/ver/29/trunk/examples/BMP085_test1/BMP085_test1.ino 11 | END 12 | -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/users-demo/bmp180/Adafruit-BMP085/examples/BMP085_test1/.svn/entries: -------------------------------------------------------------------------------- 1 | 10 2 | 3 | dir 4 | 27 5 | https://bmp085driver.googlecode.com/svn/trunk/examples/BMP085_test1 6 | https://bmp085driver.googlecode.com/svn 7 | 8 | 9 | 10 | 2011-03-26T00:15:08.173336Z 11 | 26 12 | fil.vieira@gmail.com 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 43391e3e-6b59-17a6-64d1-a79cdfe6ffa7 28 | 29 | BMP085_test1.ino 30 | file 31 | 29 32 | 33 | 34 | 35 | 2012-01-07T00:56:54.789104Z 36 | eb9f860e79f58d9bc027f91723b5a21d 37 | 2012-01-07T01:19:23.863090Z 38 | 29 39 | fil.vieira@gmail.com 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 1683 62 | 63 | BMP085_test1.pde 64 | file 65 | 29 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | deleted 86 | 87 | -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/users-demo/bmp180/Adafruit-BMP085/examples/BMP085_test1/.svn/text-base/BMP085_test1.ino.svn-base: -------------------------------------------------------------------------------- 1 | // BMP085_test1 2 | // by Filipe Vieira 3 | // Simple test of BMP085 output using default settings. 4 | // This example requires AUTO_UPDATE_TEMPERATURE to be true in bmp085.h otherwise temperature will not update. 5 | // IMPORTANT!! To get correct values you MUST CHANGE init() parameters, in 6 | // this example I've set 250m based on GPS data for my location. 7 | 8 | #include 9 | #include 10 | 11 | BMP085 dps = BMP085(); // Digital Pressure Sensor 12 | 13 | long Temperature = 0, Pressure = 0, Altitude = 0; 14 | 15 | void setup(void) { 16 | Serial.begin(9600); 17 | Wire.begin(); 18 | delay(1000); 19 | 20 | // uncomment for different initialization settings 21 | //dps.init(); // QFE (Field Elevation above ground level) is set to 0 meters. 22 | // same as init(MODE_STANDARD, 0, true); 23 | 24 | //dps.init(MODE_STANDARD, 101850, false); // 101850Pa = 1018.50hPa, false = using Pa units 25 | // this initialization is useful for normalizing pressure to specific datum. 26 | // OR setting current local hPa information from a weather station/local airport (QNH). 27 | 28 | dps.init(MODE_ULTRA_HIGHRES, 25000, true); // 250 meters, true = using meter units 29 | // this initialization is useful if current altitude is known, 30 | // pressure will be calculated based on TruePressure and known altitude. 31 | 32 | // note: use zeroCal only after initialization. 33 | // dps.zeroCal(101800, 0); // set zero point 34 | } 35 | 36 | void loop(void) { 37 | dps.getPressure(&Pressure); 38 | dps.getAltitude(&Altitude); 39 | 40 | Serial.print(" Alt(cm):"); 41 | Serial.print(Altitude); 42 | Serial.print(" Pressure(Pa):"); 43 | Serial.println(Pressure); 44 | } -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/users-demo/bmp180/Adafruit-BMP085/examples/BMP085_test1/BMP085_test1.ino: -------------------------------------------------------------------------------- 1 | // BMP085_test1 2 | // by Filipe Vieira 3 | // Simple test of BMP085 output using default settings. 4 | // This example requires AUTO_UPDATE_TEMPERATURE to be true in bmp085.h otherwise temperature will not update. 5 | // IMPORTANT!! To get correct values you MUST CHANGE init() parameters, in 6 | // this example I've set 250m based on GPS data for my location. 7 | 8 | #include 9 | #include 10 | 11 | BMP085 dps = BMP085(); // Digital Pressure Sensor 12 | 13 | long Temperature = 0, Pressure = 0, Altitude = 0; 14 | 15 | void setup(void) { 16 | Serial.begin(9600); 17 | Wire.begin(); 18 | delay(1000); 19 | 20 | // uncomment for different initialization settings 21 | //dps.init(); // QFE (Field Elevation above ground level) is set to 0 meters. 22 | // same as init(MODE_STANDARD, 0, true); 23 | 24 | //dps.init(MODE_STANDARD, 101850, false); // 101850Pa = 1018.50hPa, false = using Pa units 25 | // this initialization is useful for normalizing pressure to specific datum. 26 | // OR setting current local hPa information from a weather station/local airport (QNH). 27 | 28 | dps.init(MODE_ULTRA_HIGHRES, 25000, true); // 250 meters, true = using meter units 29 | // this initialization is useful if current altitude is known, 30 | // pressure will be calculated based on TruePressure and known altitude. 31 | 32 | // note: use zeroCal only after initialization. 33 | // dps.zeroCal(101800, 0); // set zero point 34 | } 35 | 36 | void loop(void) { 37 | dps.getPressure(&Pressure); 38 | dps.getAltitude(&Altitude); 39 | 40 | Serial.print(" Alt(cm):"); 41 | Serial.print(Altitude); 42 | Serial.print(" Pressure(Pa):"); 43 | Serial.println(Pressure); 44 | } -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/users-demo/bmp180/Adafruit-BMP085/examples/BMP085_test2/.svn/all-wcprops: -------------------------------------------------------------------------------- 1 | K 25 2 | svn:wc:ra_dav:version-url 3 | V 44 4 | /svn/!svn/ver/26/trunk/examples/BMP085_test2 5 | END 6 | BMP085_test2.ino 7 | K 25 8 | svn:wc:ra_dav:version-url 9 | V 61 10 | /svn/!svn/ver/29/trunk/examples/BMP085_test2/BMP085_test2.ino 11 | END 12 | -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/users-demo/bmp180/Adafruit-BMP085/examples/BMP085_test2/.svn/entries: -------------------------------------------------------------------------------- 1 | 10 2 | 3 | dir 4 | 27 5 | https://bmp085driver.googlecode.com/svn/trunk/examples/BMP085_test2 6 | https://bmp085driver.googlecode.com/svn 7 | 8 | 9 | 10 | 2011-03-26T00:15:08.173336Z 11 | 26 12 | fil.vieira@gmail.com 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 43391e3e-6b59-17a6-64d1-a79cdfe6ffa7 28 | 29 | BMP085_test2.ino 30 | file 31 | 29 32 | 33 | 34 | 35 | 2012-01-07T00:57:04.138147Z 36 | 568d11b3aa2e163ad9006b0fb2b0c367 37 | 2012-01-07T01:19:23.863090Z 38 | 29 39 | fil.vieira@gmail.com 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 2084 62 | 63 | BMP085_test2.pde 64 | file 65 | 29 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | deleted 86 | 87 | -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/users-demo/bmp180/Adafruit-BMP085/examples/BMP085_test2/.svn/text-base/BMP085_test2.ino.svn-base: -------------------------------------------------------------------------------- 1 | // BMP085_test2 2 | // by Filipe Vieira 3 | // Simple test of BMP085 output using default settings using dynamic update. 4 | // In order to take full advantage of dynamic measurement, automatic temperature updates must be disabled. 5 | // To disable automatic updates set AUTO_UPDATE_TEMPERATURE to false in bmp085.h. 6 | // IMPORTANT!! To get correct values you MUST CHANGE init() parameters, in 7 | // this example I've set 250m based on GPS data for my location. 8 | 9 | #include 10 | #include 11 | 12 | BMP085 dps = BMP085(); // Digital Pressure Sensor 13 | 14 | long Pressure = 0, Altitude = 0; 15 | unsigned long time1=0; 16 | 17 | void setup(void) { 18 | Serial.begin(9600); 19 | Wire.begin(); 20 | delay(1000); 21 | 22 | // uncomment for different initialization settings 23 | //dps.init(); // QFE (Field Elevation above ground level) is set to 0 meters. 24 | // same as init(MODE_STANDARD, 0, true); 25 | 26 | //dps.init(MODE_STANDARD, 101850, false); // 101850Pa = 1018.50hPa, false = using Pa units 27 | // this initialization is useful for normalizing pressure to specific datum. 28 | // OR setting current local hPa information from a weather station/local airport (QNH). 29 | 30 | dps.init(MODE_STANDARD, 25000, true); // 250 meters, true = using meter units 31 | // this initialization is useful if current altitude is known, 32 | // pressure will be calculated based on TruePressure and known altitude. 33 | 34 | // note: use zeroCal only after initialization. 35 | // dps.zeroCal(101800, 0); // set zero point 36 | } 37 | 38 | void loop(void) { 39 | // calculate temperature every 1 sec (dynamic measurement) 40 | // NOTE: in order to take full advantage of dynamic measurement set AUTO_UPDATE_TEMPERATURE to false in bmp085.h 41 | if (((millis() - time1)/1000.0) >= 1.0) { 42 | dps.calcTrueTemperature(); 43 | time1 = millis(); 44 | } 45 | 46 | dps.getPressure(&Pressure); 47 | dps.getAltitude(&Altitude); 48 | 49 | Serial.print(" Alt(cm):"); 50 | Serial.print(Altitude); 51 | Serial.print(" Pressure(Pa):"); 52 | Serial.println(Pressure); 53 | } -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/users-demo/bmp180/Adafruit-BMP085/examples/BMP085_test2/BMP085_test2.ino: -------------------------------------------------------------------------------- 1 | // BMP085_test2 2 | // by Filipe Vieira 3 | // Simple test of BMP085 output using default settings using dynamic update. 4 | // In order to take full advantage of dynamic measurement, automatic temperature updates must be disabled. 5 | // To disable automatic updates set AUTO_UPDATE_TEMPERATURE to false in bmp085.h. 6 | // IMPORTANT!! To get correct values you MUST CHANGE init() parameters, in 7 | // this example I've set 250m based on GPS data for my location. 8 | 9 | #include 10 | #include 11 | 12 | BMP085 dps = BMP085(); // Digital Pressure Sensor 13 | 14 | long Pressure = 0, Altitude = 0; 15 | unsigned long time1=0; 16 | 17 | void setup(void) { 18 | Serial.begin(9600); 19 | Wire.begin(); 20 | delay(1000); 21 | 22 | // uncomment for different initialization settings 23 | //dps.init(); // QFE (Field Elevation above ground level) is set to 0 meters. 24 | // same as init(MODE_STANDARD, 0, true); 25 | 26 | //dps.init(MODE_STANDARD, 101850, false); // 101850Pa = 1018.50hPa, false = using Pa units 27 | // this initialization is useful for normalizing pressure to specific datum. 28 | // OR setting current local hPa information from a weather station/local airport (QNH). 29 | 30 | dps.init(MODE_STANDARD, 25000, true); // 250 meters, true = using meter units 31 | // this initialization is useful if current altitude is known, 32 | // pressure will be calculated based on TruePressure and known altitude. 33 | 34 | // note: use zeroCal only after initialization. 35 | // dps.zeroCal(101800, 0); // set zero point 36 | } 37 | 38 | void loop(void) { 39 | // calculate temperature every 1 sec (dynamic measurement) 40 | // NOTE: in order to take full advantage of dynamic measurement set AUTO_UPDATE_TEMPERATURE to false in bmp085.h 41 | if (((millis() - time1)/1000.0) >= 1.0) { 42 | dps.calcTrueTemperature(); 43 | time1 = millis(); 44 | } 45 | 46 | dps.getPressure(&Pressure); 47 | dps.getAltitude(&Altitude); 48 | 49 | Serial.print(" Alt(cm):"); 50 | Serial.print(Altitude); 51 | Serial.print(" Pressure(Pa):"); 52 | Serial.println(Pressure); 53 | } -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/users-demo/bmp180/Adafruit-BMP085/examples/BMP085test/BMP085test.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /*************************************************** 5 | This is an example for the BMP085 Barometric Pressure & Temp Sensor 6 | 7 | Designed specifically to work with the Adafruit BMP085 Breakout 8 | ----> https://www.adafruit.com/products/391 9 | 10 | These displays use I2C to communicate, 2 pins are required to 11 | interface 12 | Adafruit invests time and resources providing this open source code, 13 | please support Adafruit and open-source hardware by purchasing 14 | products from Adafruit! 15 | 16 | Written by Limor Fried/Ladyada for Adafruit Industries. 17 | BSD license, all text above must be included in any redistribution 18 | ****************************************************/ 19 | 20 | // Connect VCC of the BMP085 sensor to 3.3V (NOT 5.0V!) 21 | // Connect GND to Ground 22 | // Connect SCL to i2c clock - on '168/'328 Arduino Uno/Duemilanove/etc thats Analog 5 23 | // Connect SDA to i2c data - on '168/'328 Arduino Uno/Duemilanove/etc thats Analog 4 24 | // EOC is not used, it signifies an end of conversion 25 | // XCLR is a reset pin, also not used here 26 | 27 | Adafruit_BMP085 bmp; 28 | 29 | void setup() { 30 | Serial.begin(9600); 31 | if (!bmp.begin()) { 32 | Serial.println("Could not find a valid BMP085 sensor, check wiring!"); 33 | while (1) {} 34 | } 35 | } 36 | 37 | void loop() { 38 | Serial.print("Temperature = "); 39 | Serial.print(bmp.readTemperature()); 40 | Serial.println(" *C"); 41 | 42 | Serial.print("Pressure = "); 43 | Serial.print(bmp.readPressure()); 44 | Serial.println(" Pa"); 45 | 46 | // Calculate altitude assuming 'standard' barometric 47 | // pressure of 1013.25 millibar = 101325 Pascal 48 | Serial.print("Altitude = "); 49 | Serial.print(bmp.readAltitude()); 50 | Serial.println(" meters"); 51 | 52 | Serial.print("Pressure at sealevel (calculated) = "); 53 | Serial.print(bmp.readSealevelPressure()); 54 | Serial.println(" Pa"); 55 | 56 | // you can get a more precise measurement of altitude 57 | // if you know the current sea level pressure which will 58 | // vary with weather and such. If it is 1015 millibars 59 | // that is equal to 101500 Pascals. 60 | Serial.print("Real altitude = "); 61 | Serial.print(bmp.readAltitude(101500)); 62 | Serial.println(" meters"); 63 | 64 | Serial.println(); 65 | delay(500); 66 | } -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/users-demo/bmp180/Adafruit-BMP085/keywords.txt: -------------------------------------------------------------------------------- 1 | BMP085 KEYWORD1 2 | init KEYWORD2 3 | getDevAddr KEYWORD2 4 | getMode KEYWORD2 5 | setMode KEYWORD2 6 | setLocalPressure KEYWORD2 7 | setLocalAbsAlt KEYWORD2 8 | setAltOffset KEYWORD2 9 | sethPaOffset KEYWORD2 10 | zeroCal KEYWORD2 11 | getPressure KEYWORD2 12 | getAltitude KEYWORD2 13 | getTemperature KEYWORD2 14 | calcTrueTemperature KEYWORD2 15 | calcTruePressure KEYWORD2 16 | dumpCalData KEYWORD2 17 | writemem KEYWORD2 18 | readmem KEYWORD2 -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/users-demo/bmp180/Adafruit-BMP085/library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit BMP085 Library 2 | version=1.0.0 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=A powerful but easy to use BMP085/BMP180 Library 6 | paragraph=A powerful but easy to use BMP085/BMP180 Library 7 | category=Sensors 8 | url=https://github.com/adafruit/Adafruit-BMP085-Library 9 | architectures=* 10 | -------------------------------------------------------------------------------- /ArduinoIDE/ESP8266/users-demo/bmp180/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | ##### IoT Manager: BMP-085/BMP-180 demo 3 | --- 4 | ### Author: Sergey Bulgakov 5 | -------------------------------------------------------------------------------- /ArduinoIDE/README.md: -------------------------------------------------------------------------------- 1 | ### ESP8266 - sketches for ESP8266-based devices 2 | ### Arduino - sketches for Arduino-based devices 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Victor Brutskiy 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. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ##### iot-manager-demo 2 | --- 3 | 4 | Demo sketches for 5 | 6 | ##### [IoT Manager for iOS](https://itunes.apple.com/us/app/iot-manager/id1155934877) 7 | 8 | ##### [IoT Manager for Android](https://play.google.com/store/apps/details?id=ru.esp8266.iotmanager) 9 | 10 | --- 11 | ### pull-requests welcomed! 12 | -------------------------------------------------------------------------------- /node.js/official-demo/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /node.js/official-demo/README.md: -------------------------------------------------------------------------------- 1 | 2 | ### Demo client for IoT Manager 3 | 4 | ======= 5 | 6 | ## Install & Run 7 | 8 | Edit config.js and set connection (mqtt host, port, user and pass), then run 9 | 10 | ``` 11 | npm i 12 | node boiler.js 13 | ``` 14 | 15 | - boiler.js 16 | - bilb.js 17 | - chart.js 18 | - demo.js 19 | - display-value.js 20 | - fillgauge.js 21 | - home.js 22 | - linear.js 23 | - simple-btn.js 24 | - speech.js 25 | - toggle.js 26 | - gauge.js 27 | 28 | 29 | ## License 30 | 31 | MIT 32 | -------------------------------------------------------------------------------- /node.js/official-demo/bulb.js: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////// 2 | // 3 | // Demo device emulator for "steel" widget (bulb) 4 | // 5 | // 6 | // IoT Manager https://play.google.com/store/apps/details?id=ru.esp8266.iotmanager 7 | // 8 | // version : 1.1 9 | // IoT Manager : 1.4.11 and above 10 | // 11 | //////////////////////////////////////////////// 12 | 13 | //////////////////////////////////////////////// 14 | var config = require("./config"); 15 | var host = config.host; 16 | var port = config.port; 17 | var user = config.user; 18 | var pass = config.pass; 19 | var prefix = config.prefix; 20 | var deviceID = "nodejs_emulator" 21 | //////////////////////////////////////////////// 22 | 23 | var mqtt = require('mqtt'); 24 | var opt = { 25 | host : host, 26 | port : port, 27 | username : user, 28 | password : pass, 29 | clientId : 'mqttjs_' + Math.random().toString(16).substr(2, 8), 30 | protocolId : 'MQTT', 31 | connectTimeout: 3000 32 | }; 33 | 34 | var config1 = { 35 | id :"1", 36 | descr :"bulb 1", 37 | widget :"steel", 38 | topic :prefix + "/" + deviceID + "/bulb1", 39 | class1 : "col-xs-6 text-center", 40 | widgetConfig : { 41 | width : "auto2", 42 | height : 200, 43 | type : "LightBulb", 44 | color : "rgb(204, 51, 0)", // red 45 | } 46 | }; 47 | 48 | var config2 = { 49 | id :"2", 50 | descr :"bulb 2", 51 | widget :"steel", 52 | topic :prefix + "/" + deviceID + "/bulb2", 53 | class1 : "col-xs-6 text-center", 54 | widgetConfig : { 55 | width : "auto2", 56 | height : 200, 57 | type : "LightBulb", 58 | color : "rgb(0, 255, 0)", // green 59 | } 60 | }; 61 | 62 | var config3 = { 63 | id :"3", 64 | descr :"battery", 65 | widget :"steel", 66 | topic :prefix + "/" + deviceID + "/battery1", 67 | class1 : "item text-center no-border", 68 | widgetConfig : { 69 | width : 80, 70 | height : 36, 71 | type : "Battery" 72 | } 73 | }; 74 | 75 | var config4 = { 76 | id :"4", 77 | descr :"led", 78 | widget :"steel", 79 | topic :prefix + "/" + deviceID + "/led4", 80 | class1 : "col-xs-3 text-center", 81 | widgetConfig : { 82 | width : 50, 83 | height : 50, 84 | type : "Led", 85 | blink : false, 86 | LedColor: "GREEN_LED", // RED_LED GREEN_LED BLUE_LED ORANGE_LED YELLOW_LED CYAN_LED MAGENTA_LED 87 | } 88 | }; 89 | 90 | var config5 = { 91 | id :"5", 92 | descr :"led", 93 | widget :"steel", 94 | topic :prefix + "/" + deviceID + "/led5", 95 | class1 : "col-xs-6 text-center", 96 | widgetConfig : { 97 | width : 100, 98 | height : 100, 99 | type : "Led", 100 | blink : true, 101 | LedColor: "CYAN_LED", // RED_LED GREEN_LED BLUE_LED ORANGE_LED YELLOW_LED CYAN_LED MAGENTA_LED 102 | } 103 | }; 104 | 105 | var config6 = { 106 | id :"6", 107 | descr :"led", 108 | widget :"steel", 109 | topic :prefix + "/" + deviceID + "/led6", 110 | class1 : "col-xs-2 text-center", 111 | widgetConfig : { 112 | width : 50, 113 | height : 50, 114 | type : "Led", 115 | blink : true, 116 | LedColor: "RED_LED", // RED_LED GREEN_LED BLUE_LED ORANGE_LED YELLOW_LED CYAN_LED MAGENTA_LED 117 | } 118 | }; 119 | 120 | 121 | var config7 = { 122 | id :"7", 123 | descr :"odometer", 124 | widget :"steel", 125 | topic :prefix + "/" + deviceID + "/odo", 126 | class1 : "text-center", 127 | widgetConfig : { 128 | width : 100, 129 | height : 40, 130 | type : "Odometer", 131 | } 132 | }; 133 | 134 | var bulb1alpha = 0; 135 | var bulb2alpha = 0; 136 | var batVal = 0; 137 | var batInc = 5; 138 | var led4 = 0; 139 | var odo = 123.0; 140 | 141 | var client = mqtt.connect(opt); 142 | 143 | client.on('connect', function () { 144 | console.log('Broker connected'); 145 | client.subscribe(prefix); 146 | pubConfig(); 147 | }); 148 | 149 | client.on('error', function () { 150 | console.log('error'); 151 | }); 152 | 153 | client.on('offline', function () { 154 | console.log('offline'); 155 | }); 156 | 157 | client.on('message', function (topic, message) { 158 | if (topic.toString() == prefix && message.toString() == "HELLO" ){ 159 | console.log('HELLO detected'); 160 | pubConfig(); 161 | } 162 | }); 163 | 164 | console.log('Start'); 165 | setInterval(function() { 166 | bulb1alpha = Math.random() * 100; 167 | bulb2alpha = Math.random() * 100; 168 | led4 = Math.round(Math.random() * 1); 169 | pubStatus1(); 170 | battery(); 171 | 172 | }, 2000); 173 | 174 | setInterval(function() { 175 | updateOdo(); 176 | 177 | }, 200); 178 | //////////////////////////////////////////////// 179 | function pubConfig() { 180 | client.publish(prefix + "/" + deviceID + '/config', JSON.stringify(config1)); 181 | client.publish(prefix + "/" + deviceID + '/config', JSON.stringify(config2)); 182 | client.publish(prefix + "/" + deviceID + '/config', JSON.stringify(config3)); 183 | client.publish(prefix + "/" + deviceID + '/config', JSON.stringify(config4)); 184 | client.publish(prefix + "/" + deviceID + '/config', JSON.stringify(config5)); 185 | client.publish(prefix + "/" + deviceID + '/config', JSON.stringify(config6)); 186 | client.publish(prefix + "/" + deviceID + '/config', JSON.stringify(config7)); 187 | console.log('pubConfig'); 188 | } 189 | //////////////////////////////////////////////// 190 | 191 | function pubStatus1() { 192 | console.log("Send status"); 193 | client.publish(config1.topic + '/status', JSON.stringify({ status: bulb1alpha })); 194 | client.publish(config2.topic + '/status', JSON.stringify({ status: bulb2alpha })); 195 | client.publish(config3.topic + '/status', JSON.stringify({ status: batVal })); 196 | client.publish(config4.topic + '/status', JSON.stringify({ status: led4 })); 197 | client.publish(config7.topic + '/status', JSON.stringify({ status: odo })); 198 | } 199 | //////////////////////////////////////////////// 200 | function battery() { 201 | batVal += batInc; 202 | if (batVal < 0 || batVal > 100) {batInc = -batInc;} 203 | } 204 | function updateOdo() { 205 | odo += 0.005 206 | } 207 | -------------------------------------------------------------------------------- /node.js/official-demo/chart.js: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////// 2 | // 3 | // Demo device emulator for char widget 4 | // 5 | // 6 | // 7 | // IoT Manager https://play.google.com/store/apps/details?id=ru.esp8266.iotmanager 8 | // 9 | // version : 1.0 10 | // IoT Manager : 1.5.3 and above 11 | // 12 | //////////////////////////////////////////////// 13 | 14 | //////////////////////////////////////////////// 15 | var config = require("./config"); 16 | var host = config.host; 17 | var port = config.port; 18 | var user = config.user; 19 | var pass = config.pass; 20 | //////////////////////////////////////////////// 21 | 22 | var mqtt = require('mqtt'); 23 | var opt = { 24 | host : host, 25 | port : port, 26 | username : user, 27 | password : pass, 28 | clientId : 'mqtt-js_' + Math.random().toString(16).substr(2, 8), 29 | protocolId : 'MQTT', 30 | connectTimeout: 3000 31 | }; 32 | 33 | 34 | var deviceID = "chart"; 35 | var prefix = "/IoTmanager"; 36 | var config = []; 37 | var client = mqtt.connect(opt); 38 | 39 | // First line 40 | var widget = "anydata"; 41 | var id = "0" 42 | config[0] = { 43 | id : id, 44 | widget : widget, 45 | class1 : "item no-border", 46 | style2 : "font-size:16px;", 47 | topic : prefix + "/" + deviceID + "/" + widget + id, 48 | class3 : "calm text-center", 49 | style3 : "font-size:20px;", 50 | status : "My Home" 51 | }; 52 | 53 | 54 | widget = "chart"; 55 | id = "1" 56 | config[1] = { 57 | id : id, 58 | widget : widget, 59 | topic : prefix + "/" + deviceID + "/" + widget + id, 60 | widgetConfig: { 61 | type: 'line', // line, bar, horizontalBar, radar, polarArea, doughnut, pie, bubble 62 | maxCount: 20 63 | } 64 | }; 65 | 66 | widget = "chart"; 67 | id = "2" 68 | config[2] = { 69 | id : id, 70 | widget : widget, 71 | topic : prefix + "/" + deviceID + "/" + widget + id, 72 | widgetConfig: { 73 | type: 'line', // line, bar, horizontalBar, radar, polarArea, doughnut, pie, bubble 74 | maxCount: 10 75 | } 76 | }; 77 | 78 | widget = "chart"; 79 | id = "3" 80 | config[3] = { 81 | id : id, 82 | widget : widget, 83 | topic : prefix + "/" + deviceID + "/" + widget + id, 84 | widgetConfig: { 85 | type: 'bar', // line, bar, horizontalBar, radar, polarArea, doughnut, pie, bubble 86 | maxCount: 5 87 | } 88 | }; 89 | 90 | client.on('connect', function () { 91 | console.log('Broker connected'); 92 | client.subscribe(prefix, { qos : 1 }); // HELLO expected 93 | pubConfig(); 94 | }); 95 | 96 | client.on('error', function () { 97 | console.log('Broker error'); 98 | }); 99 | 100 | client.on('offline', function () { 101 | console.log('Broker offline'); 102 | }); 103 | 104 | client.on('message', function (topic, message) { 105 | 106 | console.log("Message arrived: " + topic.toString() + " => " + message.toString()); 107 | 108 | if (topic.toString() === prefix && message.toString() == "HELLO" ){ 109 | console.log('HELLO detected'); 110 | pubConfig(); 111 | } 112 | pubStatus(); 113 | 114 | }) 115 | //////////////////////////////////////////////// 116 | function pubConfig() { 117 | config.forEach(function(item, i, arr) { 118 | client.publish(prefix + "/" + deviceID + "/config", JSON.stringify(item),{ qos : 1 }); 119 | }); 120 | } 121 | //////////////////////////////////////////////// 122 | function pubStatus() { 123 | 124 | var x = Math.round(Math.random() * 5 - 5); 125 | 126 | var y = Math.round(Math.random() * 10 - 5); 127 | 128 | var z = Math.round(Math.random() * 15 - 10); 129 | 130 | client.publish( config[1].topic+"/status", JSON.stringify({ status: x }) ); 131 | client.publish( config[2].topic+"/status", JSON.stringify({ status: [x, y ] }) ); 132 | client.publish( config[3].topic+"/status", JSON.stringify({ status: [x, y, z] }) ); 133 | 134 | console.log('Publish'); 135 | } 136 | //////////////////////////////////////////////// 137 | // run main 138 | console.log('Start'); 139 | 140 | setInterval(function() { 141 | pubStatus(); 142 | }, 1000); 143 | -------------------------------------------------------------------------------- /node.js/official-demo/clear-retain.js: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////// 2 | // 3 | // Clear all messages with RETAIN flag 4 | // 5 | //////////////////////////////////////////////// 6 | 7 | //////////////////////////////////////////////// 8 | var config = require("./config"); 9 | var host = config.host; 10 | var port = config.port; 11 | var user = config.user; 12 | var pass = config.pass; 13 | //////////////////////////////////////////////// 14 | 15 | var mqtt = require('mqtt'); 16 | var opt = { 17 | host : host, 18 | port : port, 19 | username : user, 20 | password : pass, 21 | clientId : 'mqttjs_' + Math.random().toString(16).substr(2, 8), 22 | protocolId : 'MQTT', 23 | connectTimeout: 3000 24 | }; 25 | 26 | var client = mqtt.connect(opt); 27 | 28 | client.on('connect', function () { 29 | console.log('Broker connected'); 30 | client.subscribe('#'); 31 | }); 32 | 33 | client.on('error', function () { 34 | console.log('error'); 35 | }); 36 | 37 | client.on('offline', function () { 38 | console.log('offline'); 39 | }); 40 | 41 | client.on('message', function (topic, message) { 42 | if (message.toString().length > 0) { 43 | console.log("receive '" + topic + "' : '" + message.toString() + "'") 44 | // client.publish(topic, null, {retain: true}); 45 | console.log('clear topic ' + topic) 46 | } 47 | }); 48 | 49 | -------------------------------------------------------------------------------- /node.js/official-demo/config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ###### ####### ## ## ######## #### ###### 3 | * ## ## ## ## ### ## ## ## ## ## 4 | * ## ## ## #### ## ## ## ## 5 | * ## ## ## ## ## ## ###### ## ## #### 6 | * ## ## ## ## #### ## ## ## ## 7 | * ## ## ## ## ## ### ## ## ## ## 8 | * ###### ####### ## ## ## #### ###### 9 | * 10 | * User defined section 11 | */ 12 | 13 | module.exports ={ 14 | // host : '192.168.1.135', 15 | // port : 1883, 16 | host : 'm20.cloudmqtt.com', 17 | port : 13191, 18 | user : "test", 19 | pass : "test", 20 | prefix: "/IoTmanager" 21 | } 22 | -------------------------------------------------------------------------------- /node.js/official-demo/demo.js: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////// 2 | // 3 | // Demo device emulator for "toggle" widget 4 | // 5 | // 6 | // IoT Manager https://play.google.com/store/apps/details?id=ru.esp8266.iotmanager 7 | // 8 | // version : 1.1 9 | // IoT Manager : 1.4.1 and above 10 | // 11 | //////////////////////////////////////////////// 12 | 13 | //////////////////////////////////////////////// 14 | var config = require("./config"); 15 | var host = config.host; 16 | var port = config.port; 17 | var user = config.user; 18 | var pass = config.pass; 19 | //////////////////////////////////////////////// 20 | 21 | var mqtt = require('mqtt'); 22 | var opt = { 23 | host : host, 24 | port : port, 25 | username : user, 26 | password : pass, 27 | clientId : 'mqttjs_' + Math.random().toString(16).substr(2, 8), 28 | protocolId : 'MQTT', 29 | connectTimeout: 3000 30 | }; 31 | 32 | var config1 = { 33 | id :"1", 34 | page : "kitchen", 35 | pageId : "1", 36 | descr : "Light 1", 37 | widget : "toggle", 38 | topic : "/IoTmanager/deviceID/light1", 39 | color : "orange", 40 | style1 : "" 41 | }; 42 | var config2 = { 43 | id :"2", 44 | page :"bathroom", 45 | pageId :"2", 46 | descr :"Light 2", 47 | widget :"toggle", 48 | topic :"/IoTmanager/deviceID/light2", 49 | color :"blue", 50 | style :"" 51 | }; 52 | 53 | var client = mqtt.connect(opt); 54 | 55 | client.on('connect', function () { 56 | console.log('Broker connected'); 57 | client.subscribe('/IoTmanager/deviceID/+/control'); 58 | client.subscribe('/IoTmanager'); 59 | pubConfig(); 60 | }); 61 | 62 | client.on('error', function () { 63 | console.log('error'); 64 | }); 65 | 66 | client.on('offline', function () { 67 | console.log('offline'); 68 | }); 69 | 70 | client.on('message', function (topic, message) { 71 | if (topic.toString() == "/IoTmanager" && message.toString() == "HELLO" ){ 72 | console.log('HELLO detected'); 73 | pubConfig(); 74 | } else { 75 | if (topic.split("/")[4] == 'control') { 76 | console.log('Control message arrived to topic:'+topic.toString()+', payload:'+message.toString()); 77 | var status; 78 | if (message.toString() === "1") { 79 | status = { status: 1 }; 80 | } else { 81 | status = { status: 0 }; 82 | } 83 | if (topic.split("/")[4] == 'control' && topic.split("/")[3] == "light1") { 84 | client.publish('/IoTmanager/deviceID/light1/status',JSON.stringify(status)); 85 | } 86 | if (topic.split("/")[4] == 'control' && topic.split("/")[3] == "light2") { 87 | client.publish('/IoTmanager/deviceID/light2/status',JSON.stringify(status)); 88 | } 89 | console.log("Status (echo) published: " + JSON.stringify(status)); 90 | } else { 91 | console.log('Message arrived to topic:'+topic.toString()+', payload:'+message.toString()); 92 | } 93 | } 94 | }); 95 | 96 | console.log('Start'); 97 | //////////////////////////////////////////////// 98 | function pubConfig() { 99 | client.publish('/IoTmanager/deviceID/config', JSON.stringify(config1)); 100 | setTimeout(function() { 101 | client.publish('/IoTmanager/deviceID/config', JSON.stringify(config2)); 102 | }, 200); 103 | } 104 | //////////////////////////////////////////////// -------------------------------------------------------------------------------- /node.js/official-demo/display-value.js: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////// 2 | // 3 | // Demo device emulator for "display-value" widget 4 | // 5 | // 4 different colors demo display-value widgets with random data (colors: red, green, blue, yellow) 6 | // 7 | // IoT Manager 8 | // for Android https://play.google.com/store/apps/details?id=ru.esp8266.iotmanager 9 | // for iOS https://itunes.apple.com/us/app/iot-manager/id1155934877 10 | // 11 | // version : 1.8 12 | // IoT Manager : 1.4.6 and above 13 | // 14 | //////////////////////////////////////////////// 15 | 16 | //////////////////////////////////////////////// 17 | var config = require("./config"); 18 | var host = config.host; 19 | var port = config.port; 20 | var user = config.user; 21 | var pass = config.pass; 22 | //////////////////////////////////////////////// 23 | 24 | var mqtt = require('mqtt'); 25 | var opt = { 26 | host : host, 27 | port : port, 28 | username : user, 29 | password : pass, 30 | clientId : 'mqttjs_' + Math.random().toString(16).substr(2, 8), 31 | protocolId : 'MQTT', 32 | connectTimeout: 3000 33 | }; 34 | 35 | var deviceID = "uniqueId-0001"; 36 | var prefix = "/IoTmanager"; 37 | 38 | var config1 = {"id":"1", 39 | page : "display 1", 40 | // pageId : 1, 41 | widget : "display-value", 42 | class1 : "item no-border", 43 | style1 : "", 44 | descr : "Display-1", 45 | class2 : "balanced", 46 | style2 : "font-size:20px;float:left;padding-top:10px;font-weight:bold;", 47 | topic : prefix + "/" + deviceID + "/display1", 48 | class3 : "", 49 | style3 : "float:right;", 50 | height : "40", 51 | color : "#52FF00", 52 | inactive_color : "#414141", 53 | digits_count : 5 54 | }; 55 | 56 | var config2 = {"id":"2", 57 | page : "display 2", 58 | // pageId : 2, 59 | widget : "display-value", 60 | class1 : "item no-border", 61 | style1 : "", 62 | descr : "Display-2", 63 | class2 : "assertive", 64 | style2 : "font-size:20px;float:left;font-weight:bold;", 65 | topic : prefix + "/" + deviceID + "/display2", 66 | class3 : "", 67 | style3 : "float:right;", 68 | height : "20", 69 | color : "#F10014", 70 | inactive_color : "#414141", 71 | digits_count : 10 72 | }; 73 | 74 | var config3 = {"id":"3", 75 | page : "display 34", 76 | // pageId : 3, 77 | widget : "display-value", 78 | class1 : "item no-border text-center col-xs-6", 79 | style1 : "", 80 | descr : "d-3", 81 | class2 : "calm", 82 | style2 : "font-size:32px;padding-top:10px;padding-bottom:20px;font-weight:bold;", 83 | topic : prefix + "/" + deviceID + "/display3", 84 | class3 : "", 85 | style3 : "", 86 | height : "70", 87 | color : "#58b7ff", 88 | inactive_color : "#414141", 89 | digits_count : 3 90 | }; 91 | 92 | var config4 = {"id":"4", 93 | page : "display 34", 94 | // pageId : 3, 95 | widget : "display-value", 96 | class1 : "item no-border text-center col-xs-6", 97 | style1 : "", 98 | descr : "d-4", 99 | class2 : "energized", 100 | style2 : "font-size:32px;padding-top:10px;padding-bottom:20px;font-weight:bold;", 101 | topic : prefix + "/" + deviceID + "/display4", 102 | class3 : "", 103 | style3 : "", 104 | height : "70", 105 | color : "#ffe800", 106 | inactive_color : "#414141", 107 | digits_count : 2 108 | }; 109 | 110 | var config5 = { 111 | 112 | id :"5", 113 | page : "Temp", 114 | //pageID : "3", 115 | widget : "display-value", 116 | class1 : "item no-border", // class for 1st div 117 | style1 : "", // style for 1st div 118 | descr : "Kitchen", // text for description 119 | class2 : "balanced", // class for description from Widgets Guide - Color classes 120 | style2 : "font-size:20px;float:left;padding-top:10px;font-weight:bold;", // style for description 121 | topic : prefix + "/" + deviceID + "/display5", 122 | class3 : "", // class for 3 div - SVG 123 | style3 : "float:right;", // style for 3 div - SVG 124 | height : "40", // SVG height without "px" 125 | color : "#52FF00", // color for active segments 126 | inactive_color : "#414141", // color for inactive segments 127 | digits_count : 4 // how many digits 128 | }; 129 | var client = mqtt.connect(opt); 130 | 131 | client.on('connect', function () { 132 | console.log('Broker connected'); 133 | client.subscribe('/IoTmanager',{ qos : 1 }); 134 | pubConfig(); 135 | }); 136 | 137 | client.on('error', function () { 138 | console.log('error'); 139 | }); 140 | 141 | client.on('offline', function () { 142 | console.log('offline'); 143 | }); 144 | 145 | client.on('message', function (topic, message) { 146 | if (topic.toString() === prefix && message.toString() == "HELLO" ){ 147 | console.log('HELLO detected'); 148 | pubConfig(); 149 | } 150 | }); 151 | 152 | console.log('Start'); 153 | 154 | pubConfig(); 155 | 156 | setInterval(function() { 157 | pubStatus1(); 158 | pubStatus2(); 159 | pubStatus3(); 160 | pubStatus4(); 161 | pubStatus5(); 162 | }, 5000); 163 | 164 | //////////////////////////////////////////////// 165 | function pubStatus1() { 166 | value1 = (20 - Math.round( Math.random() * 40 )); 167 | console.log("Send status 1:" + value1); 168 | value1 = value1 + '°C' 169 | client.publish( config1.topic + "/status", JSON.stringify({ status: value1, longToast: "Outdoor temp now: "+value1, vibrate: 0 }) ); 170 | } 171 | //////////////////////////////////////////////// 172 | function pubStatus2() { 173 | value2 = (Math.round( Math.random() * 1000000000 )); 174 | console.log("Send status 2:" + value2); 175 | client.publish( config2.topic + "/status", JSON.stringify({ status: value2 }) ); 176 | } 177 | //////////////////////////////////////////////// 178 | function pubStatus3() { 179 | value3 = (50 - Math.round( Math.random() * 100 )); 180 | console.log("Send status 3:" + value3); 181 | client.publish( config3.topic + "/status", JSON.stringify({ status: value3 }) ); 182 | } 183 | //////////////////////////////////////////////// 184 | function pubStatus4() { 185 | value4 = Math.round( Math.random() * 99 ); 186 | console.log("Send status 4:" + value4 + " color"); 187 | client.publish( config4.topic + "/status", JSON.stringify({ status: value4, color : "#000000" }) ); 188 | } 189 | function pubStatus5() { 190 | value5 = Math.round( Math.random() * 99 ); 191 | console.log("Send status 5:" + value5 + " color"); 192 | client.publish( config5.topic + "/status", JSON.stringify({ status: value5 }) ); 193 | } 194 | //////////////////////////////////////////////// 195 | function pubConfig() { 196 | client.publish(prefix + "/" + deviceID + "/config", JSON.stringify(config1),{ qos : 1 }); 197 | client.publish(prefix + "/" + deviceID + "/config", JSON.stringify(config2),{ qos : 1 }); 198 | client.publish(prefix + "/" + deviceID + "/config", JSON.stringify(config3),{ qos : 1 }); 199 | client.publish(prefix + "/" + deviceID + "/config", JSON.stringify(config4),{ qos : 1 }); 200 | client.publish(prefix + "/" + deviceID + "/config", JSON.stringify(config5),{ qos : 1 }); 201 | setTimeout(function() { 202 | pubStatus1(); 203 | pubStatus2(); 204 | pubStatus3(); 205 | pubStatus4(); 206 | pubStatus5(); 207 | }, 1000); 208 | } 209 | //////////////////////////////////////////////// 210 | -------------------------------------------------------------------------------- /node.js/official-demo/gauge.js: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////// 2 | // 3 | // gauge widget demo 4 | // 5 | // IoT Manager 6 | // for Android https://play.google.com/store/apps/details?id=ru.esp8266.iotmanager 7 | // for iOS https://itunes.apple.com/us/app/iot-manager/id1155934877 8 | // 9 | // script version : 1.0 10 | // IoT Manager : 1.5.5 and above 11 | // 12 | //////////////////////////////////////////////// 13 | 14 | //////////////////////////////////////////////// 15 | var config = require("./config"); 16 | var host = config.host; 17 | var port = config.port; 18 | var user = config.user; 19 | var pass = config.pass; 20 | //////////////////////////////////////////////// 21 | 22 | var mqtt = require('mqtt'); 23 | var opt = { 24 | host : host, 25 | port : port, 26 | username : user, 27 | password : pass, 28 | clientId : 'mqtt-js_' + Math.random().toString(16).substr(2, 8), 29 | protocolId : 'MQTT', 30 | connectTimeout: 3000 31 | }; 32 | 33 | 34 | var deviceID = "test-gauge"; 35 | var prefix = "/IoTmanager"; 36 | var config = []; 37 | var client = mqtt.connect(opt); 38 | 39 | var widget = "gauge"; 40 | var id = "0" 41 | config[0] = { 42 | id : id, 43 | widget : widget, 44 | topic : prefix + "/" + deviceID + "/" + widget + id, 45 | descr : "Speed", 46 | class1 : "text-center col-xs-4 no-padding-left no-padding-right", 47 | widgetConfig : { 48 | append: 'km/h' 49 | } 50 | }; 51 | 52 | id = "1" 53 | config[1] = { 54 | id : id, 55 | widget : widget, 56 | topic : prefix + "/" + deviceID + "/" + widget + id, 57 | descr : "Power", 58 | class1 : "text-center col-xs-4 no-padding-left no-padding-right", 59 | widgetConfig : { 60 | type: "semi", 61 | size: 150, 62 | append: 'kW', 63 | } 64 | }; 65 | 66 | id = "2" 67 | config[2] = { 68 | id : id, 69 | widget : widget, 70 | topic : prefix + "/" + deviceID + "/" + widget + id, 71 | descr : "Profit", 72 | class1 : "text-center col-xs-4 no-padding-left no-padding-right", 73 | widgetConfig : { 74 | type: "arch", 75 | size: 150, 76 | append: '%', 77 | } 78 | }; 79 | 80 | id = "3" 81 | config[3] = { 82 | id : id, 83 | widget : widget, 84 | topic : prefix + "/" + deviceID + "/" + widget + id, 85 | descr : "Sales", 86 | class1 : "text-center col-xs-4 no-padding-left no-padding-right", 87 | widgetConfig : { 88 | type : "full", 89 | thick : 8, 90 | append :"%" 91 | } 92 | }; 93 | 94 | id = "4" 95 | config[4] = { 96 | id : id, 97 | widget : widget, 98 | topic : prefix + "/" + deviceID + "/" + widget + id, 99 | descr : "Pressure", 100 | class1 : "text-center col-xs-4 no-padding-left no-padding-right", 101 | widgetConfig : { 102 | type : "arch", 103 | thick : 12, 104 | append :"Pa", 105 | color : '#ffaaaa', 106 | textColor : '#ff5555', 107 | backgroundColor: 'rgba(255,255,255, 0.8)' 108 | } 109 | }; 110 | 111 | id = "5" 112 | config[5] = { 113 | id : id, 114 | widget : widget, 115 | topic : prefix + "/" + deviceID + "/" + widget + id, 116 | descr : "Usage", 117 | class1 : "text-center col-xs-4 no-padding-left no-padding-right", 118 | widgetConfig : { 119 | type : "arch", 120 | thick : 12, 121 | cap : "butt", 122 | append : "Gb", 123 | color : '#aaffaa', 124 | backgroundColor: '#ffaaaa' 125 | } 126 | }; 127 | 128 | id = "6" 129 | config[6] = { 130 | id : id, 131 | widget : widget, 132 | topic : prefix + "/" + deviceID + "/" + widget + id, 133 | class1 : "text-center col-xs-6 no-padding-left no-padding-right", 134 | descr : "maxValue 150", 135 | widgetConfig : { 136 | type : "arch", 137 | thick : 8, 138 | maximum: 150, 139 | color : '#aaaaff', 140 | backgroundColor: '#fff' 141 | } 142 | }; 143 | 144 | id = "7" 145 | config[7] = { 146 | id : id, 147 | widget : widget, 148 | topic : prefix + "/" + deviceID + "/" + widget + id, 149 | class1 : "text-center col-xs-6 no-padding-left no-padding-right", 150 | descr : "Prepend", 151 | widgetConfig : { 152 | type : "arch", 153 | thick : 8, 154 | prepend: "$", 155 | color : '#55ff55' 156 | } 157 | }; 158 | 159 | id = "8" 160 | config[8] = { 161 | id : id, 162 | widget : widget, 163 | topic : prefix + "/" + deviceID + "/" + widget + id, 164 | class1 : "item no-border no-padding text-center", 165 | descr : "maxValue 200", 166 | widgetConfig : { 167 | type : "semi", 168 | size : 300, 169 | thick : 20, 170 | maximum: 200, 171 | color : '#11c1f3', 172 | backgroundColor: 'rgba(0,0,0, 0.2)' 173 | } 174 | }; 175 | 176 | client.on('connect', function () { 177 | console.log('Broker connected'); 178 | client.subscribe(prefix, { qos : 1 }); // HELLO expected 179 | pubConfig(); 180 | setInterval(function() { 181 | pubStatus(); 182 | }, 3000); 183 | }); 184 | 185 | client.on('error', function () { 186 | console.log('Broker error'); 187 | }); 188 | 189 | client.on('offline', function () { 190 | console.log('Broker offline'); 191 | }); 192 | 193 | client.on('message', function (topic, message) { 194 | 195 | console.log("Message arrived: " + topic.toString() + " => " + message.toString()); 196 | 197 | if (topic.toString() === prefix && message.toString() == "HELLO" ){ 198 | console.log('HELLO detected'); 199 | pubConfig(); 200 | } 201 | 202 | }) 203 | //////////////////////////////////////////////// 204 | function pubConfig() { 205 | config.forEach(function(item, i, arr) { 206 | client.publish(prefix + "/" + deviceID + "/config", JSON.stringify(item),{ qos : 1 }); 207 | }); 208 | pubStatus(); 209 | } 210 | //////////////////////////////////////////////// 211 | function pubStatus() { 212 | var speed = 60 + Math.round(Math.random() * 30); 213 | var power = 70 + Math.round(Math.random() * 30); 214 | var profit = 80 + Math.round(Math.random() * 20); 215 | var sales = 90 + Math.round(Math.random() * 10); 216 | var pressure = 50 + Math.round(Math.random() * 50); 217 | var usage = 40 + Math.round(Math.random() * 60); 218 | var used = 100 + Math.round(Math.random() * 50); 219 | var prepend = 20 + Math.round(Math.random() * 80); 220 | var noappend = 100 + Math.round(Math.random() * 100); 221 | 222 | client.publish( config[0].topic+"/status", JSON.stringify({ status: speed }) ); 223 | client.publish( config[1].topic+"/status", JSON.stringify({ status: power }) ); 224 | client.publish( config[2].topic+"/status", JSON.stringify({ status: profit }) ); 225 | client.publish( config[3].topic+"/status", JSON.stringify({ status: sales }) ); 226 | client.publish( config[4].topic+"/status", JSON.stringify({ status: pressure }) ); 227 | client.publish( config[5].topic+"/status", JSON.stringify({ status: usage }) ); 228 | client.publish( config[6].topic+"/status", JSON.stringify({ status: used }) ); 229 | client.publish( config[7].topic+"/status", JSON.stringify({ status: prepend }) ); 230 | client.publish( config[8].topic+"/status", JSON.stringify({ status: noappend }) ); 231 | console.log('Publish status'); 232 | } 233 | //////////////////////////////////////////////// 234 | // run main 235 | console.log('Start'); 236 | 237 | -------------------------------------------------------------------------------- /node.js/official-demo/home.js: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////// 2 | // 3 | // Demo device emulator 4 | // 5 | // 6 | // 7 | // IoT Manager https://play.google.com/store/apps/details?id=ru.esp8266.iotmanager 8 | // 9 | // version : 1.1 10 | // IoT Manager : 1.5.0 and above 11 | // 12 | //////////////////////////////////////////////// 13 | 14 | //////////////////////////////////////////////// 15 | var config = require("./config"); 16 | var host = config.host; 17 | var port = config.port; 18 | var user = config.user; 19 | var pass = config.pass; 20 | //////////////////////////////////////////////// 21 | 22 | var mqtt = require('mqtt'); 23 | var opt = { 24 | host : host, 25 | port : port, 26 | username : user, 27 | password : pass, 28 | clientId : 'mqtt-js_' + Math.random().toString(16).substr(2, 8), 29 | protocolId : 'MQTT', 30 | connectTimeout: 3000 31 | }; 32 | 33 | 34 | var waterTemp = 20; 35 | var hiTemp = 40; 36 | var hysteresis= 5; 37 | 38 | var deviceID = "boiler-0001"; 39 | var prefix = "/IoTmanager"; 40 | var config = []; 41 | var client = mqtt.connect(opt); 42 | 43 | // First line 44 | var widget = "anydata"; 45 | var id = "0" 46 | config[0] = { 47 | id : id, 48 | page : "boiler", 49 | pageId : 1, 50 | widget : widget, 51 | class1 : "item no-border", 52 | style2 : "font-size:16px;", 53 | topic : prefix + "/" + deviceID + "/" + widget + id, 54 | class3 : "calm text-center", 55 | style3 : "font-size:20px;", 56 | status : "My Home" 57 | }; 58 | 59 | 60 | // Outdoor temp 61 | widget = "anydata"; 62 | id = "1" 63 | config[1] = { 64 | id : id, 65 | page : "boiler", 66 | pageId : 1, 67 | widget : widget, 68 | class1 : "item no-border", 69 | style2 : "font-size:20px;float:left", 70 | descr : "Outdoor temp", 71 | topic : prefix + "/" + deviceID + "/" + widget + id, 72 | class3 : "assertive", 73 | style3 : "font-size:40px;font-weight:bold;float:right", 74 | }; 75 | 76 | // Indoor temp 77 | widget = "anydata"; 78 | id = "2" 79 | config[2] = { 80 | id : id, 81 | page : "boiler", 82 | pageId : 1, 83 | widget : widget, 84 | class1 : "item no-border", 85 | style2 : "font-size:20px;float:left;line-height:3em", 86 | descr : "Indoor temp", 87 | topic : prefix + "/" + deviceID + "/" + widget + id, 88 | class3 : "balanced-bg light padding-left padding-right rounded", 89 | style3 : "font-size:40px;font-weight:bold;float:right;line-height:1.5em", 90 | }; 91 | 92 | 93 | // Humidity 94 | widget = "anydata"; 95 | id = "3" 96 | config[3] = { 97 | id : id, 98 | page : "boiler", 99 | pageId : 1, 100 | widget : widget, 101 | class1 : "item no-border", 102 | style2 : "font-size:20px;float:left;line-height:3em", 103 | descr : "Humidity", 104 | topic : prefix + "/" + deviceID + "/" + widget + id, 105 | class3 : "balanced-bg light padding-left padding-right rounded", 106 | style3 : "font-size:40px;font-weight:bold;float:right;line-height:1.5em", 107 | }; 108 | 109 | // CO2 110 | widget = "anydata"; 111 | id = "4" 112 | config[4] = { 113 | id : id, 114 | page : "boiler", 115 | pageId : 1, 116 | widget : widget, 117 | class1 : "item no-border", 118 | style2 : "font-size:30px;float:left", 119 | descr : "CO2", 120 | topic : prefix + "/" + deviceID + "/" + widget + id, 121 | class3 : "balanced", 122 | style3 : "font-size:30px;font-weight:bold;float:right", 123 | }; 124 | 125 | 126 | 127 | client.on('connect', function () { 128 | console.log('Broker connected'); 129 | client.subscribe(prefix, { qos : 1 }); // HELLO expected 130 | // client.subscribe(prefix + "/" + deviceID +"/+/control", { qos : 1 }); // all commands, not used int this example 131 | pubConfig(); 132 | setInterval(function() { 133 | pubStatus(); 134 | }, 1000); 135 | }); 136 | 137 | client.on('error', function () { 138 | console.log('Broker error'); 139 | }); 140 | 141 | client.on('offline', function () { 142 | console.log('Broker offline'); 143 | }); 144 | 145 | client.on('message', function (topic, message) { 146 | 147 | console.log("Message arrived: " + topic.toString() + " => " + message.toString()); 148 | 149 | if (topic.toString() === prefix && message.toString() == "HELLO" ){ 150 | console.log('HELLO detected'); 151 | pubConfig(); 152 | } 153 | pubStatus(); 154 | 155 | }) 156 | //////////////////////////////////////////////// 157 | function pubConfig() { 158 | config.forEach(function(item, i, arr) { 159 | client.publish(prefix + "/" + deviceID + "/config", JSON.stringify(item),{ qos : 1 }); 160 | }); 161 | } 162 | //////////////////////////////////////////////// 163 | function pubStatus() { 164 | var outdoor = 10 + Math.round(Math.random() * 5); 165 | var indoor = 18 + Math.round(Math.random() * 5); 166 | var hum = 60 - Math.round(Math.random() * 30); 167 | var health = 'normal'; 168 | if (hum < 40 || indoor < 20) { 169 | health = 'not good'; 170 | } 171 | client.publish( config[1].topic+"/status", JSON.stringify({ status: outdoor + "°C" }) ); 172 | client.publish( config[2].topic+"/status", JSON.stringify({ status: indoor + "°C" }) ); 173 | client.publish( config[3].topic+"/status", JSON.stringify({ status: hum + "%" }) ); 174 | client.publish( config[4].topic+"/status", JSON.stringify({ status: health }) ); 175 | console.log('Publish outdoor:' + outdoor + ' indoor:' + indoor + ' hum:' + hum); 176 | } 177 | //////////////////////////////////////////////// 178 | // run main 179 | console.log('Start'); 180 | 181 | -------------------------------------------------------------------------------- /node.js/official-demo/joystick-btn.js: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////// 2 | // 3 | // !Not worked, in development now! Demo device emulator for "joystick-btn" widget 4 | // 5 | // 6 | // 7 | // IoT Manager https://play.google.com/store/apps/details?id=ru.esp8266.iotmanager 8 | // 9 | // version : 1.0 10 | // IoT Manager : 1.4.12 and above 11 | // 12 | //////////////////////////////////////////////// 13 | 14 | //////////////////////////////////////////////// 15 | var config = require("./config"); 16 | var host = config.host; 17 | var port = config.port; 18 | var user = config.user; 19 | var pass = config.pass; 20 | var prefix = config.prefix; 21 | //////////////////////////////////////////////// 22 | 23 | var mqtt = require('mqtt'); 24 | var opt = { 25 | host : host, 26 | port : port, 27 | username : user, 28 | password : pass, 29 | clientId : 'mqttjs_' + Math.random().toString(16).substr(2, 8), 30 | protocolId : 'MQTT', 31 | connectTimeout: 3000 32 | }; 33 | 34 | var deviceID = "uniqueId-0002"; 35 | 36 | var widget = "joystick-btnXY"; 37 | 38 | var config1 = { 39 | id : "1", 40 | widget : widget, 41 | class1 : "item no-border no-padding", 42 | style1 : "", 43 | descr : "GamePad", 44 | class2 : "text-center balanced", 45 | style2 : "font-size:20px;font-weight:bold;", 46 | topic : prefix + "/" + deviceID + "/" + widget, 47 | class3 : "text-center", 48 | style3 : "", 49 | widgetConfig : { 50 | fill : "#DDE1DD", 51 | fillPressed : "#101010", 52 | arrow : "#4990E2", 53 | arrowPressed : "#A6CAF3", 54 | delay : 200 55 | } 56 | }; 57 | 58 | 59 | var client = mqtt.connect(opt); 60 | 61 | client.on('connect', function () { 62 | console.log('Broker connected'); 63 | client.subscribe(prefix, { qos : 1 }); 64 | client.subscribe(prefix + "/" + deviceID + "/" + widget + "/control",{ qos : 1 }); 65 | pubConfig(); 66 | }); 67 | 68 | client.on('error', function () { 69 | console.log('error'); 70 | }); 71 | 72 | client.on('offline', function () { 73 | console.log('offline'); 74 | }); 75 | 76 | client.on('message', function (topic, message) { 77 | if (topic.toString() === prefix && message.toString() == "HELLO" ){ 78 | console.log('HELLO detected'); 79 | pubConfig(); 80 | } else { 81 | console.log("msg: " + topic.toString() + " => " + message.toString()); 82 | } 83 | }); 84 | 85 | console.log('Start'); 86 | pubConfig(); 87 | 88 | //////////////////////////////////////////////// 89 | function pubConfig() { 90 | client.publish( prefix, deviceID ); 91 | client.publish(prefix + "/" + deviceID + "/config", JSON.stringify(config1),{ qos : 1 }); 92 | } 93 | //////////////////////////////////////////////// 94 | -------------------------------------------------------------------------------- /node.js/official-demo/linear.js: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////// 2 | // 3 | // Demo device emulator for "steel" widget (linear) 4 | // 5 | // 6 | // IoT Manager https://play.google.com/store/apps/details?id=ru.esp8266.iotmanager 7 | // 8 | // version : 1.1 9 | // IoT Manager : 1.5.0 and above 10 | // 11 | //////////////////////////////////////////////// 12 | 13 | //////////////////////////////////////////////// 14 | var config = require("./config"); 15 | var host = config.host; 16 | var port = config.port; 17 | var user = config.user; 18 | var pass = config.pass; 19 | var prefix = config.prefix; 20 | var deviceID = "nodejs_emulator" 21 | //////////////////////////////////////////////// 22 | 23 | var mqtt = require('mqtt'); 24 | var opt = { 25 | host : host, 26 | port : port, 27 | username : user, 28 | password : pass, 29 | clientId : 'mqttjs_' + Math.random().toString(16).substr(2, 8), 30 | protocolId : 'MQTT', 31 | connectTimeout: 3000 32 | }; 33 | 34 | var config1 = { 35 | id :"1", 36 | pageId : 1, 37 | page : "1", 38 | descr :"Steel 1", 39 | widget :"steel", 40 | topic :prefix + "/" + deviceID + "/steel1", 41 | widgetConfig : { 42 | width : "auto", 43 | height : 100, 44 | type : "Linear", 45 | titleString: "Thermometer 1", 46 | unitString: "temp C", 47 | threshold: 90 48 | } 49 | }; 50 | 51 | var config2 = { 52 | id :"2", 53 | pageId : 1, 54 | page : "1", 55 | descr : "Steel 2", 56 | widget : "steel", 57 | topic : prefix + "/" + deviceID + "/steel2", 58 | widgetConfig : { 59 | width : "auto", 60 | height : 140, 61 | type : "Linear", 62 | gaugeType : "TYPE2", 63 | titleString : "Thermometer 2", 64 | unitString : "Unit", 65 | threshold : 70, 66 | lcdVisible : true, 67 | lcdDecimals : 0, 68 | // optional parameters 69 | FrameDesign : "STEEL", // BLACK_METAL METAL SHINY_METAL BRASS STEEL CHROME GOLD ANTHRACITE TILTED_GRAY TILTED_BLACK GLOSSY_METAL 70 | BackgroundColor: "CARBON", // DARK_GRAY SATIN_GRAY LIGHT_GRAY WHITE BLACK BEIGE BROWN RED GREEN BLUE ANTHRACITE MUD PUNCHED_SHEET CARBON STAINLESS BRUSHED_METAL BRUSHED_STAINLESS TURNED 71 | ColorDef : "RAITH", // RED GREEN BLUE ORANGE YELLOW CYAN MAGENTA WHITE GRAY BLACK RAITH GREEN_LCD JUG_GREEN 72 | LcdColor : "RED_DARKRED", // BEIGE BLUE ORANGE RED YELLOW WHITE GRAY BLACK GREEN BLUE2 BLUE_BLACK BLUE_DARKBLUE BLUE_GRAY STANDARD STANDARD_GREEN BLUE_BLUE RED_DARKRED DARKBLUE LILA BLACKRED DARKGREEN AMBER LIGHTBLUE SECTIONS 73 | LedColor : "MAGENTA_LED", // RED_LED GREEN_LED BLUE_LED ORANGE_LED YELLOW_LED CYAN_LED MAGENTA_LED 74 | } 75 | }; 76 | 77 | var config3 = { 78 | id :"3", 79 | pageId : 2, 80 | page : "2", 81 | descr : "Steel 3", 82 | widget : "steel", 83 | topic : prefix + "/" + deviceID + "/steel3", 84 | widgetConfig : { 85 | width : "auto", 86 | height : 140, 87 | type : "LinearBargraph", 88 | titleString : "Gradient Colors", 89 | unitString : "Unit", 90 | threshold : 30, 91 | useValueGradient: true, 92 | 93 | // optional parameters 94 | FrameDesign : "CHROME", // BLACK_METAL METAL SHINY_METAL BRASS STEEL CHROME GOLD ANTHRACITE TILTED_GRAY TILTED_BLACK GLOSSY_METAL 95 | BackgroundColor: "TURNED", // DARK_GRAY SATIN_GRAY LIGHT_GRAY WHITE BLACK BEIGE BROWN RED GREEN BLUE ANTHRACITE MUD PUNCHED_SHEET CARBON STAINLESS BRUSHED_METAL BRUSHED_STAINLESS TURNED 96 | ColorDef : "ORANGE", // RED GREEN BLUE ORANGE YELLOW CYAN MAGENTA WHITE GRAY BLACK RAITH GREEN_LCD JUG_GREEN 97 | LcdColor : "BLUE_BLUE", // BEIGE BLUE ORANGE RED YELLOW WHITE GRAY BLACK GREEN BLUE2 BLUE_BLACK BLUE_DARKBLUE BLUE_GRAY STANDARD STANDARD_GREEN BLUE_BLUE RED_DARKRED DARKBLUE LILA BLACKRED DARKGREEN AMBER LIGHTBLUE SECTIONS 98 | LedColor : "ORANGE_LED", // RED_LED GREEN_LED BLUE_LED ORANGE_LED YELLOW_LED CYAN_LED MAGENTA_LED 99 | } 100 | }; 101 | 102 | var config4 = { 103 | id :"4", 104 | pageId : 3, 105 | page : "3", 106 | descr : "Steel 4", 107 | widget : "steel", 108 | topic : prefix + "/" + deviceID + "/steel4", 109 | style1 : "float:left;", 110 | widgetConfig : { 111 | width : "auto2", 112 | height : 100, 113 | type : "Linear", 114 | frameVisible: false, 115 | minMeasuredValueVisible : true, 116 | maxMeasuredValueVisible : true, 117 | minValue : -50, 118 | maxValue : 50, 119 | thresholdVisible : false 120 | } 121 | }; 122 | 123 | var config5 = { 124 | id :"5", 125 | pageId : 3, 126 | page : "3", 127 | descr : "Steel 5", 128 | widget : "steel", 129 | topic : prefix + "/" + deviceID + "/steel5", 130 | style1 : "float:right;", 131 | widgetConfig : { 132 | width : "auto2", 133 | height : 100, 134 | type : "Linear", 135 | frameVisible: false 136 | } 137 | }; 138 | 139 | var temp = 0; 140 | var temp2 = 0; 141 | var temp3 = 0; 142 | var temp4 = 0; 143 | var temp5 = 0; 144 | 145 | var client = mqtt.connect(opt); 146 | 147 | client.on('connect', function () { 148 | console.log('Broker connected'); 149 | client.subscribe(prefix); 150 | pubConfig(); 151 | }); 152 | 153 | client.on('error', function () { 154 | console.log('error'); 155 | }); 156 | 157 | client.on('offline', function () { 158 | console.log('offline'); 159 | }); 160 | 161 | client.on('message', function (topic, message) { 162 | if (topic.toString() == prefix && message.toString() == "HELLO" ){ 163 | console.log('HELLO detected'); 164 | pubConfig(); 165 | } 166 | }); 167 | 168 | console.log('Start'); 169 | setInterval(function() { 170 | temp = Math.round(Math.random() * 100); 171 | temp2 = Math.round(Math.random() * 100); 172 | temp3 = Math.round(Math.random() * 100); 173 | temp4 = Math.round(Math.random() * 50); 174 | temp5 = Math.round(Math.random() * 50); 175 | pubStatus1(); 176 | 177 | }, 5000); 178 | //////////////////////////////////////////////// 179 | function pubConfig() { 180 | client.publish(prefix + "/" + deviceID + '/config', JSON.stringify(config1)); 181 | client.publish(prefix + "/" + deviceID + '/config', JSON.stringify(config2)); 182 | client.publish(prefix + "/" + deviceID + '/config', JSON.stringify(config3)); 183 | client.publish(prefix + "/" + deviceID + '/config', JSON.stringify(config4)); 184 | client.publish(prefix + "/" + deviceID + '/config', JSON.stringify(config5)); 185 | console.log('pubConfig'); 186 | } 187 | //////////////////////////////////////////////// 188 | 189 | function pubStatus1() { 190 | console.log("Send status"); 191 | client.publish(config1.topic + '/status', JSON.stringify({ status: temp })); 192 | client.publish(config2.topic + '/status', JSON.stringify({ status: temp2 })); 193 | client.publish(config3.topic + '/status', JSON.stringify({ status: temp3 })); 194 | client.publish(config4.topic + '/status', JSON.stringify({ status: temp4 })); 195 | client.publish(config5.topic + '/status', JSON.stringify({ status: temp5 })); 196 | } 197 | -------------------------------------------------------------------------------- /node.js/official-demo/markdown.js: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////// 2 | // 3 | // Markdown to HTML converter demo (markdown widget) 4 | // 5 | // 6 | // IoT Manager https://play.google.com/store/apps/details?id=ru.esp8266.iotmanager 7 | // 8 | // version : 1.0 9 | // IoT Manager : 1.5.4 and above 10 | // 11 | //////////////////////////////////////////////// 12 | 13 | //////////////////////////////////////////////// 14 | var config = require("./config"); 15 | var host = config.host; 16 | var port = config.port; 17 | var user = config.user; 18 | var pass = config.pass; 19 | //////////////////////////////////////////////// 20 | 21 | var mqtt = require('mqtt'); 22 | var opt = { 23 | host : host, 24 | port : port, 25 | username : user, 26 | password : pass, 27 | clientId : 'mqtt-js_' + Math.random().toString(16).substr(2, 8), 28 | protocolId : 'MQTT', 29 | connectTimeout: 3000 30 | }; 31 | 32 | 33 | var deviceID = "device10"; 34 | var prefix = "/IoTmanager"; 35 | var config = []; 36 | var client = mqtt.connect(opt); 37 | 38 | // First line 39 | var widget = "anydata"; 40 | var id = "0" 41 | 42 | widget = "markdown"; 43 | id = "0" 44 | config[0] = { 45 | id : id, 46 | widget : widget, 47 | topic : prefix + "/" + deviceID + "/" + widget + id, 48 | class1 : "padding" 49 | }; 50 | 51 | client.on('connect', function () { 52 | console.log('Broker connected'); 53 | client.subscribe(prefix, { qos : 1 }); // HELLO expected 54 | pubConfig(); 55 | }); 56 | 57 | client.on('error', function () { 58 | console.log('Broker error'); 59 | }); 60 | 61 | client.on('offline', function () { 62 | console.log('Broker offline'); 63 | }); 64 | 65 | client.on('message', function (topic, message) { 66 | 67 | console.log("Message arrived: " + topic.toString() + " => " + message.toString()); 68 | 69 | if (topic.toString() === prefix && message.toString() == "HELLO" ){ 70 | console.log('HELLO detected'); 71 | pubConfig(); 72 | } 73 | pubStatus(); 74 | 75 | }) 76 | //////////////////////////////////////////////// 77 | function pubConfig() { 78 | config.forEach(function(item, i, arr) { 79 | client.publish(prefix + "/" + deviceID + "/config", JSON.stringify(item),{ qos : 1 }); 80 | }); 81 | } 82 | //////////////////////////////////////////////// 83 | function pubStatus() { 84 | 85 | var x = 10 + Math.round(Math.random() * 10); 86 | var y = 100 + Math.round(Math.random() * 100); 87 | var z = 1000 + Math.round(Math.random() * 1000); 88 | var z1= 1000 + Math.round(Math.random() * 5000); 89 | var text = '\n'; 90 | text += '\n__Sensor1 ' + x + '__'; 91 | text += '\n~~Sensor2 ' + y + '~~'; 92 | text += '\n**Sensor3 ' + z + '**'; 93 | text += '\n*Sensor4 ' + z1+ '*'; 94 | text += '\n'; 95 | text += '\n| Tables | Are | Cool |'; 96 | text += '\n| -------- |:-------------:|------:|'; 97 | text += '\n| col 2 | centered |'+x+'|'; 98 | text += '\n| col 3 | **right** |'+y+'|'; 99 | text += '\n| col 1 | ~~left~~ |'+z+'|'; 100 | text += '\n| | 4 |'+z1+'|'; 101 | text += '\n'; 102 | text += '\n# Sensor 1: '+x; 103 | text += '\n## Sensor 2: '+y; 104 | text += '\n### Sensor 3: '+z; 105 | text += '\n#### Sensor 4: '+z1; 106 | text += '\n'; 107 | client.publish( config[0].topic+"/status", JSON.stringify({ status: text }) ); 108 | 109 | console.log('Publish'); 110 | } 111 | //////////////////////////////////////////////// 112 | // run main 113 | console.log('Start'); 114 | 115 | setInterval(function() { 116 | pubStatus(); 117 | }, 5000); 118 | -------------------------------------------------------------------------------- /node.js/official-demo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "iotm-demo-client", 3 | "version": "1.1.0", 4 | "description": "IoTmanager demo client", 5 | "contributors": [ 6 | { 7 | "name": "Victor Brutskiy", 8 | "email": "4refr0nt@gmail.com" 9 | } 10 | ], 11 | "license": "MIT", 12 | "dependencies": { 13 | "mqtt": "^2.0.1" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /node.js/official-demo/simple-btn.js: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////// 2 | // 3 | // Demo device emulator for "simple-btn" widget 4 | // 5 | // 6 | // 7 | // IoT Manager https://play.google.com/store/apps/details?id=ru.esp8266.iotmanager 8 | // 9 | // version : 1.0 10 | // IoT Manager : 1.4.7 and above 11 | // 12 | //////////////////////////////////////////////// 13 | 14 | //////////////////////////////////////////////// 15 | var config = require("./config"); 16 | var host = config.host; 17 | var port = config.port; 18 | var user = config.user; 19 | var pass = config.pass; 20 | //////////////////////////////////////////////// 21 | 22 | var mqtt = require('mqtt'); 23 | var opt = { 24 | host : host, 25 | port : port, 26 | username : user, 27 | password : pass, 28 | clientId : 'mqttjs_' + Math.random().toString(16).substr(2, 8), 29 | protocolId : 'MQTT', 30 | connectTimeout: 3000 31 | }; 32 | 33 | var deviceID = "uniqueId-0002"; 34 | var prefix = "/IoTmanager"; 35 | var config = []; 36 | var widget = "simple-btn"; 37 | 38 | var id = "0" 39 | config[0] = { 40 | id : id, 41 | page : "b1", 42 | pageId : 1, 43 | pageTopic : prefix + "/page1", 44 | widget : widget, 45 | class1 : "item no-border no-padding-bottom", 46 | descr : "Fab button with any colors", 47 | class2 : "balanced padding-top", 48 | style2 : "float:left;font-size:16px;", 49 | topic : prefix + "/" + deviceID + "/" + widget + id, 50 | class3 : "button button-fab icon ion-bug", 51 | style3 : "float:right;", 52 | widgetConfig : { 53 | fill : "#724200", // You can use any HTML colors 54 | fillPressed : "#004333", 55 | label : "#4990E2", 56 | labelPressed : "#FF0000" 57 | } 58 | }; 59 | 60 | id = "1" 61 | config[1] = { 62 | id : id, 63 | page : "b1", 64 | pageId : 1, 65 | widget : widget, 66 | class1 : "item no-border no-padding-bottom", 67 | descr : "Another fab button", 68 | class2 : "assertive padding-top", 69 | style2 : "float:left;font-weight:bold;", 70 | topic : prefix + "/" + deviceID + "/" + widget + id, 71 | class3 : "button button-assertive button-fab icon ion-heart", 72 | style3 : "float:right;" 73 | }; 74 | 75 | id = "2" 76 | config[2] = { 77 | id : id, 78 | page : "b2", 79 | pageId : 2, 80 | widget : widget, 81 | class1 : "col-xs-2 text-center", 82 | descr : "Left", 83 | class2 : "calm", 84 | topic : prefix + "/" + deviceID + "/" + widget + id, 85 | class3 : "button button-calm button-fab icon ion-arrow-left-a" 86 | }; 87 | 88 | id = "3" 89 | config[3] = { 90 | id : id, 91 | page : "b2", 92 | pageId : 2, 93 | widget : widget, 94 | class1 : "col-xs-3 text-center", 95 | descr : "Right", 96 | class2 : "calm", 97 | topic : prefix + "/" + deviceID + "/" + widget + id, 98 | class3 : "button button-calm button-fab icon ion-arrow-right-a" 99 | }; 100 | 101 | id = "4" 102 | config[4] = { 103 | id : id, 104 | page : "b2", 105 | pageId : 2, 106 | widget : widget, 107 | class1 : "col-xs-3 text-center", 108 | descr : "Up", 109 | class2 : "balanced", 110 | topic : prefix + "/" + deviceID + "/" + widget + id, 111 | class3 : "button button-balanced button-fab icon ion-arrow-up-c" 112 | }; 113 | 114 | id = "5" 115 | config[5] = { 116 | id : id, 117 | page : "b2", 118 | pageId : 2, 119 | widget : widget, 120 | class1 : "text-center padding-right", 121 | style1 : "float:right;", 122 | descr : "Down", 123 | class2 : "balanced", 124 | topic : prefix + "/" + deviceID + "/" + widget + id, 125 | class3 : "button button-balanced button-fab icon ion-arrow-down-c" 126 | }; 127 | 128 | id = "6" 129 | config[6] = { 130 | id : id, 131 | page : "b3", 132 | pageId : 3, 133 | widget : widget, 134 | class1 : "text-center padding-left padding-right", 135 | topic : prefix + "/" + deviceID + "/" + widget + id, 136 | class3 : "button button-energized button-block icon-left ion-arrow-shrink", 137 | style3 : "", 138 | widgetConfig : { 139 | title : "button-block" 140 | } 141 | }; 142 | 143 | id = "7" 144 | config[7] = { 145 | id : id, 146 | page : "b3", 147 | pageId : 3, 148 | widget : widget, 149 | class1 : "col-xs-3", 150 | style1 : "", 151 | descr : "", 152 | class2 : "", 153 | style2 : "", 154 | topic : prefix + "/" + deviceID + "/" + widget + id, 155 | class3 : "button button-royal button-small", 156 | style3 : "", 157 | widgetConfig : { 158 | title : "small" 159 | } 160 | }; 161 | 162 | id = "8" 163 | config[8] = { 164 | id : id, 165 | page : "b3", 166 | pageId : 3, 167 | widget : widget, 168 | class1 : "col-xs-3 col-xs-offset-1", 169 | style1 : "", 170 | descr : "", 171 | class2 : "", 172 | style2 : "", 173 | topic : prefix + "/" + deviceID + "/" + widget + id, 174 | class3 : "button button-positive", 175 | style3 : "", 176 | widgetConfig : { 177 | title : "button" 178 | } 179 | }; 180 | 181 | id = "9" 182 | config[9] = { 183 | id : id, 184 | page : "b3", 185 | pageId : 3, 186 | widget : widget, 187 | class1 : "col-xs-3 col-xs-offset-1", 188 | topic : prefix + "/" + deviceID + "/" + widget + id, 189 | class3 : "button button-large button-balanced", 190 | style3 : "", 191 | widgetConfig : { 192 | title : "large" 193 | } 194 | }; 195 | 196 | id = "10" 197 | config[10] = { 198 | id : id, 199 | page : "b3", 200 | pageId : 3, 201 | widget : widget, 202 | class1 : "padding-left", 203 | style1 : "float:left;", 204 | descr : "", 205 | class2 : "", 206 | style2 : "", 207 | topic : prefix + "/" + deviceID + "/" + widget + id, 208 | class3 : "button button-calm button-outline", 209 | style3 : "", 210 | widgetConfig : { 211 | title : "outline" 212 | } 213 | }; 214 | 215 | id = "11" 216 | config[11] = { 217 | id : id, 218 | page : "b3", 219 | pageId : 3, 220 | widget : widget, 221 | style1 : "float:right;", 222 | topic : prefix + "/" + deviceID + "/" + widget + id, 223 | class3 : "button button-light button-clear icon-right ion-toggle", 224 | style3 : "", 225 | widgetConfig : { 226 | title : "clear" 227 | } 228 | }; 229 | 230 | id = "12" 231 | config[12] = { 232 | id : id, 233 | page : "b4", 234 | pageId : 4, 235 | widget : widget, 236 | class1 : "item no-border padding-top", 237 | descr : "Try long-touch", 238 | class2 : "energized padding-top", 239 | style2 : "float:left;font-size:20px;", 240 | topic : prefix + "/" + deviceID + "/" + widget + id, 241 | class3 : "button button-energized icon ion-alert-circled", 242 | style3 : "float:right;", 243 | widgetConfig : { 244 | delay : 200 245 | } 246 | }; 247 | 248 | id = "13" 249 | config[13] = { 250 | id : id, 251 | page : "b4", 252 | pageId : 4, 253 | widget : widget, 254 | class1 : "text-center", 255 | topic : prefix + "/" + deviceID + "/" + widget + id, 256 | class3 : "button button-calm button-block icon-right ion-earth", 257 | style3 : "", 258 | widgetConfig : { 259 | title : "Send custom data", 260 | data : "any usefull data" 261 | } 262 | }; 263 | 264 | 265 | var client = mqtt.connect(opt); 266 | 267 | client.on('connect', function () { 268 | console.log('Broker connected'); 269 | client.subscribe(prefix, { qos : 1 }); // only HELLO expected 270 | pubConfig(); 271 | }); 272 | 273 | client.on('error', function () { 274 | console.log('error'); 275 | }); 276 | 277 | client.on('offline', function () { 278 | console.log('offline'); 279 | }); 280 | 281 | client.on('message', function (topic, message) { 282 | if (topic.toString() === prefix && message.toString() == "HELLO" ){ 283 | console.log('HELLO detected'); 284 | pubConfig(); 285 | } else { 286 | console.log("msg: " + topic.toString() + " => " + message.toString()); 287 | } 288 | }); 289 | 290 | console.log('Start'); 291 | pubConfig(); 292 | 293 | //////////////////////////////////////////////// 294 | function pubConfig() { 295 | client.publish( prefix, deviceID ); 296 | config.forEach(function(item, i, arr) { 297 | client.publish(prefix + "/" + deviceID + "/config", JSON.stringify(item),{ qos : 1 }); 298 | }); 299 | } 300 | //////////////////////////////////////////////// 301 | -------------------------------------------------------------------------------- /node.js/official-demo/speech.js: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////// 2 | // 3 | // Demo for text2speech feature 4 | // 5 | // 6 | // IoT Manager https://play.google.com/store/apps/details?id=ru.esp8266.iotmanager 7 | // 8 | // version : 1.0 9 | // IoT Manager : 1.5.4 and above 10 | // 11 | //////////////////////////////////////////////// 12 | 13 | //////////////////////////////////////////////// 14 | var config = require("./config"); 15 | var host = config.host; 16 | var port = config.port; 17 | var user = config.user; 18 | var pass = config.pass; 19 | //////////////////////////////////////////////// 20 | 21 | var mqtt = require('mqtt'); 22 | var opt = { 23 | host : host, 24 | port : port, 25 | username : user, 26 | password : pass, 27 | clientId : 'mqtt-js_' + Math.random().toString(16).substr(2, 8), 28 | protocolId : 'MQTT', 29 | connectTimeout: 3000 30 | }; 31 | 32 | 33 | var deviceID = "device10"; 34 | var prefix = "/IoTmanager"; 35 | var config = []; 36 | var client = mqtt.connect(opt); 37 | 38 | // First line 39 | var widget = "anydata"; 40 | var id = "0" 41 | 42 | widget = "chart"; 43 | id = "0" 44 | config[0] = { 45 | id : id, 46 | widget : widget, 47 | topic : prefix + "/" + deviceID + "/" + widget + id, 48 | widgetConfig: { 49 | type: 'line', // line, bar, horizontalBar, radar, polarArea, doughnut, pie, bubble 50 | maxCount: 20 51 | } 52 | }; 53 | 54 | client.on('connect', function () { 55 | console.log('Broker connected'); 56 | client.subscribe(prefix, { qos : 1 }); // HELLO expected 57 | pubConfig(); 58 | }); 59 | 60 | client.on('error', function () { 61 | console.log('Broker error'); 62 | }); 63 | 64 | client.on('offline', function () { 65 | console.log('Broker offline'); 66 | }); 67 | 68 | client.on('message', function (topic, message) { 69 | 70 | console.log("Message arrived: " + topic.toString() + " => " + message.toString()); 71 | 72 | if (topic.toString() === prefix && message.toString() == "HELLO" ){ 73 | console.log('HELLO detected'); 74 | pubConfig(); 75 | } 76 | pubStatus(); 77 | 78 | }) 79 | //////////////////////////////////////////////// 80 | function pubConfig() { 81 | config.forEach(function(item, i, arr) { 82 | client.publish(prefix + "/" + deviceID + "/config", JSON.stringify(item),{ qos : 1 }); 83 | }); 84 | } 85 | //////////////////////////////////////////////// 86 | function pubStatus() { 87 | 88 | var x = 20 + Math.round(Math.random() * 4); 89 | // text = 'hello'; 90 | text = 'Outside temperature ' + x.toString(); 91 | client.publish( config[0].topic+"/status", JSON.stringify({ status: x, speech: text }) ); 92 | 93 | console.log('Publish'); 94 | } 95 | //////////////////////////////////////////////// 96 | // run main 97 | console.log('Start'); 98 | 99 | setInterval(function() { 100 | pubStatus(); 101 | }, 10000); 102 | -------------------------------------------------------------------------------- /node.js/official-demo/toggle.js: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////// 2 | // 3 | // Demo device emulator for "toggle" widget 4 | // 5 | // 6 | // IoT Manager https://play.google.com/store/apps/details?id=ru.esp8266.iotmanager 7 | // 8 | // version : 1.2 9 | // IoT Manager : 1.4.11 and above 10 | // 11 | //////////////////////////////////////////////// 12 | 13 | //////////////////////////////////////////////// 14 | var config = require("./config"); 15 | var host = config.host; 16 | var port = config.port; 17 | var user = config.user; 18 | var pass = config.pass; 19 | var prefix = config.prefix; 20 | var deviceID = "nodejs_emulator" 21 | //////////////////////////////////////////////// 22 | 23 | var mqtt = require('mqtt'); 24 | var opt = { 25 | host : host, 26 | port : port, 27 | username : user, 28 | password : pass, 29 | clientId : 'mqttjs_' + Math.random().toString(16).substr(2, 8), 30 | protocolId : 'MQTT', 31 | connectTimeout: 3000 32 | }; 33 | 34 | var config1 = { 35 | // min config: green track background without icon, status not visible 36 | id :"1", 37 | descr : "Light 1", 38 | widget : "toggle", 39 | topic : prefix + "/" + deviceID + "/light1" 40 | }; 41 | var config2 = { 42 | // old-style config with colored icon at left and colored background for ON state 43 | id :"2", 44 | page :"bathroom", 45 | pageId :"2", 46 | descr :"Light 2", 47 | widget :"toggle", 48 | topic :prefix + "/" + deviceID + "/light2", 49 | color :"orange" // also, you can use any HTML color code 50 | }; 51 | var config3 = { 52 | // config with colored description and colored icon 53 | id :"3", 54 | page :"bathroom", 55 | pageId :"2", 56 | descr :"Light 3", 57 | widget :"toggle", 58 | topic :prefix + "/" + deviceID + "/light3", 59 | color : "#00FF00", 60 | descrStyle : "color:#FFFF00" 61 | }; 62 | var config4 = { 63 | // config without icon at left 64 | id :"4", 65 | page :"bathroom", 66 | pageId :"2", 67 | descr :"Outdoor light", 68 | widget :"toggle", 69 | topic :prefix+ "/" + deviceID + "/light4", 70 | iconClass : "ion-ios-lightbulb", 71 | iconClassOff: "ion-ios-lightbulb-outline", 72 | iconStyle : "font-size:30px;color:#F2CD1F;", 73 | iconStyleOff: "font-size:30px;color:#eee;", 74 | descrStyle : "font-size:20px;line-height:1.5em;" 75 | }; 76 | var config5 = { 77 | // config with colored custom icons and big size description 78 | id :"5", 79 | page :"bathroom", 80 | pageId :"2", 81 | descr :"Light 5", 82 | widget :"toggle", 83 | topic :prefix + "/" + deviceID + "/light5", 84 | iconClass : "ion-battery-charging", 85 | iconClassOff: "ion-battery-low", 86 | iconStyle : "font-size:30px;color:#4cd964;", 87 | iconStyleOff: "font-size:30px;color:red;", 88 | descrStyle : "font-size:20px;line-height:1.5em;" 89 | }; 90 | var config6 = { 91 | // config with custom style description, track and handle 92 | id :"6", 93 | page :"bathroom", 94 | pageId :"2", 95 | descr :"Light 6", 96 | widget :"toggle", 97 | class1 : "", 98 | topic :prefix + "/" + deviceID + "/light6", 99 | descrClass :"balanced-900 text-center", 100 | descrStyle :"background-color:#0F0;border:solid 2px #F00;font-size:20px;font-weight:bold;", 101 | descrStyleOff :"background-color:#0F0;border:solid 2px #000;font-size:20px;font-weight:bold;", 102 | iconStyle :"color:red;font-size:25px;", 103 | iconStyleOff :"color:black;font-size:25px;", 104 | trackStyle :"background-color:red;", 105 | trackStyleOff :"background-color:white;", 106 | handleStyle :"background-color:yellow;", 107 | handleStyleOff:"background-color:green;", 108 | }; 109 | var config7 = { 110 | id :"7", 111 | page :"bathroom", 112 | pageId :"2", 113 | descr :"Light 7", 114 | widget :"toggle", 115 | topic :prefix + "/" + deviceID + "/light7", 116 | descrStyle :"font-size:20px;line-height:1.5em;", 117 | iconStyle :"font-size:30px;color:#4cd964;", 118 | }; 119 | 120 | var client = mqtt.connect(opt); 121 | 122 | client.on('connect', function () { 123 | console.log('Broker connected'); 124 | client.subscribe(prefix+ "/" + deviceID + '/+/control'); 125 | client.subscribe(prefix); 126 | pubConfig(); 127 | }); 128 | 129 | client.on('error', function () { 130 | console.log('error'); 131 | }); 132 | 133 | client.on('offline', function () { 134 | console.log('offline'); 135 | }); 136 | 137 | client.on('message', function (topic, message) { 138 | if (topic.toString() == prefix && message.toString() == "HELLO" ){ 139 | console.log('HELLO detected'); 140 | pubConfig(); 141 | } else { 142 | console.log('message arrived'); 143 | if (topic.split("/")[4] == 'control') { 144 | console.log('Control message arrived to topic:'+topic.toString()+', payload:'+message.toString()); 145 | var status; 146 | if (message.toString() === "1") { 147 | status = { status: 1 }; 148 | } else { 149 | status = { status: 0 }; 150 | } 151 | if (topic.split("/")[4] == 'control' && topic.split("/")[3] == "light1") { 152 | client.publish(prefix + "/" + deviceID + '/light1/status',JSON.stringify(status)); 153 | } 154 | if (topic.split("/")[4] == 'control' && topic.split("/")[3] == "light2") { 155 | client.publish(prefix + "/" + deviceID + '/light2/status',JSON.stringify(status)); 156 | } 157 | if (topic.split("/")[4] == 'control' && topic.split("/")[3] == "light3") { 158 | client.publish(prefix + "/" + deviceID + '/light3/status',JSON.stringify(status)); 159 | } 160 | if (topic.split("/")[4] == 'control' && topic.split("/")[3] == "light4") { 161 | client.publish(prefix + "/" + deviceID + '/light4/status',JSON.stringify(status)); 162 | } 163 | if (topic.split("/")[4] == 'control' && topic.split("/")[3] == "light5") { 164 | client.publish(prefix + "/" + deviceID + '/light5/status',JSON.stringify(status)); 165 | } 166 | if (topic.split("/")[4] == 'control' && topic.split("/")[3] == "light6") { 167 | client.publish(prefix + "/" + deviceID + '/light6/status',JSON.stringify(status)); 168 | } 169 | if (topic.split("/")[4] == 'control' && topic.split("/")[3] == "light7") { 170 | client.publish(prefix + "/" + deviceID + '/light7/status',JSON.stringify(status)); 171 | } 172 | console.log("Status (echo) published: " + JSON.stringify(status)); 173 | } else { 174 | console.log('Message arrived to topic:'+topic.toString()+', payload:'+message.toString()); 175 | } 176 | } 177 | }); 178 | 179 | console.log('Start'); 180 | //////////////////////////////////////////////// 181 | function pubConfig() { 182 | client.publish(prefix + "/" + deviceID + '/config', JSON.stringify(config1)); 183 | client.publish(prefix + "/" + deviceID + '/config', JSON.stringify(config2)); 184 | client.publish(prefix + "/" + deviceID + '/config', JSON.stringify(config3)); 185 | client.publish(prefix + "/" + deviceID + '/config', JSON.stringify(config4)); 186 | client.publish(prefix + "/" + deviceID + '/config', JSON.stringify(config5)); 187 | client.publish(prefix + "/" + deviceID + '/config', JSON.stringify(config6)); 188 | client.publish(prefix + "/" + deviceID + '/config', JSON.stringify(config7)); 189 | console.log('pubConfig:'+prefix + "/" + deviceID + '/config', JSON.stringify(config1)); 190 | } 191 | //////////////////////////////////////////////// 192 | 193 | 194 | -------------------------------------------------------------------------------- /node.js/official-demo/v2/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /node.js/official-demo/v2/README.md: -------------------------------------------------------------------------------- 1 | 2 | ### Demo client for IoT Manager 3 | 4 | ======= 5 | 6 | ## Install & Run 7 | 8 | Edit demo1.js and set connection (mqtt host, port, user and pass), then run 9 | 10 | ``` 11 | npm i 12 | node demo1.js 13 | ``` 14 | 15 | ## Valid messages for manual testing 16 | 17 | * publish to topic `/IoTmanager/mobile_id/request` payload `{ "command": "getPages", "param":"" }` 18 | * publish to topic `/IoTmanager/mobile_id/request` payload `{ "command": "getPageById", "param":20 }` where `20` - pageId (may be `10`,`20`,`30`,`40`) 19 | 20 | ## Where results? 21 | 22 | * `/IoTmanager/dev-0001/response` 23 | * `/IoTmanager/dev-0001/config` 24 | * `/IoTmanager/dev-0001/+/status` 25 | 26 | ## License 27 | 28 | MIT 29 | -------------------------------------------------------------------------------- /node.js/official-demo/v2/demo1.js: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////// 2 | // 3 | // IoT Manager NODE.JS demo client 4 | // version : 1.0.0 5 | // 6 | // Exchange protocol version: 2.0 7 | // 8 | //////////////////////////////////////////////// 9 | // 10 | //////////////////////////////////////////////// 11 | // 12 | // Connection 13 | // 14 | var host = 'm11.cloudmqtt.com'; 15 | var port = 10927; 16 | var user = "test"; 17 | var pass = "test"; 18 | var prefix = "/IoTmanager"; 19 | var deviceId = "dev-0001"; 20 | //////////////////////////////////////////////// 21 | 22 | var mqtt = require('mqtt'); 23 | var opt = { 24 | host: host, 25 | port: port, 26 | username: user, 27 | password: pass, 28 | clientId: 'iotm_client_' + Math.random().toString(16).substr(2, 8), 29 | protocolId: 'MQTT', 30 | connectTimeout: 3000 31 | }; 32 | 33 | var config = []; 34 | 35 | var pagesList = { 36 | pages: [ 37 | { pageId: 10, pageName: "page1" }, 38 | { pageId: 20, pageName: "page2" }, 39 | { pageId: 30, pageName: "page3" }, 40 | { pageId: 40, pageName: "page4" } 41 | ] 42 | }; 43 | 44 | // First line 45 | var widget = "anydata"; 46 | var id = "0" 47 | config[0] = { 48 | id: id, 49 | page: pagesList.pages[0].pageName, // page1 50 | pageId: pagesList.pages[0].pageId, // page1 51 | widget: widget, 52 | class1: "item no-border", 53 | style2: "font-size:16px;", 54 | topic: prefix + "/" + deviceId + "/" + widget + id, 55 | class3: "calm text-center", 56 | style3: "font-size:20px;", 57 | status: "My Home" 58 | }; 59 | 60 | // Outdoor temp 61 | widget = "anydata"; 62 | id = "1" 63 | config[1] = { 64 | id: id, 65 | page: pagesList.pages[1].pageName, // page2 66 | pageId: pagesList.pages[1].pageId, // page2 67 | widget: widget, 68 | class1: "item no-border", 69 | style2: "font-size:20px;float:left", 70 | descr: "Outdoor temp", 71 | topic: prefix + "/" + deviceId + "/" + widget + id, 72 | class3: "assertive", 73 | style3: "font-size:40px;font-weight:bold;float:right", 74 | }; 75 | 76 | // Indoor temp 77 | widget = "anydata"; 78 | id = "2" 79 | config[2] = { 80 | id: id, 81 | page: pagesList.pages[1].pageName, // page2 82 | pageId: pagesList.pages[1].pageId, // page2 83 | widget: widget, 84 | class1: "item no-border", 85 | style2: "font-size:20px;float:left;line-height:3em", 86 | descr: "Indoor temp", 87 | topic: prefix + "/" + deviceId + "/" + widget + id, 88 | class3: "balanced-bg light padding-left padding-right rounded", 89 | style3: "font-size:40px;font-weight:bold;float:right;line-height:1.5em", 90 | }; 91 | 92 | 93 | // Humidity 94 | widget = "anydata"; 95 | id = "3" 96 | config[3] = { 97 | id: id, 98 | page: pagesList.pages[2].pageName, // page3 99 | pageId: pagesList.pages[2].pageId, // page3 100 | widget: widget, 101 | class1: "item no-border", 102 | style2: "font-size:20px;float:left;line-height:3em", 103 | descr: "Humidity", 104 | topic: prefix + "/" + deviceId + "/" + widget + id, 105 | class3: "balanced-bg light padding-left padding-right rounded", 106 | style3: "font-size:40px;font-weight:bold;float:right;line-height:1.5em", 107 | }; 108 | 109 | // CO2 110 | widget = "anydata"; 111 | id = "4" 112 | config[4] = { 113 | id: id, 114 | page: pagesList.pages[3].pageName, // page4 115 | pageId: pagesList.pages[3].pageId, // page4 116 | widget: widget, 117 | class1: "item no-border", 118 | style2: "font-size:30px;float:left", 119 | descr: "CO2", 120 | topic: prefix + "/" + deviceId + "/" + widget + id, 121 | class3: "balanced", 122 | style3: "font-size:30px;font-weight:bold;float:right", 123 | }; 124 | 125 | var client = mqtt.connect(opt); 126 | 127 | 128 | client.on('connect', function() { 129 | console.log('mqtt: Broker connected'); 130 | 131 | //client.subscribe(prefix, { qos : 1 }); // HELLO expected (only for old devices) 132 | client.subscribe(prefix + "/+/request", { qos: 1 }); // requests from all mobile devices 133 | 134 | // client.subscribe(prefix + "/" + deviceId + "/+/control", { qos: 1 }); // all control commands for this device - compatible with old exchange protocol, but not used in this example 135 | // pubConfig(); // I'm online now! - old style 136 | pubPages(); // I'm online now! - new style 137 | }); 138 | 139 | 140 | client.on('error', function() { 141 | console.log('mqtt: Error'); 142 | }); 143 | 144 | 145 | client.on('offline', function() { 146 | console.log('mqtt: Offline'); 147 | }); 148 | 149 | 150 | client.on('message', function(topic, message) { 151 | 152 | console.log("\nMessage arrived: msg topic:" + topic.toString() + " => " + message.toString()); 153 | 154 | if (topic.toString() === prefix && message.toString() == "HELLO") { 155 | 156 | // this code never executed, because not subscribing to topic prefix - "/IoTmanager" 157 | console.log('HELLO detected'); 158 | // pubConfig(); /////////// old exchange protocol - actions not needed for exchange protocol v2 159 | } 160 | 161 | // get mobile device id - may be useful for different response to different mobile device, not used in this example 162 | var id = topic.toString().split("/")[2]; 163 | 164 | // new exchange protocol? 165 | if (topic.toString() === prefix + "/" + id + "/request") { 166 | 167 | // extract command and param 168 | var msg = JSON.parse(message.toString()); 169 | 170 | console.log('New request from IoT Manager: id="' + id + '", command="' + msg.command + '", param="' + msg.param + '"'); 171 | 172 | // response: my pages list 173 | if (msg.command === "getPages") { 174 | 175 | console.log("Command detected: getPages"); 176 | pubPages(); 177 | 178 | // response: widgets config from one page only 179 | } else if (msg.command === "getPageById" && msg.param > 0) { 180 | 181 | console.log('Command detected: "getPageById", param: "' + msg.param + '"'); 182 | 183 | 184 | pagesList.pages.forEach(function(item, i, arr) { 185 | 186 | // it is one of our pages? 187 | if (item.pageId === msg.param) { 188 | console.log('Request is for existing page "' + item.pageName + '", pageId="' + msg.param + '"'); 189 | pubPage(msg.param); 190 | } 191 | }); 192 | } else if (msg.command === "getPageById" && msg.param === 0) { 193 | console.log('Request is for All pages.'); 194 | pubPage(0); 195 | } 196 | 197 | } 198 | }) 199 | 200 | 201 | function pubPage(page) { 202 | 203 | // check all widgets and pub widgets config from requested page 204 | config.forEach(function(item, i, arr) { 205 | if (item.pageId === page || page === 0) { 206 | 207 | // pub config for one widget 208 | console.log('Action: response config widget id="' + item.id + '"'); 209 | client.publish(prefix + "/" + deviceId + "/config", JSON.stringify(item), { qos: 1 }); 210 | 211 | // pub status for one widget 212 | pubStatus(i); 213 | } 214 | }); 215 | } 216 | 217 | 218 | function pubStatus(i) { 219 | 220 | var status; 221 | 222 | if (i == 0) { 223 | // do nothing - in this example widget 0 without status 224 | return; 225 | 226 | } else if (i == 1) { 227 | 228 | status = 10 + Math.round(Math.random() * 5) + "°C"; 229 | console.log('Action: response status outdoor:' + status); 230 | 231 | } else if (i == 2) { 232 | 233 | status = 18 + Math.round(Math.random() * 5) + "°C"; 234 | console.log('Action: response status indoor:' + status); 235 | 236 | } else if (i == 3) { 237 | status = 50 + Math.round(Math.random() * 20) + "%"; 238 | console.log('Action: response status hum:' + status); 239 | 240 | } else if (i == 4) { 241 | 242 | status = "normal"; 243 | console.log('Action: response status CO2:' + status); 244 | } 245 | 246 | client.publish(config[i].topic + "/status", JSON.stringify({ status: status })); 247 | 248 | } 249 | 250 | 251 | function pubPages() { 252 | 253 | console.log('Action: Pub pages list: ' + JSON.stringify(pagesList)); 254 | client.publish(prefix + "/" + deviceId + "/response", JSON.stringify(pagesList)); 255 | } 256 | 257 | // run main 258 | console.log('Start'); 259 | -------------------------------------------------------------------------------- /node.js/official-demo/v2/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "iotm-demo-client", 3 | "version": "1.0.0", 4 | "description": "IoTmanager demo client, exchange protocol v2.0", 5 | "contributors": [ 6 | { 7 | "name": "Victor Brutskiy", 8 | "email": "4refr0nt@gmail.com" 9 | } 10 | ], 11 | "license": "MIT", 12 | "main": "demo1.js", 13 | "dependencies": { 14 | "mqtt": "^2.0.1" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /node.js/users/willey_/saver.js: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////// 2 | // User defined section 3 | var host = '192.168.122.1'; 4 | var port = 1883; 5 | var user = ""; 6 | var pass = ""; 7 | 8 | var IoTmanager = { 9 | topic: "/IoTmanager", 10 | cachefile: "/opt/test/iotcache" //куда писать кэш, файл должен существовать, в него лучше записать что-то вроде { "one":"one"} 11 | } 12 | 13 | //////////////////////////////////////////////// 14 | 15 | var opt = { 16 | host : host, 17 | port : port, 18 | username : user, 19 | password : pass, 20 | clientId : 'mqttjs_' + Math.random().toString(16).substr(2, 8), 21 | protocolId : 'MQTT', 22 | connectTimeout: 3000 23 | }; 24 | 25 | 26 | 27 | mqtt = require('mqtt'); 28 | fs = require('fs'); 29 | 30 | run(); 31 | function run() { 32 | mqttclient = mqtt.connect(opt); 33 | setTimeout(function() { 34 | cachefile = fs.readFileSync(IoTmanager.cachefile.toString()); 35 | states = JSON.parse(cachefile); 36 | console.log("Cache ready"); 37 | }, 100); 38 | setTimeout(function() { 39 | fs.writeFile(IoTmanager.cachefile.toString(), JSON.stringify(states)); 40 | }, 5000); 41 | 42 | mqttclient.on('connect', function() { 43 | console.log("Connected to MQTT server at "+opt.host+":"+opt.port); 44 | mqttclient.subscribe(IoTmanager.topic); 45 | console.log("subscribed to "+IoTmanager.topic); 46 | mqttclient.publish(IoTmanager.topic, 'HELLO'); 47 | }); 48 | 49 | mqttclient.on('close', function() { 50 | fs.writeFile(IoTmanager.cachefile.toString(), JSON.stringify(states)); 51 | console.log('mqtt closed'); 52 | }); 53 | mqttclient.on('message', function(topic, message) { 54 | if (topic.toString() == IoTmanager.topic && message.toString() == "HELLO" ){ 55 | } else if (topic.split("/").length == 1) { 56 | mqttclient.subscribe(IoTmanager.topic+"/"+message.toString()+"/config"); 57 | } else if (topic.split("/").length == 2 ) { 58 | mqttclient.subscribe(IoTmanager.topic+"/"+message.toString()+"/config"); 59 | if ( typeof states !== 'undefined' ) { 60 | if ( states[message.toString()+"_stored"] !== 'undefined' ) { 61 | Object.keys(states).forEach(function(device) { 62 | if ( device.split("_")[0] == message.toString() && device.toString() !== states[message.toString()+"_stored"] ) { 63 | setTimeout(function() { 64 | mqttclient.publish(IoTmanager.topic.toString()+"/"+message.toString()+"/"+device.split("_")[1]+"/control", states[device].toString()); 65 | }, 500); 66 | } 67 | }); 68 | } 69 | } 70 | if ( typeof states !== 'undefined' ) { fs.writeFile(IoTmanager.cachefile.toString(),JSON.stringify(states));} 71 | } else if (topic.split("/")[3] == 'config' ) { 72 | mqttclient.subscribe(JSON.parse(message.toString()).topic+'/status'); 73 | mqttclient.subscribe(JSON.parse(message.toString()).topic+'/control'); 74 | } else if (topic.split("/").length == 4 ) { 75 | } else if (topic.split("/")[4] == 'status' ) { 76 | states[topic.split("/")[2].toString()+"_stored"] = ""; 77 | states[topic.split("/")[2].toString()+"_"+topic.split("/")[3].toString()] = JSON.parse(message.toString()).status; 78 | } 79 | }); 80 | }; 81 | -------------------------------------------------------------------------------- /platformio/heater/.gitignore: -------------------------------------------------------------------------------- 1 | .pioenvs 2 | .clang_complete 3 | .gcc-flags.json 4 | .piolibdeps 5 | prebuild/temp 6 | -------------------------------------------------------------------------------- /platformio/heater/.travis.yml: -------------------------------------------------------------------------------- 1 | # Continuous Integration (CI) is the practice, in software 2 | # engineering, of merging all developer working copies with a shared mainline 3 | # several times a day < http://docs.platformio.org/en/stable/ci/index.html > 4 | # 5 | # Documentation: 6 | # 7 | # * Travis CI Embedded Builds with PlatformIO 8 | # < https://docs.travis-ci.com/user/integration/platformio/ > 9 | # 10 | # * PlatformIO integration with Travis CI 11 | # < http://docs.platformio.org/en/stable/ci/travis.html > 12 | # 13 | # * User Guide for `platformio ci` command 14 | # < http://docs.platformio.org/en/stable/userguide/cmd_ci.html > 15 | # 16 | # 17 | # Please choice one of the following templates (proposed below) and uncomment 18 | # it (remove "# " before each line) or use own configuration according to the 19 | # Travis CI documentation (see above). 20 | # 21 | 22 | 23 | # 24 | # Template #1: General project. Test it using existing `platformio.ini`. 25 | # 26 | 27 | # language: python 28 | # python: 29 | # - "2.7" 30 | # 31 | # sudo: false 32 | # cache: 33 | # directories: 34 | # - "~/.platformio" 35 | # 36 | # install: 37 | # - pip install -U platformio 38 | # 39 | # script: 40 | # - platformio run 41 | 42 | 43 | # 44 | # Template #2: The project is intended to by used as a library with examples 45 | # 46 | 47 | # language: python 48 | # python: 49 | # - "2.7" 50 | # 51 | # sudo: false 52 | # cache: 53 | # directories: 54 | # - "~/.platformio" 55 | # 56 | # env: 57 | # - PLATFORMIO_CI_SRC=path/to/test/file.c 58 | # - PLATFORMIO_CI_SRC=examples/file.ino 59 | # - PLATFORMIO_CI_SRC=path/to/test/directory 60 | # 61 | # install: 62 | # - pip install -U platformio 63 | # 64 | # script: 65 | # - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N 66 | -------------------------------------------------------------------------------- /platformio/heater/extra_script.py: -------------------------------------------------------------------------------- 1 | from subprocess import call 2 | Import("env") 3 | 4 | print "Current build targets: ", map(str, BUILD_TARGETS) 5 | print "Add build hook" 6 | call(".\prebuild\gen_h.bat") 7 | -------------------------------------------------------------------------------- /platformio/heater/lib/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for the project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link to executable file. 4 | 5 | The source code of each library should be placed in separate directory, like 6 | "lib/private_lib/[here are source files]". 7 | 8 | For example, see how can be organized `Foo` and `Bar` libraries: 9 | 10 | |--lib 11 | | |--Bar 12 | | | |--docs 13 | | | |--examples 14 | | | |--src 15 | | | |- Bar.c 16 | | | |- Bar.h 17 | | |--Foo 18 | | | |- Foo.c 19 | | | |- Foo.h 20 | | |- readme.txt --> THIS FILE 21 | |- platformio.ini 22 | |--src 23 | |- main.c 24 | 25 | Then in `src/main.c` you should use: 26 | 27 | #include 28 | #include 29 | 30 | // rest H/C/CPP code 31 | 32 | PlatformIO will find your libraries automatically, configure preprocessor's 33 | include paths and build them. 34 | 35 | More information about PlatformIO Library Dependency Finder 36 | - http://docs.platformio.org/en/stable/librarymanager/ldf.html 37 | -------------------------------------------------------------------------------- /platformio/heater/lib/widgets/line01_00.h: -------------------------------------------------------------------------------- 1 | const char line01_00_json[] = { 2 | 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x69, 0x64, 0x22, 0x20, 0x20, 0x20, 3 | 0x20, 0x20, 0x3a, 0x20, 0x22, 0x30, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 4 | 0x22, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x22, 0x20, 0x3a, 0x20, 0x22, 5 | 0x61, 0x6e, 0x79, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 6 | 0x20, 0x22, 0x70, 0x61, 0x67, 0x65, 0x22, 0x20, 0x20, 0x20, 0x3a, 0x20, 7 | 0x22, 0x48, 0x65, 0x61, 0x74, 0x65, 0x72, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 8 | 0x20, 0x22, 0x70, 0x61, 0x67, 0x65, 0x49, 0x64, 0x22, 0x20, 0x3a, 0x20, 9 | 0x31, 0x30, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x64, 0x65, 0x73, 0x63, 10 | 0x72, 0x22, 0x20, 0x20, 0x3a, 0x20, 0x22, 0x48, 0x65, 0x61, 0x74, 0x65, 11 | 0x72, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x74, 0x6f, 0x70, 0x69, 12 | 0x63, 0x22, 0x20, 0x20, 0x3a, 0x20, 0x22, 0x2f, 0x49, 0x6f, 0x54, 0x6d, 13 | 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2f, 0x68, 0x65, 0x61, 0x74, 0x65, 14 | 0x72, 0x2f, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x30, 0x30, 0x22, 0x2c, 15 | 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x31, 0x22, 16 | 0x20, 0x3a, 0x20, 0x22, 0x69, 0x74, 0x65, 0x6d, 0x20, 0x6e, 0x6f, 0x2d, 17 | 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 18 | 0x22, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x32, 0x22, 0x20, 0x3a, 0x20, 0x22, 19 | 0x63, 0x61, 0x6c, 0x6d, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x63, 0x65, 20 | 0x6e, 0x74, 0x65, 0x72, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x73, 21 | 0x74, 0x79, 0x6c, 0x65, 0x32, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x66, 0x6f, 22 | 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x32, 0x30, 0x70, 0x78, 23 | 0x3b, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 24 | 0x3a, 0x62, 0x6f, 0x6c, 0x64, 0x3b, 0x6c, 0x69, 0x6e, 0x65, 0x2d, 0x68, 25 | 0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x33, 0x65, 0x6d, 0x3b, 0x22, 0x0d, 26 | 0x0a, 0x7d, 0x0d, 0x0a, 0x00 27 | }; 28 | const int line01_00_len = 293; 29 | -------------------------------------------------------------------------------- /platformio/heater/lib/widgets/line02_01.h: -------------------------------------------------------------------------------- 1 | const char line02_01_json[] = { 2 | 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x69, 0x64, 0x22, 0x20, 0x20, 0x20, 3 | 0x20, 0x20, 0x3a, 0x20, 0x22, 0x31, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 4 | 0x22, 0x70, 0x61, 0x67, 0x65, 0x22, 0x20, 0x20, 0x20, 0x3a, 0x20, 0x22, 5 | 0x48, 0x65, 0x61, 0x74, 0x65, 0x72, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 6 | 0x22, 0x70, 0x61, 0x67, 0x65, 0x49, 0x64, 0x22, 0x20, 0x3a, 0x20, 0x31, 7 | 0x30, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x77, 0x69, 0x64, 0x67, 0x65, 8 | 0x74, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 9 | 0x2d, 0x62, 0x74, 0x6e, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x74, 10 | 0x6f, 0x70, 0x69, 0x63, 0x22, 0x20, 0x20, 0x3a, 0x20, 0x22, 0x2f, 0x49, 11 | 0x6f, 0x54, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2f, 0x68, 0x65, 12 | 0x61, 0x74, 0x65, 0x72, 0x2f, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x30, 13 | 0x31, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x63, 0x6c, 0x61, 0x73, 14 | 0x73, 0x31, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x63, 0x6f, 0x6c, 0x2d, 0x78, 15 | 0x73, 0x2d, 0x34, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x63, 0x6c, 16 | 0x61, 0x73, 0x73, 0x32, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x63, 0x61, 0x6c, 17 | 0x6d, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x63, 0x6c, 0x61, 0x73, 18 | 0x73, 0x33, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x62, 0x75, 0x74, 0x74, 0x6f, 19 | 0x6e, 0x20, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x2d, 0x63, 0x61, 0x6c, 20 | 0x6d, 0x20, 0x69, 0x63, 0x6f, 0x6e, 0x20, 0x69, 0x6f, 0x6e, 0x2d, 0x6d, 21 | 0x69, 0x6e, 0x75, 0x73, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x73, 22 | 0x74, 0x79, 0x6c, 0x65, 0x33, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x68, 0x65, 23 | 0x69, 0x67, 0x68, 0x74, 0x3a, 0x37, 0x30, 0x70, 0x78, 0x3b, 0x22, 0x0d, 24 | 0x0a, 0x7d, 0x0d, 0x0a, 0x00 25 | }; 26 | const int line02_01_len = 269; 27 | -------------------------------------------------------------------------------- /platformio/heater/lib/widgets/line02_02.h: -------------------------------------------------------------------------------- 1 | const char line02_02_json[] = { 2 | 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x69, 0x64, 0x22, 0x20, 0x20, 0x20, 3 | 0x20, 0x20, 0x3a, 0x20, 0x22, 0x32, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 4 | 0x22, 0x70, 0x61, 0x67, 0x65, 0x22, 0x20, 0x20, 0x20, 0x3a, 0x20, 0x22, 5 | 0x48, 0x65, 0x61, 0x74, 0x65, 0x72, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 6 | 0x22, 0x70, 0x61, 0x67, 0x65, 0x49, 0x64, 0x22, 0x20, 0x3a, 0x20, 0x31, 7 | 0x30, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x77, 0x69, 0x64, 0x67, 0x65, 8 | 0x74, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x61, 0x6e, 0x79, 0x64, 0x61, 0x74, 9 | 0x61, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x74, 0x6f, 0x70, 0x69, 10 | 0x63, 0x22, 0x20, 0x20, 0x3a, 0x20, 0x22, 0x2f, 0x49, 0x6f, 0x54, 0x6d, 11 | 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2f, 0x68, 0x65, 0x61, 0x74, 0x65, 12 | 0x72, 0x2f, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x30, 0x32, 0x22, 0x2c, 13 | 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x31, 0x22, 14 | 0x20, 0x3a, 0x20, 0x22, 0x63, 0x6f, 0x6c, 0x2d, 0x78, 0x73, 0x2d, 0x34, 15 | 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x63, 0x6c, 0x61, 0x73, 0x73, 16 | 0x33, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x63, 17 | 0x65, 0x6e, 0x74, 0x65, 0x72, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 18 | 0x73, 0x74, 0x79, 0x6c, 0x65, 0x33, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x66, 19 | 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x34, 0x30, 0x70, 20 | 0x78, 0x3b, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x77, 0x65, 0x69, 0x67, 0x68, 21 | 0x74, 0x3a, 0x62, 0x6f, 0x6c, 0x64, 0x3b, 0x6c, 0x69, 0x6e, 0x65, 0x2d, 22 | 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x32, 0x65, 0x6d, 0x3b, 0x68, 23 | 0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x37, 0x30, 0x70, 0x78, 0x3b, 0x22, 24 | 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 25 | 0x22, 0x20, 0x3a, 0x20, 0x30, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x00 26 | }; 27 | const int line02_02_len = 287; 28 | -------------------------------------------------------------------------------- /platformio/heater/lib/widgets/line02_03.h: -------------------------------------------------------------------------------- 1 | const char line02_03_json[] = { 2 | 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x69, 0x64, 0x22, 0x20, 0x20, 0x20, 3 | 0x20, 0x20, 0x3a, 0x20, 0x22, 0x33, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 4 | 0x22, 0x70, 0x61, 0x67, 0x65, 0x22, 0x20, 0x20, 0x20, 0x3a, 0x20, 0x22, 5 | 0x48, 0x65, 0x61, 0x74, 0x65, 0x72, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 6 | 0x22, 0x70, 0x61, 0x67, 0x65, 0x49, 0x64, 0x22, 0x20, 0x3a, 0x20, 0x31, 7 | 0x30, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x77, 0x69, 0x64, 0x67, 0x65, 8 | 0x74, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 9 | 0x2d, 0x62, 0x74, 0x6e, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x74, 10 | 0x6f, 0x70, 0x69, 0x63, 0x22, 0x20, 0x20, 0x3a, 0x20, 0x22, 0x2f, 0x49, 11 | 0x6f, 0x54, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2f, 0x68, 0x65, 12 | 0x61, 0x74, 0x65, 0x72, 0x2f, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x30, 13 | 0x33, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x63, 0x6c, 0x61, 0x73, 14 | 0x73, 0x31, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x63, 0x6f, 0x6c, 0x2d, 0x78, 15 | 0x73, 0x2d, 0x34, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x63, 0x6c, 16 | 0x61, 0x73, 0x73, 0x32, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x63, 0x61, 0x6c, 17 | 0x6d, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x63, 0x6c, 0x61, 0x73, 18 | 0x73, 0x33, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x62, 0x75, 0x74, 0x74, 0x6f, 19 | 0x6e, 0x20, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x2d, 0x63, 0x61, 0x6c, 20 | 0x6d, 0x20, 0x69, 0x63, 0x6f, 0x6e, 0x20, 0x69, 0x6f, 0x6e, 0x2d, 0x70, 21 | 0x6c, 0x75, 0x73, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x73, 0x74, 22 | 0x79, 0x6c, 0x65, 0x33, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x68, 0x65, 0x69, 23 | 0x67, 0x68, 0x74, 0x3a, 0x37, 0x30, 0x70, 0x78, 0x3b, 0x22, 0x0d, 0x0a, 24 | 0x7d, 0x0d, 0x0a, 0x00 25 | }; 26 | const int line02_03_len = 268; 27 | -------------------------------------------------------------------------------- /platformio/heater/lib/widgets/line03_04.h: -------------------------------------------------------------------------------- 1 | const char line03_04_json[] = { 2 | 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x69, 0x64, 0x22, 0x20, 0x20, 0x20, 3 | 0x20, 0x20, 0x3a, 0x20, 0x22, 0x34, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 4 | 0x22, 0x70, 0x61, 0x67, 0x65, 0x22, 0x20, 0x20, 0x20, 0x3a, 0x20, 0x22, 5 | 0x48, 0x65, 0x61, 0x74, 0x65, 0x72, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 6 | 0x22, 0x70, 0x61, 0x67, 0x65, 0x49, 0x64, 0x22, 0x20, 0x3a, 0x20, 0x31, 7 | 0x30, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x77, 0x69, 0x64, 0x67, 0x65, 8 | 0x74, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x61, 0x6e, 0x79, 0x64, 0x61, 0x74, 9 | 0x61, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x74, 0x6f, 0x70, 0x69, 10 | 0x63, 0x22, 0x20, 0x20, 0x3a, 0x20, 0x22, 0x2f, 0x49, 0x6f, 0x54, 0x6d, 11 | 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2f, 0x68, 0x65, 0x61, 0x74, 0x65, 12 | 0x72, 0x2f, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x30, 0x34, 0x22, 0x2c, 13 | 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x31, 0x22, 14 | 0x20, 0x3a, 0x20, 0x22, 0x69, 0x74, 0x65, 0x6d, 0x20, 0x6e, 0x6f, 0x2d, 15 | 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 16 | 0x22, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x33, 0x22, 0x20, 0x3a, 0x20, 0x22, 17 | 0x63, 0x61, 0x6c, 0x6d, 0x2d, 0x62, 0x67, 0x20, 0x6c, 0x69, 0x67, 0x68, 18 | 0x74, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x63, 0x65, 0x6e, 0x74, 0x65, 19 | 0x72, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x2d, 0x6c, 0x65, 20 | 0x66, 0x74, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x2d, 0x72, 21 | 0x69, 0x67, 0x68, 0x74, 0x20, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x65, 0x64, 22 | 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x73, 0x74, 0x79, 0x6c, 0x65, 23 | 0x33, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 24 | 0x69, 0x7a, 0x65, 0x3a, 0x34, 0x30, 0x70, 0x78, 0x3b, 0x66, 0x6f, 0x6e, 25 | 0x74, 0x2d, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x62, 0x6f, 0x6c, 26 | 0x64, 0x3b, 0x6c, 0x69, 0x6e, 0x65, 0x2d, 0x68, 0x65, 0x69, 0x67, 0x68, 27 | 0x74, 0x3a, 0x32, 0x65, 0x6d, 0x3b, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 28 | 0x3a, 0x37, 0x30, 0x70, 0x78, 0x3b, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 29 | 0x22, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x20, 0x3a, 0x20, 0x30, 30 | 0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x00 31 | }; 32 | const int line03_04_len = 342; 33 | -------------------------------------------------------------------------------- /platformio/heater/lib/widgets/line04_05.h: -------------------------------------------------------------------------------- 1 | const char line04_05_json[] = { 2 | 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x69, 0x64, 0x22, 0x20, 0x20, 0x20, 3 | 0x20, 0x20, 0x3a, 0x20, 0x22, 0x35, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 4 | 0x22, 0x70, 0x61, 0x67, 0x65, 0x22, 0x20, 0x20, 0x20, 0x3a, 0x20, 0x22, 5 | 0x48, 0x65, 0x61, 0x74, 0x65, 0x72, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 6 | 0x22, 0x70, 0x61, 0x67, 0x65, 0x49, 0x64, 0x22, 0x20, 0x3a, 0x20, 0x31, 7 | 0x30, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x77, 0x69, 0x64, 0x67, 0x65, 8 | 0x74, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 9 | 0x2d, 0x62, 0x74, 0x6e, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x74, 10 | 0x6f, 0x70, 0x69, 0x63, 0x22, 0x20, 0x20, 0x3a, 0x20, 0x22, 0x2f, 0x49, 11 | 0x6f, 0x54, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2f, 0x68, 0x65, 12 | 0x61, 0x74, 0x65, 0x72, 0x2f, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x30, 13 | 0x35, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x63, 0x6c, 0x61, 0x73, 14 | 0x73, 0x31, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x63, 0x6f, 0x6c, 0x2d, 0x78, 15 | 0x73, 0x2d, 0x34, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x63, 0x6c, 16 | 0x61, 0x73, 0x73, 0x32, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x63, 0x61, 0x6c, 17 | 0x6d, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x63, 0x6c, 0x61, 0x73, 18 | 0x73, 0x33, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x62, 0x75, 0x74, 0x74, 0x6f, 19 | 0x6e, 0x20, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x2d, 0x63, 0x61, 0x6c, 20 | 0x6d, 0x20, 0x69, 0x63, 0x6f, 0x6e, 0x20, 0x69, 0x6f, 0x6e, 0x2d, 0x6d, 21 | 0x69, 0x6e, 0x75, 0x73, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x73, 22 | 0x74, 0x79, 0x6c, 0x65, 0x33, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x68, 0x65, 23 | 0x69, 0x67, 0x68, 0x74, 0x3a, 0x37, 0x30, 0x70, 0x78, 0x3b, 0x22, 0x0d, 24 | 0x0a, 0x7d, 0x0d, 0x0a, 0x00 25 | }; 26 | const int line04_05_len = 269; 27 | -------------------------------------------------------------------------------- /platformio/heater/lib/widgets/line04_06.h: -------------------------------------------------------------------------------- 1 | const char line04_06_json[] = { 2 | 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x69, 0x64, 0x22, 0x20, 0x20, 0x20, 3 | 0x20, 0x20, 0x3a, 0x20, 0x22, 0x36, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 4 | 0x22, 0x70, 0x61, 0x67, 0x65, 0x22, 0x20, 0x20, 0x20, 0x3a, 0x20, 0x22, 5 | 0x48, 0x65, 0x61, 0x74, 0x65, 0x72, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 6 | 0x22, 0x70, 0x61, 0x67, 0x65, 0x49, 0x64, 0x22, 0x20, 0x3a, 0x20, 0x31, 7 | 0x30, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x77, 0x69, 0x64, 0x67, 0x65, 8 | 0x74, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x61, 0x6e, 0x79, 0x64, 0x61, 0x74, 9 | 0x61, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x74, 0x6f, 0x70, 0x69, 10 | 0x63, 0x22, 0x20, 0x20, 0x3a, 0x20, 0x22, 0x2f, 0x49, 0x6f, 0x54, 0x6d, 11 | 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2f, 0x68, 0x65, 0x61, 0x74, 0x65, 12 | 0x72, 0x2f, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x30, 0x36, 0x22, 0x2c, 13 | 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x31, 0x22, 14 | 0x20, 0x3a, 0x20, 0x22, 0x63, 0x6f, 0x6c, 0x2d, 0x78, 0x73, 0x2d, 0x34, 15 | 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x63, 0x6c, 0x61, 0x73, 0x73, 16 | 0x33, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x63, 17 | 0x65, 0x6e, 0x74, 0x65, 0x72, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 18 | 0x73, 0x74, 0x79, 0x6c, 0x65, 0x33, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x66, 19 | 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x34, 0x30, 0x70, 20 | 0x78, 0x3b, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x77, 0x65, 0x69, 0x67, 0x68, 21 | 0x74, 0x3a, 0x62, 0x6f, 0x6c, 0x64, 0x3b, 0x6c, 0x69, 0x6e, 0x65, 0x2d, 22 | 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x32, 0x65, 0x6d, 0x3b, 0x68, 23 | 0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x37, 0x30, 0x70, 0x78, 0x3b, 0x22, 24 | 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 25 | 0x22, 0x20, 0x3a, 0x20, 0x30, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x00 26 | }; 27 | const int line04_06_len = 287; 28 | -------------------------------------------------------------------------------- /platformio/heater/lib/widgets/line04_07.h: -------------------------------------------------------------------------------- 1 | const char line04_07_json[] = { 2 | 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x69, 0x64, 0x22, 0x20, 0x20, 0x20, 3 | 0x20, 0x20, 0x3a, 0x20, 0x22, 0x37, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 4 | 0x22, 0x70, 0x61, 0x67, 0x65, 0x22, 0x20, 0x20, 0x20, 0x3a, 0x20, 0x22, 5 | 0x48, 0x65, 0x61, 0x74, 0x65, 0x72, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 6 | 0x22, 0x70, 0x61, 0x67, 0x65, 0x49, 0x64, 0x22, 0x20, 0x3a, 0x20, 0x31, 7 | 0x30, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x77, 0x69, 0x64, 0x67, 0x65, 8 | 0x74, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 9 | 0x2d, 0x62, 0x74, 0x6e, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x74, 10 | 0x6f, 0x70, 0x69, 0x63, 0x22, 0x20, 0x20, 0x3a, 0x20, 0x22, 0x2f, 0x49, 11 | 0x6f, 0x54, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2f, 0x68, 0x65, 12 | 0x61, 0x74, 0x65, 0x72, 0x2f, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x30, 13 | 0x37, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x63, 0x6c, 0x61, 0x73, 14 | 0x73, 0x31, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x63, 0x6f, 0x6c, 0x2d, 0x78, 15 | 0x73, 0x2d, 0x34, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x63, 0x6c, 16 | 0x61, 0x73, 0x73, 0x32, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x63, 0x61, 0x6c, 17 | 0x6d, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x63, 0x6c, 0x61, 0x73, 18 | 0x73, 0x33, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x62, 0x75, 0x74, 0x74, 0x6f, 19 | 0x6e, 0x20, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x2d, 0x63, 0x61, 0x6c, 20 | 0x6d, 0x20, 0x69, 0x63, 0x6f, 0x6e, 0x20, 0x69, 0x6f, 0x6e, 0x2d, 0x70, 21 | 0x6c, 0x75, 0x73, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x73, 0x74, 22 | 0x79, 0x6c, 0x65, 0x33, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x68, 0x65, 0x69, 23 | 0x67, 0x68, 0x74, 0x3a, 0x37, 0x30, 0x70, 0x78, 0x3b, 0x22, 0x0d, 0x0a, 24 | 0x7d, 0x0d, 0x0a, 0x00 25 | }; 26 | const int line04_07_len = 268; 27 | -------------------------------------------------------------------------------- /platformio/heater/lib/widgets/line05_08.h: -------------------------------------------------------------------------------- 1 | const char line05_08_json[] = { 2 | 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x69, 0x64, 0x22, 0x20, 0x20, 0x20, 3 | 0x20, 0x20, 0x3a, 0x20, 0x22, 0x38, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 4 | 0x22, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x22, 0x20, 0x3a, 0x20, 0x22, 5 | 0x61, 0x6e, 0x79, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 6 | 0x20, 0x22, 0x70, 0x61, 0x67, 0x65, 0x22, 0x20, 0x20, 0x20, 0x3a, 0x20, 7 | 0x22, 0x48, 0x65, 0x61, 0x74, 0x65, 0x72, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 8 | 0x20, 0x22, 0x70, 0x61, 0x67, 0x65, 0x49, 0x64, 0x22, 0x20, 0x3a, 0x20, 9 | 0x31, 0x30, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x74, 0x6f, 0x70, 0x69, 10 | 0x63, 0x22, 0x20, 0x20, 0x3a, 0x20, 0x22, 0x2f, 0x49, 0x6f, 0x54, 0x6d, 11 | 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2f, 0x68, 0x65, 0x61, 0x74, 0x65, 12 | 0x72, 0x2f, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x30, 0x38, 0x22, 0x2c, 13 | 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x31, 0x22, 14 | 0x20, 0x3a, 0x20, 0x22, 0x69, 0x74, 0x65, 0x6d, 0x20, 0x6e, 0x6f, 0x2d, 15 | 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 16 | 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 17 | 0x22, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x33, 0x22, 0x20, 0x3a, 0x20, 0x22, 18 | 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x32, 0x30, 19 | 0x70, 0x78, 0x3b, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x77, 0x65, 0x69, 0x67, 20 | 0x68, 0x74, 0x3a, 0x62, 0x6f, 0x6c, 0x64, 0x3b, 0x77, 0x69, 0x64, 0x74, 21 | 0x68, 0x3a, 0x31, 0x30, 0x30, 0x25, 0x3b, 0x22, 0x0d, 0x0a, 0x7d, 0x0d, 22 | 0x0a, 0x00 23 | }; 24 | const int line05_08_len = 242; 25 | -------------------------------------------------------------------------------- /platformio/heater/lib/widgets/line06_09.h: -------------------------------------------------------------------------------- 1 | const char line06_09_json[] = { 2 | 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x69, 0x64, 0x22, 0x20, 0x20, 0x20, 3 | 0x20, 0x20, 0x3a, 0x20, 0x22, 0x39, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 4 | 0x22, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x22, 0x20, 0x3a, 0x20, 0x22, 5 | 0x61, 0x6e, 0x79, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 6 | 0x20, 0x22, 0x70, 0x61, 0x67, 0x65, 0x22, 0x20, 0x20, 0x20, 0x3a, 0x20, 7 | 0x22, 0x48, 0x65, 0x61, 0x74, 0x65, 0x72, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 8 | 0x20, 0x22, 0x70, 0x61, 0x67, 0x65, 0x49, 0x64, 0x22, 0x20, 0x3a, 0x20, 9 | 0x31, 0x30, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x74, 0x6f, 0x70, 0x69, 10 | 0x63, 0x22, 0x20, 0x20, 0x3a, 0x20, 0x22, 0x2f, 0x49, 0x6f, 0x54, 0x6d, 11 | 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2f, 0x68, 0x65, 0x61, 0x74, 0x65, 12 | 0x72, 0x2f, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x30, 0x39, 0x22, 0x2c, 13 | 0x0d, 0x0a, 0x20, 0x20, 0x22, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x31, 0x22, 14 | 0x20, 0x3a, 0x20, 0x22, 0x69, 0x74, 0x65, 0x6d, 0x20, 0x6e, 0x6f, 0x2d, 15 | 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x20, 0x72, 0x6f, 0x75, 0x6e, 0x64, 16 | 0x65, 0x64, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x63, 0x65, 0x6e, 0x74, 17 | 0x65, 0x72, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x2d, 0x74, 18 | 0x6f, 0x70, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x2d, 0x62, 19 | 0x6f, 0x74, 0x74, 0x6f, 0x6d, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 20 | 0x63, 0x6c, 0x61, 0x73, 0x73, 0x33, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x61, 21 | 0x73, 0x73, 0x65, 0x72, 0x74, 0x69, 0x76, 0x65, 0x2d, 0x62, 0x67, 0x20, 22 | 0x6c, 0x69, 0x67, 0x68, 0x74, 0x22, 0x2c, 0x0d, 0x0a, 0x20, 0x20, 0x22, 23 | 0x73, 0x74, 0x79, 0x6c, 0x65, 0x33, 0x22, 0x20, 0x3a, 0x20, 0x22, 0x66, 24 | 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x32, 0x30, 0x70, 25 | 0x78, 0x22, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x00 26 | }; 27 | const int line06_09_len = 284; 28 | -------------------------------------------------------------------------------- /platformio/heater/platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter, extra scripting 4 | ; Upload options: custom port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; 7 | ; Please visit documentation for the other options and examples 8 | ; http://docs.platformio.org/en/stable/projectconf.html 9 | 10 | [env:nodemcuv2] 11 | platform = espressif8266 12 | board = nodemcuv2 13 | framework = arduino 14 | extra_script = extra_script.py 15 | 16 | libdeps-dir = "lib" 17 | 18 | lib_deps = 19 | https://github.com/Imroy/pubsubclient 20 | OneWire 21 | DallasTemperature 22 | -------------------------------------------------------------------------------- /platformio/heater/prebuild/bin/bin.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4refr0nt/iot-manager-demo/5ceed46ccf538e5bac9b92a03452eed21d27f74f/platformio/heater/prebuild/bin/bin.zip -------------------------------------------------------------------------------- /platformio/heater/prebuild/gen_h.bat: -------------------------------------------------------------------------------- 1 | @Echo off 2 | cd prebuild 3 | md temp >nul 4 | for %%f in (json/*.*) do ( 5 | echo -------------------------- 6 | echo Processing: %%f 7 | copy json\%%f temp\%%~nf.j >nul 8 | bin\echo -n -e \0000 >> temp\%%~nf.j 9 | bin\xxd -i temp\%%~nf.j > temp\%%~nf.x 10 | bin\sed "s/unsigned char temp_%%~nf\_j\[\]\ =/const char %%~nf_json[] =/" temp\%%~nf.x | sed "s/unsigned int temp_%%~nf\_j\_len/const int %%~nf\_len/" > ..\lib\widgets\%%~nf.h 11 | echo Resulting : %%~nf.h 12 | ) 13 | rem del /Q /S temp\*.j >nul 14 | rem del /Q /S temp\*.x >nul 15 | rd temp >nul 16 | cd .. 17 | -------------------------------------------------------------------------------- /platformio/heater/prebuild/json/line01_00.json: -------------------------------------------------------------------------------- 1 | { 2 | "id" : "0", 3 | "widget" : "anydata", 4 | "page" : "Heater", 5 | "pageId" : 10, 6 | "descr" : "Heater", 7 | "topic" : "/IoTmanager/heater/widget00", 8 | "class1" : "item no-border", 9 | "class2" : "calm text-center", 10 | "style2" : "font-size:20px;font-weight:bold;line-height:3em;" 11 | } 12 | -------------------------------------------------------------------------------- /platformio/heater/prebuild/json/line02_01.json: -------------------------------------------------------------------------------- 1 | { 2 | "id" : "1", 3 | "page" : "Heater", 4 | "pageId" : 10, 5 | "widget" : "simple-btn", 6 | "topic" : "/IoTmanager/heater/widget01", 7 | "class1" : "col-xs-4", 8 | "class2" : "calm", 9 | "class3" : "button button-calm icon ion-minus", 10 | "style3" : "height:70px;" 11 | } 12 | -------------------------------------------------------------------------------- /platformio/heater/prebuild/json/line02_02.json: -------------------------------------------------------------------------------- 1 | { 2 | "id" : "2", 3 | "page" : "Heater", 4 | "pageId" : 10, 5 | "widget" : "anydata", 6 | "topic" : "/IoTmanager/heater/widget02", 7 | "class1" : "col-xs-4", 8 | "class3" : "text-center", 9 | "style3" : "font-size:40px;font-weight:bold;line-height:2em;height:70px;", 10 | "status" : 0 11 | } 12 | -------------------------------------------------------------------------------- /platformio/heater/prebuild/json/line02_03.json: -------------------------------------------------------------------------------- 1 | { 2 | "id" : "3", 3 | "page" : "Heater", 4 | "pageId" : 10, 5 | "widget" : "simple-btn", 6 | "topic" : "/IoTmanager/heater/widget03", 7 | "class1" : "col-xs-4", 8 | "class2" : "calm", 9 | "class3" : "button button-calm icon ion-plus", 10 | "style3" : "height:70px;" 11 | } 12 | -------------------------------------------------------------------------------- /platformio/heater/prebuild/json/line03_04.json: -------------------------------------------------------------------------------- 1 | { 2 | "id" : "4", 3 | "page" : "Heater", 4 | "pageId" : 10, 5 | "widget" : "anydata", 6 | "topic" : "/IoTmanager/heater/widget04", 7 | "class1" : "item no-border", 8 | "class3" : "calm-bg light text-center padding-left padding-right rounded", 9 | "style3" : "font-size:40px;font-weight:bold;line-height:2em;height:70px;", 10 | "status" : 0 11 | } 12 | -------------------------------------------------------------------------------- /platformio/heater/prebuild/json/line04_05.json: -------------------------------------------------------------------------------- 1 | { 2 | "id" : "5", 3 | "page" : "Heater", 4 | "pageId" : 10, 5 | "widget" : "simple-btn", 6 | "topic" : "/IoTmanager/heater/widget05", 7 | "class1" : "col-xs-4", 8 | "class2" : "calm", 9 | "class3" : "button button-calm icon ion-minus", 10 | "style3" : "height:70px;" 11 | } 12 | -------------------------------------------------------------------------------- /platformio/heater/prebuild/json/line04_06.json: -------------------------------------------------------------------------------- 1 | { 2 | "id" : "6", 3 | "page" : "Heater", 4 | "pageId" : 10, 5 | "widget" : "anydata", 6 | "topic" : "/IoTmanager/heater/widget06", 7 | "class1" : "col-xs-4", 8 | "class3" : "text-center", 9 | "style3" : "font-size:40px;font-weight:bold;line-height:2em;height:70px;", 10 | "status" : 0 11 | } 12 | -------------------------------------------------------------------------------- /platformio/heater/prebuild/json/line04_07.json: -------------------------------------------------------------------------------- 1 | { 2 | "id" : "7", 3 | "page" : "Heater", 4 | "pageId" : 10, 5 | "widget" : "simple-btn", 6 | "topic" : "/IoTmanager/heater/widget07", 7 | "class1" : "col-xs-4", 8 | "class2" : "calm", 9 | "class3" : "button button-calm icon ion-plus", 10 | "style3" : "height:70px;" 11 | } 12 | -------------------------------------------------------------------------------- /platformio/heater/prebuild/json/line05_08.json: -------------------------------------------------------------------------------- 1 | { 2 | "id" : "8", 3 | "widget" : "anydata", 4 | "page" : "Heater", 5 | "pageId" : 10, 6 | "topic" : "/IoTmanager/heater/widget08", 7 | "class1" : "item no-border text-center", 8 | "style3" : "font-size:20px;font-weight:bold;width:100%;" 9 | } 10 | -------------------------------------------------------------------------------- /platformio/heater/prebuild/json/line06_09.json: -------------------------------------------------------------------------------- 1 | { 2 | "id" : "9", 3 | "widget" : "anydata", 4 | "page" : "Heater", 5 | "pageId" : 10, 6 | "topic" : "/IoTmanager/heater/widget09", 7 | "class1" : "item no-border rounded text-center padding-top padding-bottom", 8 | "class3" : "assertive-bg light", 9 | "style3" : "font-size:20px" 10 | } 11 | -------------------------------------------------------------------------------- /platformio/heater/readme.md: -------------------------------------------------------------------------------- 1 | # Manual lib installing 2 | 3 | ``` 4 | platformio lib install https://github.com/Imroy/pubsubclient.git 5 | ``` 6 | -------------------------------------------------------------------------------- /platformio/home/.gitignore: -------------------------------------------------------------------------------- 1 | .pioenvs 2 | .clang_complete 3 | .gcc-flags.json 4 | .piolibdeps -------------------------------------------------------------------------------- /platformio/home/.travis.yml: -------------------------------------------------------------------------------- 1 | # Continuous Integration (CI) is the practice, in software 2 | # engineering, of merging all developer working copies with a shared mainline 3 | # several times a day < http://docs.platformio.org/en/stable/ci/index.html > 4 | # 5 | # Documentation: 6 | # 7 | # * Travis CI Embedded Builds with PlatformIO 8 | # < https://docs.travis-ci.com/user/integration/platformio/ > 9 | # 10 | # * PlatformIO integration with Travis CI 11 | # < http://docs.platformio.org/en/stable/ci/travis.html > 12 | # 13 | # * User Guide for `platformio ci` command 14 | # < http://docs.platformio.org/en/stable/userguide/cmd_ci.html > 15 | # 16 | # 17 | # Please choice one of the following templates (proposed below) and uncomment 18 | # it (remove "# " before each line) or use own configuration according to the 19 | # Travis CI documentation (see above). 20 | # 21 | 22 | 23 | # 24 | # Template #1: General project. Test it using existing `platformio.ini`. 25 | # 26 | 27 | # language: python 28 | # python: 29 | # - "2.7" 30 | # 31 | # sudo: false 32 | # cache: 33 | # directories: 34 | # - "~/.platformio" 35 | # 36 | # install: 37 | # - pip install -U platformio 38 | # 39 | # script: 40 | # - platformio run 41 | 42 | 43 | # 44 | # Template #2: The project is intended to by used as a library with examples 45 | # 46 | 47 | # language: python 48 | # python: 49 | # - "2.7" 50 | # 51 | # sudo: false 52 | # cache: 53 | # directories: 54 | # - "~/.platformio" 55 | # 56 | # env: 57 | # - PLATFORMIO_CI_SRC=path/to/test/file.c 58 | # - PLATFORMIO_CI_SRC=examples/file.ino 59 | # - PLATFORMIO_CI_SRC=path/to/test/directory 60 | # 61 | # install: 62 | # - pip install -U platformio 63 | # 64 | # script: 65 | # - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N 66 | -------------------------------------------------------------------------------- /platformio/home/lib/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for the project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link to executable file. 4 | 5 | The source code of each library should be placed in separate directory, like 6 | "lib/private_lib/[here are source files]". 7 | 8 | For example, see how can be organized `Foo` and `Bar` libraries: 9 | 10 | |--lib 11 | | |--Bar 12 | | | |--docs 13 | | | |--examples 14 | | | |--src 15 | | | |- Bar.c 16 | | | |- Bar.h 17 | | |--Foo 18 | | | |- Foo.c 19 | | | |- Foo.h 20 | | |- readme.txt --> THIS FILE 21 | |- platformio.ini 22 | |--src 23 | |- main.c 24 | 25 | Then in `src/main.c` you should use: 26 | 27 | #include 28 | #include 29 | 30 | // rest H/C/CPP code 31 | 32 | PlatformIO will find your libraries automatically, configure preprocessor's 33 | include paths and build them. 34 | 35 | More information about PlatformIO Library Dependency Finder 36 | - http://docs.platformio.org/en/stable/librarymanager/ldf.html 37 | -------------------------------------------------------------------------------- /platformio/home/platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter, extra scripting 4 | ; Upload options: custom port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; 7 | ; Please visit documentation for the other options and examples 8 | ; http://docs.platformio.org/en/stable/projectconf.html 9 | 10 | [env:d1_mini] 11 | platform = espressif8266 12 | board = d1_mini 13 | framework = arduino 14 | lib_deps = 15 | https://github.com/Imroy/pubsubclient 16 | ArduinoJson 17 | -------------------------------------------------------------------------------- /platformio/home/readme.md: -------------------------------------------------------------------------------- 1 | # Manual libs installing 2 | 3 | ``` 4 | platformio lib install https://github.com/Imroy/pubsubclient.git 5 | platformio lib install ArduinoJson 6 | ``` 7 | -------------------------------------------------------------------------------- /platformio/rv9yw_fill_gauge/lib/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for the project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link to executable file. 4 | 5 | The source code of each library should be placed in separate directory, like 6 | "lib/private_lib/[here are source files]". 7 | 8 | For example, see how can be organized `Foo` and `Bar` libraries: 9 | 10 | |--lib 11 | | |--Bar 12 | | | |--docs 13 | | | |--examples 14 | | | |--src 15 | | | |- Bar.c 16 | | | |- Bar.h 17 | | |--Foo 18 | | | |- Foo.c 19 | | | |- Foo.h 20 | | |- readme.txt --> THIS FILE 21 | |- platformio.ini 22 | |--src 23 | |- main.c 24 | 25 | Then in `src/main.c` you should use: 26 | 27 | #include 28 | #include 29 | 30 | // rest H/C/CPP code 31 | 32 | PlatformIO will find your libraries automatically, configure preprocessor's 33 | include paths and build them. 34 | 35 | More information about PlatformIO Library Dependency Finder 36 | - http://docs.platformio.org/en/stable/librarymanager/ldf.html 37 | -------------------------------------------------------------------------------- /platformio/rv9yw_fill_gauge/platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter, extra scripting 4 | ; Upload options: custom port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; 7 | ; Please visit documentation for the other options and examples 8 | ; http://docs.platformio.org/en/stable/projectconf.html 9 | 10 | [env:esp12e] 11 | platform = espressif8266 12 | board = esp12e 13 | framework = arduino 14 | lib_deps = 15 | https://github.com/Imroy/pubsubclient 16 | ArduinoJson 17 | -------------------------------------------------------------------------------- /platformio/rv9yw_fill_gauge/readme.md: -------------------------------------------------------------------------------- 1 | # Manual libs installing 2 | 3 | ``` 4 | platformio lib install https://github.com/Imroy/pubsubclient.git 5 | platformio lib install ArduinoJson 6 | ``` 7 | -------------------------------------------------------------------------------- /python/.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | __pycache__ 3 | sensor/__pycache__ 4 | -------------------------------------------------------------------------------- /python/README.md: -------------------------------------------------------------------------------- 1 | ##### iot-manager-demo 2 | 3 | Demo example for Raspberry Pi status 4 | 5 | ## Install & Run 6 | 7 | ``` 8 | pip install paho-mqtt httplib2 9 | python main.py 10 | ``` 11 | 12 | ## Push notification 13 | 14 | Please edit push.py and set your mobile phone ids (go to IoT Manager - Statistics - IDS) 15 | 16 | ``` 17 | python push.py 18 | ``` 19 | -------------------------------------------------------------------------------- /python/main.py: -------------------------------------------------------------------------------- 1 | # iotManager 2 | # RPI 3 | # @auhtor Alex Suslov 4 | # @created 2016-09-06 5 | # The MIT License (MIT) 6 | # Copyright (c) 2016 AlexSuslov 7 | 8 | import os 9 | import paho.mqtt.client as mqtt 10 | import json 11 | import threading 12 | import httplib2 13 | from sensor.temp import Temperature 14 | from sensor.la import LoadAvg 15 | from sensor.la5 import LoadAvg5 16 | from sensor.la15 import LoadAvg15 17 | from sensor.mem import Memory 18 | from sensor.sdcard import SDcard 19 | 20 | connection = False 21 | ids = [""] 22 | # mqtt config 23 | host = "m20.cloudmqtt.com" 24 | port = 13191 25 | username = "test" 26 | password = "test" 27 | 28 | # IoT MAnager config 29 | prefix = '/IoTmanager' 30 | deviceID = 'rpi'; 31 | 32 | # mqtt 33 | client = mqtt.Client() 34 | 35 | temperature = Temperature(client, prefix, deviceID, 1, 1, 'page1') 36 | loadavg = LoadAvg(client, prefix, deviceID, 2, 2, 'page2') 37 | loadavg5 = LoadAvg5(client, prefix, deviceID, 3, 2, 'page2') 38 | loadavg15 = LoadAvg15(client, prefix, deviceID, 4, 3, 'page3') 39 | mem = Memory(client, prefix, deviceID, 5, 3, 'page3') 40 | sdcard = SDcard(client, prefix, deviceID, 6, 3, 'page3') 41 | 42 | 43 | def send_configs(): 44 | print("Sending all configs ...") 45 | temperature.send_config() 46 | loadavg.send_config() 47 | loadavg5.send_config() 48 | loadavg15.send_config() 49 | mem.send_config() 50 | sdcard.send_config() 51 | 52 | def on_connect(client, userdata, flags, rc): 53 | print("Connected with result code " + str(rc)) 54 | client.subscribe(prefix) 55 | client.subscribe(prefix + "/#") 56 | send_configs() 57 | 58 | def on_message(client, userdata, msg): 59 | # topic 60 | t = msg.topic 61 | # message 62 | m = msg.payload.decode("utf-8") 63 | print("Message arrived: " + t + "=>" + m) 64 | 65 | if( t == prefix and m == u'HELLO'): 66 | print("HELLO detected") 67 | send_configs() 68 | 69 | if (t == prefix + "/push" and ids[0] != ""): 70 | http = httplib2.Http() 71 | url= "https://onesignal.com/api/v1/notifications" 72 | headers = {'Content-type': 'application/json'} 73 | data = { 74 | "app_id": "8871958c-5f52-11e5-8f7a-c36f5770ade9", 75 | "include_player_ids":ids, 76 | "android_group":"IoT Manager", 77 | "contents": { 78 | "en": m 79 | } 80 | } 81 | response, content = http.request(url, 'POST', headers=headers, body=json.dumps(data)) 82 | print(response.status, response.reason) 83 | 84 | if(t == (prefix + "/ids")): 85 | print("ids detected:" + m) 86 | ids[0] = m 87 | # store ids for sending alerts 88 | # ids = m ... 89 | 90 | client.on_connect = on_connect 91 | client.on_message = on_message 92 | client.username_pw_set(username, password) 93 | print("Try connecting to " + host + ":" + str(port)) 94 | client.connect(host, port, 60) 95 | client.loop_forever() 96 | 97 | -------------------------------------------------------------------------------- /python/push.py: -------------------------------------------------------------------------------- 1 | # iotManager 2 | # RPI 3 | # @auhtor Alex Suslov 4 | # @created 2016-09-06 5 | # The MIT License (MIT) 6 | # Copyright (c) 2016 AlexSuslov 7 | # 8 | # Push notification 9 | # 10 | ids =["your-phone-ids"] 11 | msg = "Alert! Kitchen: water lake detected!" 12 | import httplib2 13 | import json 14 | 15 | http = httplib2.Http() 16 | url= "https://onesignal.com/api/v1/notifications" 17 | headers = {'Content-type': 'application/json'} 18 | data = { 19 | "app_id": "8871958c-5f52-11e5-8f7a-c36f5770ade9", 20 | "include_player_ids":ids, 21 | "android_group":"IoT Manager", 22 | "contents": { 23 | "en": msg 24 | } 25 | } 26 | response, content = http.request(url, 'POST', headers=headers, body=json.dumps(data)) 27 | print(response.status, response.reason) 28 | -------------------------------------------------------------------------------- /python/sensor/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4refr0nt/iot-manager-demo/5ceed46ccf538e5bac9b92a03452eed21d27f74f/python/sensor/__init__.py -------------------------------------------------------------------------------- /python/sensor/la.py: -------------------------------------------------------------------------------- 1 | # iotManager 2 | # load avg sensor 3 | import json 4 | import threading 5 | # import os 6 | 7 | frame = "STEEL" # BLACK_METAL METAL SHINY_METAL BRASS STEEL CHROME GOLD ANTHRACITE TILTED_GRAY TILTED_BLACK GLOSSY_METAL 8 | color = "RAITH" # RED GREEN BLUE ORANGE YELLOW CYAN MAGENTA WHITE GRAY BLACK RAITH GREEN_LCD JUG_GREEN 9 | bgColor = "CARBON" # DARK_GRAY SATIN_GRAY LIGHT_GRAY WHITE BLACK BEIGE BROWN RED GREEN BLUE ANTHRACITE MUD PUNCHED_SHEET CARBON STAINLESS BRUSHED_METAL BRUSHED_STAINLESS TURNED 10 | lcd = "BLUE_BLUE" # BEIGE BLUE ORANGE RED YELLOW WHITE GRAY BLACK GREEN BLUE2 BLUE_BLACK BLUE_DARKBLUE BLUE_GRAY STANDARD STANDARD_GREEN BLUE_BLUE RED_DARKRED DARKBLUE LILA BLACKRED DARKGREEN AMBER LIGHTBLUE SECTIONS 11 | led = "RED_LED" # RED_LED GREEN_LED BLUE_LED ORANGE_LED YELLOW_LED CYAN_LED 12 | 13 | class LoadAvg: 14 | counter = 0 15 | t = 0 16 | config = { 17 | 'descr' : "Load average", 18 | 'widget' : "steel", 19 | 'style1' : "float:left;", 20 | 'widgetConfig' : { 21 | 'titleString' : "Load average 1 min", 22 | 'unitString' : "%", 23 | 'width' : "auto2", 24 | 'height' : 100, 25 | 'type' : "Linear", 26 | 'lcdVisible' : True, 27 | 'ledVisible' : True, 28 | 'lcdDecimals' : 0, 29 | 'FrameDesign' : frame, 30 | 'ColorDef' : color, 31 | 'BackgroundColor': bgColor, 32 | 'LcdColor' : lcd, 33 | 'LedColor' : led, 34 | 'minMeasuredValueVisible' : True, 35 | 'maxMeasuredValueVisible' : True, 36 | 'threshold' : 50, 37 | 'minValue' : 0, 38 | 'maxValue' : 100, 39 | } 40 | } 41 | 42 | def __init__(self, client, prefix, deviceID, widgetID, pageId, page): 43 | self.client = client 44 | self.prefix = prefix 45 | self.deviceID = deviceID 46 | self.config['id'] = widgetID 47 | self.config['topic'] = prefix + "/" + deviceID + "/la" 48 | self.config['pageId'] = pageId 49 | self.config['page'] = page 50 | self.t = threading.Timer(10.0, self.send) 51 | self.t.start() 52 | 53 | 54 | def send_config(self): 55 | print('Publish config:'+ json.dumps(self.config)) 56 | self.client.publish( self.prefix + "/" + self.deviceID + '/config', json.dumps(self.config)) 57 | self.counter = 5 * 60 / 10 # 5 min send 58 | self.send() 59 | 60 | def send(self): 61 | self.t.cancel() 62 | self.t = threading.Timer(10.0, self.send) 63 | self.t.start() 64 | if(self.counter > 0): 65 | topic = self.prefix + "/" + self.deviceID + "/la/status" 66 | val = float(self.get()[0]) * 100 67 | print('Publish ' + topic + ':' + str(val)) 68 | self.client.publish(topic, json.dumps({ 'status': val}) ) 69 | 70 | 71 | def get(self): 72 | with open('/proc/loadavg') as f: 73 | loadavg = f.readlines() 74 | return str(loadavg[0]).replace('\n', '').split(' ') 75 | -------------------------------------------------------------------------------- /python/sensor/la15.py: -------------------------------------------------------------------------------- 1 | # iotManager 2 | # load avg sensor 3 | import json 4 | import threading 5 | # import os 6 | 7 | frame = "STEEL" # BLACK_METAL METAL SHINY_METAL BRASS STEEL CHROME GOLD ANTHRACITE TILTED_GRAY TILTED_BLACK GLOSSY_METAL 8 | color = "RAITH" # RED GREEN BLUE ORANGE YELLOW CYAN MAGENTA WHITE GRAY BLACK RAITH GREEN_LCD JUG_GREEN 9 | bgColor = "CARBON" # DARK_GRAY SATIN_GRAY LIGHT_GRAY WHITE BLACK BEIGE BROWN RED GREEN BLUE ANTHRACITE MUD PUNCHED_SHEET CARBON STAINLESS BRUSHED_METAL BRUSHED_STAINLESS TURNED 10 | lcd = "BLUE_BLUE" # BEIGE BLUE ORANGE RED YELLOW WHITE GRAY BLACK GREEN BLUE2 BLUE_BLACK BLUE_DARKBLUE BLUE_GRAY STANDARD STANDARD_GREEN BLUE_BLUE RED_DARKRED DARKBLUE LILA BLACKRED DARKGREEN AMBER LIGHTBLUE SECTIONS 11 | led = "RED_LED" # RED_LED GREEN_LED BLUE_LED ORANGE_LED YELLOW_LED CYAN_LED 12 | 13 | class LoadAvg15: 14 | counter = 0 15 | t = 0 16 | config = { 17 | 'descr' : "Load average", 18 | 'widget' : "steel", 19 | 'widgetConfig' : { 20 | 'titleString' : "Load average 15 min", 21 | 'unitString' : "%", 22 | 'width' : "auto", 23 | 'height' : 100, 24 | 'type' : "Linear", 25 | 'lcdVisible' : True, 26 | 'ledVisible' : True, 27 | 'lcdDecimals' : 0, 28 | 'FrameDesign' : frame, 29 | 'ColorDef' : color, 30 | 'BackgroundColor': bgColor, 31 | 'LcdColor' : lcd, 32 | 'LedColor' : led, 33 | 'minMeasuredValueVisible' : True, 34 | 'maxMeasuredValueVisible' : True, 35 | 'threshold' : 50, 36 | 'minValue' : 0, 37 | 'maxValue' : 100, 38 | } 39 | } 40 | 41 | def __init__(self, client, prefix, deviceID, widgetID, pageId, page): 42 | self.client = client 43 | self.prefix = prefix 44 | self.deviceID = deviceID 45 | self.config['id'] = widgetID 46 | self.config['topic'] = prefix + "/" + deviceID + "/la15" 47 | self.config['pageId'] = pageId 48 | self.config['page'] = page 49 | self.t = threading.Timer(10.0, self.send) 50 | self.t.start() 51 | 52 | 53 | def send_config(self): 54 | print('Publish config:'+ json.dumps(self.config)) 55 | self.client.publish( self.prefix + "/" + self.deviceID + '/config', json.dumps(self.config)) 56 | self.counter = 5 * 60 / 10 # 5 min send 57 | self.send() 58 | 59 | def send(self): 60 | self.t.cancel() 61 | self.t = threading.Timer(10.0, self.send) 62 | self.t.start() 63 | if(self.counter > 0): 64 | topic = self.prefix + "/" + self.deviceID + "/la15/status" 65 | val = float(self.get()[2]) * 100 66 | print('Publish ' + topic + ':' + str(val)) 67 | self.client.publish(topic, json.dumps({ 'status': val}) ) 68 | 69 | 70 | def get(self): 71 | with open('/proc/loadavg') as f: 72 | loadavg = f.readlines() 73 | return str(loadavg[0]).replace('\n', '').split(' ') 74 | -------------------------------------------------------------------------------- /python/sensor/la5.py: -------------------------------------------------------------------------------- 1 | # iotManager 2 | # load avg sensor 3 | import json 4 | import threading 5 | # import os 6 | 7 | frame = "STEEL" # BLACK_METAL METAL SHINY_METAL BRASS STEEL CHROME GOLD ANTHRACITE TILTED_GRAY TILTED_BLACK GLOSSY_METAL 8 | color = "RAITH" # RED GREEN BLUE ORANGE YELLOW CYAN MAGENTA WHITE GRAY BLACK RAITH GREEN_LCD JUG_GREEN 9 | bgColor = "CARBON" # DARK_GRAY SATIN_GRAY LIGHT_GRAY WHITE BLACK BEIGE BROWN RED GREEN BLUE ANTHRACITE MUD PUNCHED_SHEET CARBON STAINLESS BRUSHED_METAL BRUSHED_STAINLESS TURNED 10 | lcd = "BLUE_BLUE" # BEIGE BLUE ORANGE RED YELLOW WHITE GRAY BLACK GREEN BLUE2 BLUE_BLACK BLUE_DARKBLUE BLUE_GRAY STANDARD STANDARD_GREEN BLUE_BLUE RED_DARKRED DARKBLUE LILA BLACKRED DARKGREEN AMBER LIGHTBLUE SECTIONS 11 | led = "RED_LED" # RED_LED GREEN_LED BLUE_LED ORANGE_LED YELLOW_LED CYAN_LED 12 | 13 | class LoadAvg5: 14 | counter = 0 15 | t = 0 16 | config = { 17 | 'descr' : "Load average", 18 | 'style1' : "float:right;", 19 | 'widget' : "steel", 20 | 'widgetConfig' : { 21 | 'titleString' : "Load average 5 min", 22 | 'unitString' : "%", 23 | 'width' : "auto2", 24 | 'height' : 100, 25 | 'type' : "Linear", 26 | 'lcdVisible' : True, 27 | 'ledVisible' : True, 28 | 'lcdDecimals' : 0, 29 | 'FrameDesign' : frame, 30 | 'ColorDef' : color, 31 | 'BackgroundColor': bgColor, 32 | 'LcdColor' : lcd, 33 | 'LedColor' : led, 34 | 'minMeasuredValueVisible' : True, 35 | 'maxMeasuredValueVisible' : True, 36 | 'threshold' : 50, 37 | 'minValue' : 0, 38 | 'maxValue' : 100, 39 | } 40 | } 41 | 42 | def __init__(self, client, prefix, deviceID, widgetID, pageId, page): 43 | self.client = client 44 | self.prefix = prefix 45 | self.deviceID = deviceID 46 | self.config['id'] = widgetID 47 | self.config['topic'] = prefix + "/" + deviceID + "/la5" 48 | self.config['pageId'] = pageId 49 | self.config['page'] = page 50 | self.t = threading.Timer(10.0, self.send) 51 | self.t.start() 52 | 53 | 54 | def send_config(self): 55 | print('Publish config:'+ json.dumps(self.config)) 56 | self.client.publish( self.prefix + "/" + self.deviceID + '/config', json.dumps(self.config)) 57 | self.counter = 5 * 60 / 10 # 5 min send 58 | self.send() 59 | 60 | def send(self): 61 | self.t.cancel() 62 | self.t = threading.Timer(10.0, self.send) 63 | self.t.start() 64 | if(self.counter > 0): 65 | topic = self.prefix + "/" + self.deviceID + "/la5/status" 66 | val = float(self.get()[1]) * 100 67 | print('Publish ' + topic + ':' + str(val)) 68 | self.client.publish(topic, json.dumps({ 'status': val}) ) 69 | 70 | 71 | def get(self): 72 | with open('/proc/loadavg') as f: 73 | loadavg = f.readlines() 74 | return str(loadavg[0]).replace('\n', '').split(' ') 75 | -------------------------------------------------------------------------------- /python/sensor/mem.py: -------------------------------------------------------------------------------- 1 | # iotManager 2 | # RPI memory sensor 3 | # @auhtor Alex Suslov 4 | # @created 2016-09-06 5 | # The MIT License (MIT) 6 | # Copyright (c) 2016 AlexSuslov 7 | 8 | import json 9 | import threading 10 | 11 | frame = "STEEL" # BLACK_METAL METAL SHINY_METAL BRASS STEEL CHROME GOLD ANTHRACITE TILTED_GRAY TILTED_BLACK GLOSSY_METAL 12 | color = "RAITH" # RED GREEN BLUE ORANGE YELLOW CYAN MAGENTA WHITE GRAY BLACK RAITH GREEN_LCD JUG_GREEN 13 | bgColor = "CARBON" # DARK_GRAY SATIN_GRAY LIGHT_GRAY WHITE BLACK BEIGE BROWN RED GREEN BLUE ANTHRACITE MUD PUNCHED_SHEET CARBON STAINLESS BRUSHED_METAL BRUSHED_STAINLESS TURNED 14 | lcd = "BLUE_BLUE" # BEIGE BLUE ORANGE RED YELLOW WHITE GRAY BLACK GREEN BLUE2 BLUE_BLACK BLUE_DARKBLUE BLUE_GRAY STANDARD STANDARD_GREEN BLUE_BLUE RED_DARKRED DARKBLUE LILA BLACKRED DARKGREEN AMBER LIGHTBLUE SECTIONS 15 | led = "RED_LED" # RED_LED GREEN_LED BLUE_LED ORANGE_LED YELLOW_LED CYAN_LED 16 | 17 | class Memory: 18 | counter = 0 19 | t = 0 20 | config = { 21 | 'descr' : "Memory usage", 22 | 'widget' : "fillgauge", 23 | 'class1' : "no-border text-center col-xs-6", 24 | 'class2' : "calm", 25 | 'style2' : "font-size:14px;padding-bottom:5px;", 26 | 'width' : "150px", 27 | 'height' : "150px", 28 | 'class3' : "text-center", 29 | 'widgetConfig' : { 30 | 'circleThickness' : 0.1, 31 | 'waveAnimateTime' : 1000, 32 | 'waveHeight' : 0.05, 33 | 'waveAnimate' : 'true', 34 | 'waveOffset' : 0.25, 35 | 'textSize' : 0.6, 36 | 'minValue' : 0, 37 | 'maxValue' : 100, 38 | 'waveCount' : 2 39 | } 40 | } 41 | 42 | def __init__(self, client, prefix, deviceID, widgetID, pageId, page): 43 | self.client = client 44 | self.prefix = prefix 45 | self.deviceID = deviceID 46 | self.config['id'] = widgetID 47 | self.config['topic'] = prefix + "/" + deviceID + "/mem" 48 | self.config['pageId'] = pageId 49 | self.config['page'] = page 50 | self.t = threading.Timer(10.0, self.send) 51 | self.t.start() 52 | 53 | def send_config(self): 54 | print('Publish config:'+ json.dumps(self.config)) 55 | self.client.publish( self.prefix + "/" + self.deviceID + '/config', json.dumps(self.config)) 56 | self.counter = 5 * 60 / 10 # 5 min send 57 | x = threading.Timer(2.0, self.send) 58 | x.start() 59 | 60 | def send(self): 61 | self.t.cancel() 62 | self.t = threading.Timer(10.0, self.send) 63 | self.t.start() 64 | if(self.counter > 0): 65 | self.counter = self.counter - 1 66 | topic = self.prefix + "/" + self.deviceID + "/mem/status" 67 | print('Publish ' + topic + ':' + str(self.get()["p_MemUsed"])) 68 | self.client.publish(topic, json.dumps({ 'status': self.get()["p_MemUsed"]}) ) 69 | 70 | def get(self): 71 | resp = {} 72 | with open('/proc/meminfo') as f: 73 | for line in f: 74 | data = line.replace("\n", "").replace("kB", "").split(":") 75 | resp[data[0]] = int(data[1].strip()) 76 | 77 | resp['MemUsed'] = resp['MemTotal'] - resp['MemFree'] 78 | resp['p_MemUsed'] = (resp['MemUsed'] / resp['MemTotal']) * 100 79 | return resp -------------------------------------------------------------------------------- /python/sensor/sdcard.py: -------------------------------------------------------------------------------- 1 | # iotManager 2 | # sdcard sensor 3 | import json 4 | import threading 5 | import os 6 | 7 | frame = "STEEL" # BLACK_METAL METAL SHINY_METAL BRASS STEEL CHROME GOLD ANTHRACITE TILTED_GRAY TILTED_BLACK GLOSSY_METAL 8 | color = "RAITH" # RED GREEN BLUE ORANGE YELLOW CYAN MAGENTA WHITE GRAY BLACK RAITH GREEN_LCD JUG_GREEN 9 | bgColor = "CARBON" # DARK_GRAY SATIN_GRAY LIGHT_GRAY WHITE BLACK BEIGE BROWN RED GREEN BLUE ANTHRACITE MUD PUNCHED_SHEET CARBON STAINLESS BRUSHED_METAL BRUSHED_STAINLESS TURNED 10 | lcd = "BLUE_BLUE" # BEIGE BLUE ORANGE RED YELLOW WHITE GRAY BLACK GREEN BLUE2 BLUE_BLACK BLUE_DARKBLUE BLUE_GRAY STANDARD STANDARD_GREEN BLUE_BLUE RED_DARKRED DARKBLUE LILA BLACKRED DARKGREEN AMBER LIGHTBLUE SECTIONS 11 | led = "RED_LED" # RED_LED GREEN_LED BLUE_LED ORANGE_LED YELLOW_LED CYAN_LED 12 | 13 | class SDcard: 14 | counter = 0 15 | t = 0 16 | config = { 17 | 'descr' : "Disk usage", 18 | 'widget' : "fillgauge", 19 | 'class1' : "no-border text-center col-xs-6", 20 | 'class2' : "calm", 21 | 'style2' : "font-size:14px;padding-bottom:5px;", 22 | 'width' : "150px", 23 | 'height' : "150px", 24 | 'class3' : "text-center", 25 | 'widgetConfig' : { 26 | 'circleThickness' : 0.1, 27 | 'waveAnimateTime' : 1000, 28 | 'waveHeight' : 0.05, 29 | 'waveAnimate' : 'true', 30 | 'waveOffset' : 0.25, 31 | 'textSize' : 0.6, 32 | 'minValue' : 0, 33 | 'maxValue' : 100, 34 | 'waveCount' : 2 35 | } 36 | } 37 | 38 | def __init__(self, client, prefix, deviceID, widgetID, pageId, page): 39 | self.client = client 40 | self.prefix = prefix 41 | self.deviceID = deviceID 42 | self.config['id'] = widgetID 43 | self.config['topic'] = prefix + "/" + deviceID + "/sdcard" 44 | self.config['pageId'] = pageId 45 | self.config['page'] = page 46 | self.t = threading.Timer(10.0, self.send) 47 | self.t.start() 48 | 49 | def send_config(self): 50 | print('Publish config:'+ json.dumps(self.config)) 51 | self.client.publish( self.prefix + "/" + self.deviceID + '/config', json.dumps(self.config)) 52 | self.counter = 5 * 60 / 10 # 5 min send 53 | x = threading.Timer(2.0, self.send) 54 | x.start() 55 | 56 | def send(self): 57 | self.t.cancel() 58 | self.t = threading.Timer(10.0, self.send) 59 | self.t.start() 60 | if(self.counter > 0): 61 | topic = self.prefix + "/" + self.deviceID + "/sdcard/status" 62 | print('Publish ' + topic + ':' + str(self.get())) 63 | self.client.publish(topic, json.dumps({ 'status': self.get()}) ) 64 | 65 | 66 | 67 | def get(self): 68 | st = os.statvfs('/') 69 | return 100 * (st.f_blocks - st.f_bfree) * st.f_frsize / (st.f_blocks * st.f_frsize) 70 | -------------------------------------------------------------------------------- /python/sensor/temp.py: -------------------------------------------------------------------------------- 1 | # iotManager 2 | # RPI Temperature sensor 3 | # @auhtor Alex Suslov 4 | # @created 2016-09-06 5 | # The MIT License (MIT) 6 | # Copyright (c) 2016 AlexSuslov 7 | 8 | import json 9 | import threading 10 | 11 | frame = "STEEL" # BLACK_METAL METAL SHINY_METAL BRASS STEEL CHROME GOLD ANTHRACITE TILTED_GRAY TILTED_BLACK GLOSSY_METAL 12 | color = "RAITH" # RED GREEN BLUE ORANGE YELLOW CYAN MAGENTA WHITE GRAY BLACK RAITH GREEN_LCD JUG_GREEN 13 | bgColor = "CARBON" # DARK_GRAY SATIN_GRAY LIGHT_GRAY WHITE BLACK BEIGE BROWN RED GREEN BLUE ANTHRACITE MUD PUNCHED_SHEET CARBON STAINLESS BRUSHED_METAL BRUSHED_STAINLESS TURNED 14 | lcd = "BLUE_BLUE" # BEIGE BLUE ORANGE RED YELLOW WHITE GRAY BLACK GREEN BLUE2 BLUE_BLACK BLUE_DARKBLUE BLUE_GRAY STANDARD STANDARD_GREEN BLUE_BLUE RED_DARKRED DARKBLUE LILA BLACKRED DARKGREEN AMBER LIGHTBLUE SECTIONS 15 | led = "RED_LED" # RED_LED GREEN_LED BLUE_LED ORANGE_LED YELLOW_LED CYAN_LED 16 | 17 | class Temperature: 18 | counter = 0 19 | t = 0 20 | config = { 21 | 'descr' : "Temp", 22 | 'widget' : "steel", 23 | 'widgetConfig': { 24 | 'titleString' : "Temp", 25 | 'unitString' : "C", 26 | 'type' : "LinearBargraph", 27 | 'width' : "auto", 28 | 'height' : 100, 29 | 'useValueGradient': True, 30 | 'lcdVisible' : True, 31 | 'ledVisible' : True, 32 | 'lcdDecimals' : 1, 33 | 'FrameDesign' : frame, 34 | 'ColorDef' : color, 35 | 'BackgroundColor': bgColor, 36 | 'LcdColor' : lcd, 37 | 'LedColor' : led, 38 | 'maxMeasuredValueVisible' : True, 39 | 'threshold' : 70, 40 | 'minValue' : 20, 41 | 'maxValue' : 85 42 | } 43 | } 44 | 45 | def __init__(self, client, prefix, deviceID, widgetID, pageId, page): 46 | self.client = client 47 | self.prefix = prefix 48 | self.deviceID = deviceID 49 | self.config['id'] = widgetID 50 | self.config['topic'] = prefix + "/" + deviceID + "/temp" 51 | self.config['pageId'] = pageId 52 | self.config['page'] = page 53 | self.t = threading.Timer(10.0, self.send) 54 | self.t.start() 55 | 56 | def send_config(self): 57 | print('Publish config:'+ json.dumps(self.config)) 58 | self.client.publish( self.prefix + "/" + self.deviceID + '/config', json.dumps(self.config)) 59 | self.counter = 5 * 60 / 10 # 5 min send 60 | self.send() 61 | 62 | def send(self): 63 | self.t.cancel() 64 | self.t = threading.Timer(10.0, self.send) 65 | self.t.start() 66 | if(self.counter > 0): 67 | self.counter = self.counter - 1 68 | topic = self.prefix + "/" + self.deviceID + "/temp/status" 69 | print('Publish ' + topic + ':' + str(self.get())) 70 | self.client.publish(topic, json.dumps({ 'status': self.get()}) ) 71 | 72 | def get(self): 73 | with open('/sys/class/thermal/thermal_zone0/temp') as f: 74 | temp = f.readlines() 75 | return 1/1000 * int( str(temp[0]) ) -------------------------------------------------------------------------------- /utils/json2h/README: -------------------------------------------------------------------------------- 1 | Json to C++ header (c) 2017 www.onlims.com\n" 2 | Sergey Alikin, Ricardo Timmermann\n" 3 | 4 | Repository: https://gitlab.com/OnLIMS-public/json2h 5 | 6 | Small command line program for converting json (and any text) file to C header file. 7 | 8 | Use: 9 | json2h jsonfile.json OPTIONS 10 | -r or --reduce 11 | removes from source input all chars with code <= 0x20 to reduce header file size 12 | -c or --colsize VALUE 13 | set item count on each line of result array, default is 12. 14 | -d or --deletecomments 15 | deletes source file as comment in result header file 16 | 17 | Examples of usage: 18 | ./json2h test.json (produce non-reduced output with 12 items on each row) 19 | ./json2h -c 15 -r test.json (produce reduced output with 15 items on each row) 20 | ./json2h test.json -r -c 0 (produce reduced output with one long line) 21 | ./json2h test.json -r -d (produce reduced output, source file did not included into result file) 22 | 23 | Result of program work will JSON_FILE_NAME.h file in the same directory (if file exists it will be overwritten). 24 | 25 | Binaries for different (Linux and Windows) placed into bin/ folder, binaries contains all necessary libraries for start. 26 | -------------------------------------------------------------------------------- /utils/json2h/bin/linux/json2h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4refr0nt/iot-manager-demo/5ceed46ccf538e5bac9b92a03452eed21d27f74f/utils/json2h/bin/linux/json2h -------------------------------------------------------------------------------- /utils/json2h/bin/windows/json2h.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4refr0nt/iot-manager-demo/5ceed46ccf538e5bac9b92a03452eed21d27f74f/utils/json2h/bin/windows/json2h.zip -------------------------------------------------------------------------------- /utils/json2h/json2h.pro: -------------------------------------------------------------------------------- 1 | QT += core 2 | QT -= gui 3 | 4 | CONFIG += c++11 5 | 6 | TARGET = json2h 7 | CONFIG += console 8 | CONFIG -= app_bundle 9 | 10 | TEMPLATE = app 11 | 12 | SOURCES += main.cpp 13 | 14 | DEFINES += QT_DEPRECATED_WARNINGS 15 | 16 | DISTFILES += README 17 | -------------------------------------------------------------------------------- /utils/json2h/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | int main(int argc, char *argv[]) 9 | { 10 | QCoreApplication a(argc, argv); 11 | 12 | QCommandLineParser parser; 13 | parser.addOption({{"c", "colsize"}, "Count of hex values in one row", "colsize", "12"}); 14 | parser.addOption({{"r", "reduce"}, "Remove all chars <= space from source text"}); 15 | parser.addOption({{"d", "deletecomments"}, "Delete comments with sourece file contentfrom result h file"}); 16 | parser.process(a); 17 | 18 | if (parser.positionalArguments().size() == 1) { 19 | QFile jsonFile(parser.positionalArguments().at(0)); 20 | QString jsonFilename(QFileInfo(jsonFile).fileName().remove(QRegularExpression("(\\.[^.]+)$"))); 21 | 22 | if (jsonFile.exists() == true) { 23 | if (jsonFile.open(QIODevice::ReadOnly) == true) { 24 | QByteArray jsonRawContent; 25 | QString jsonHexContent; 26 | jsonRawContent = jsonFile.readAll(); 27 | jsonFile.close(); 28 | if (parser.isSet("deletecomments") == false) 29 | jsonHexContent.append(QString("/** Source file %1\n").arg(jsonFile.fileName()) + jsonRawContent + "**/\n"); 30 | if (parser.isSet("reduce")) 31 | jsonRawContent = QString(jsonRawContent).remove(QRegularExpression("\\s+(?=([^\"]*\"[^\"]*\")*[^\"]*$)")).toLocal8Bit(); 32 | jsonRawContent.append(char(0x00)); 33 | jsonHexContent.append(QString("const char %1_json[] = {\n").arg(jsonFilename)); 34 | 35 | int colCount = 0; 36 | for (const unsigned char jsonChar : jsonRawContent) { 37 | QString hexValue(QString::number(jsonChar, 16)); 38 | if (hexValue.size() == 1) 39 | hexValue.push_front("0"); 40 | hexValue.push_front("0x"); 41 | hexValue.append(", "); 42 | jsonHexContent.append(hexValue); 43 | if (parser.value("colsize").toInt() > 0) 44 | if (++colCount == parser.value("colsize").toInt()) { 45 | colCount = 0; 46 | jsonHexContent.append('\n'); 47 | } 48 | } 49 | jsonHexContent.append(QString("};\nconst int %1_len = %2;\n").arg(jsonFilename).arg(jsonRawContent.size())); 50 | 51 | QFile hFile(jsonFile.fileName() + ".h"); 52 | if (hFile.open(QIODevice::WriteOnly)) { 53 | hFile.write(jsonHexContent.toLocal8Bit()); 54 | hFile.close(); 55 | qDebug() << "Header file" << hFile.fileName() << "has been wrote success"; 56 | } 57 | else 58 | qDebug() << "Can't write data to header file" << hFile.fileName(); 59 | } 60 | else 61 | qDebug() << "Can't open file" << jsonFilename; 62 | } 63 | else 64 | qDebug() << "File" << jsonFilename << "not exists"; 65 | } 66 | else 67 | qDebug() << "Json to C++ header (c) 2017 https://www.onlims.com/\r\n" 68 | "Sergey Alikin, Ricardo Timmermann\r\n" 69 | "Repository: https://gitlab.com/OnLIMS-public/json2h\r\n" 70 | "\r\n" 71 | "Use:\r\n" 72 | "json2h jsonfile.json OPTIONS\r\n" 73 | "-r or --reduce\r\n\tremoves from source input all chars with code <= 0x20 to reduce header file size\r\n" 74 | "-c or --colsize VALUE\r\n\tset item count on each line of result array, default is 12.\r\n" 75 | "-d or --deletecomments\r\n\tDeletes source file as comment in result header file\r\n" 76 | "\r\n" 77 | "Examples of usage:\r\n" 78 | "./json2h test.json (produce non-reduced output with 12 items on each row)\r\n" 79 | "./json2h -c 15 -r test.json (produce reduced output with 15 items on each row)\r\n" 80 | "./json2h test.json -r -c 0 (produce reduced output with one long line)\r\n" 81 | "./json2h test.json -r -d (produce reduced output, source file did not included into result file)\r\n"; 82 | 83 | return 0; 84 | } 85 | -------------------------------------------------------------------------------- /utils/json2h/samples/test1.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "0001", 3 | "type": "donut", 4 | "name": "Cake", 5 | "ppu": 0.55, 6 | "batters": 7 | { 8 | "batter": 9 | [ 10 | { "id": "1001", "type": "Regular" }, 11 | { "id": "1002", "type": "Chocolate" }, 12 | { "id": "1003", "type": "Blueberry" }, 13 | { "id": "1004", "type": "Devil's Food" } 14 | ] 15 | }, 16 | "topping": 17 | [ 18 | { "id": "5001", "type": "None" }, 19 | { "id": "5002", "type": "Glazed" }, 20 | { "id": "5005", "type": "Sugar" }, 21 | { "id": "5007", "type": "Powdered Sugar" }, 22 | { "id": "5006", "type": "Chocolate with Sprinkles" }, 23 | { "id": "5003", "type": "Chocolate" }, 24 | { "id": "5004", "type": "Maple" } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /utils/json2h/samples/test1.json.h: -------------------------------------------------------------------------------- 1 | const char test1_json[] = { 2 | 0x7b, 0x22, 0x69, 0x64, 0x22, 0x3a, 0x22, 0x30, 0x30, 0x30, 0x31, 0x22, 3 | 0x2c, 0x22, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3a, 0x22, 0x64, 0x6f, 0x6e, 4 | 0x75, 0x74, 0x22, 0x2c, 0x22, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x3a, 0x22, 5 | 0x43, 0x61, 0x6b, 0x65, 0x22, 0x2c, 0x22, 0x70, 0x70, 0x75, 0x22, 0x3a, 6 | 0x30, 0x2e, 0x35, 0x35, 0x2c, 0x22, 0x62, 0x61, 0x74, 0x74, 0x65, 0x72, 7 | 0x73, 0x22, 0x3a, 0x7b, 0x22, 0x62, 0x61, 0x74, 0x74, 0x65, 0x72, 0x22, 8 | 0x3a, 0x5b, 0x7b, 0x22, 0x69, 0x64, 0x22, 0x3a, 0x22, 0x31, 0x30, 0x30, 9 | 0x31, 0x22, 0x2c, 0x22, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3a, 0x22, 0x52, 10 | 0x65, 0x67, 0x75, 0x6c, 0x61, 0x72, 0x22, 0x7d, 0x2c, 0x7b, 0x22, 0x69, 11 | 0x64, 0x22, 0x3a, 0x22, 0x31, 0x30, 0x30, 0x32, 0x22, 0x2c, 0x22, 0x74, 12 | 0x79, 0x70, 0x65, 0x22, 0x3a, 0x22, 0x43, 0x68, 0x6f, 0x63, 0x6f, 0x6c, 13 | 0x61, 0x74, 0x65, 0x22, 0x7d, 0x2c, 0x7b, 0x22, 0x69, 0x64, 0x22, 0x3a, 14 | 0x22, 0x31, 0x30, 0x30, 0x33, 0x22, 0x2c, 0x22, 0x74, 0x79, 0x70, 0x65, 15 | 0x22, 0x3a, 0x22, 0x42, 0x6c, 0x75, 0x65, 0x62, 0x65, 0x72, 0x72, 0x79, 16 | 0x22, 0x7d, 0x2c, 0x7b, 0x22, 0x69, 0x64, 0x22, 0x3a, 0x22, 0x31, 0x30, 17 | 0x30, 0x34, 0x22, 0x2c, 0x22, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3a, 0x22, 18 | 0x44, 0x65, 0x76, 0x69, 0x6c, 0x27, 0x73, 0x20, 0x46, 0x6f, 0x6f, 0x64, 19 | 0x22, 0x7d, 0x5d, 0x7d, 0x2c, 0x22, 0x74, 0x6f, 0x70, 0x70, 0x69, 0x6e, 20 | 0x67, 0x22, 0x3a, 0x5b, 0x7b, 0x22, 0x69, 0x64, 0x22, 0x3a, 0x22, 0x35, 21 | 0x30, 0x30, 0x31, 0x22, 0x2c, 0x22, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3a, 22 | 0x22, 0x4e, 0x6f, 0x6e, 0x65, 0x22, 0x7d, 0x2c, 0x7b, 0x22, 0x69, 0x64, 23 | 0x22, 0x3a, 0x22, 0x35, 0x30, 0x30, 0x32, 0x22, 0x2c, 0x22, 0x74, 0x79, 24 | 0x70, 0x65, 0x22, 0x3a, 0x22, 0x47, 0x6c, 0x61, 0x7a, 0x65, 0x64, 0x22, 25 | 0x7d, 0x2c, 0x7b, 0x22, 0x69, 0x64, 0x22, 0x3a, 0x22, 0x35, 0x30, 0x30, 26 | 0x35, 0x22, 0x2c, 0x22, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3a, 0x22, 0x53, 27 | 0x75, 0x67, 0x61, 0x72, 0x22, 0x7d, 0x2c, 0x7b, 0x22, 0x69, 0x64, 0x22, 28 | 0x3a, 0x22, 0x35, 0x30, 0x30, 0x37, 0x22, 0x2c, 0x22, 0x74, 0x79, 0x70, 29 | 0x65, 0x22, 0x3a, 0x22, 0x50, 0x6f, 0x77, 0x64, 0x65, 0x72, 0x65, 0x64, 30 | 0x20, 0x53, 0x75, 0x67, 0x61, 0x72, 0x22, 0x7d, 0x2c, 0x7b, 0x22, 0x69, 31 | 0x64, 0x22, 0x3a, 0x22, 0x35, 0x30, 0x30, 0x36, 0x22, 0x2c, 0x22, 0x74, 32 | 0x79, 0x70, 0x65, 0x22, 0x3a, 0x22, 0x43, 0x68, 0x6f, 0x63, 0x6f, 0x6c, 33 | 0x61, 0x74, 0x65, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x53, 0x70, 0x72, 34 | 0x69, 0x6e, 0x6b, 0x6c, 0x65, 0x73, 0x22, 0x7d, 0x2c, 0x7b, 0x22, 0x69, 35 | 0x64, 0x22, 0x3a, 0x22, 0x35, 0x30, 0x30, 0x33, 0x22, 0x2c, 0x22, 0x74, 36 | 0x79, 0x70, 0x65, 0x22, 0x3a, 0x22, 0x43, 0x68, 0x6f, 0x63, 0x6f, 0x6c, 37 | 0x61, 0x74, 0x65, 0x22, 0x7d, 0x2c, 0x7b, 0x22, 0x69, 0x64, 0x22, 0x3a, 38 | 0x22, 0x35, 0x30, 0x30, 0x34, 0x22, 0x2c, 0x22, 0x74, 0x79, 0x70, 0x65, 39 | 0x22, 0x3a, 0x22, 0x4d, 0x61, 0x70, 0x6c, 0x65, 0x22, 0x7d, 0x5d, 0x7d, 40 | 0x00, }; 41 | const int test1_len = 457; 42 | --------------------------------------------------------------------------------