├── .gitattributes ├── .gitignore ├── KMPDinoEthernet ├── .gitignore ├── README.md ├── Releases │ ├── Ethernet_1.1.2.zip │ ├── Ethernet_1.1.3.zip │ ├── KMPDinoEthernet_1.2.0.zip │ ├── KMPDinoEthernet_1.2.2.zip │ ├── KMPDinoEthernet_1.2.3.zip │ ├── KMPDinoEthernet_1.2.4.zip │ ├── KMPDinoEthernet_1.2.5.1.zip │ ├── KMPDinoEthernet_1.2.5.zip │ ├── KMPDinoEthernet_1.2.6.zip │ ├── KMPDinoEthernet_1.3.0.zip │ ├── KMPDinoEthernet_1.4.0.zip │ ├── KMPDinoEthernet_1.4.1.zip │ ├── KMPDinoEthernet_1.4.2.zip │ ├── KMPDinoEthernet_1.4.3.zip │ ├── KMPDinoEthernet_1.5.0.zip │ ├── KMPDinoEthernet_1.6.0.zip │ ├── KMPDinoEthernet_1.6.1.zip │ └── Last │ │ └── KMPDinoEthernet.zip └── src │ └── KMPDinoEthernet │ ├── README.md │ ├── examples │ ├── MqttSimple │ │ └── MqttSimple.ino │ ├── RS485Echo │ │ └── RS485Echo.ino │ ├── TcpOptoInput │ │ └── TcpOptoInput.ino │ ├── TcpRelay │ │ └── TcpRelay.ino │ ├── TcpRelayInput │ │ └── TcpRelayInput.ino │ ├── TcpTemperature │ │ └── TcpTemperature.ino │ ├── UdpOptoInput │ │ └── UdpOptoInput.ino │ ├── UdpRelay │ │ └── UdpRelay.ino │ ├── WebOptoInputs │ │ └── WebOptoInputs.ino │ ├── WebPing │ │ └── WebPing.ino │ ├── WebRS485 │ │ └── WebRS485.ino │ ├── WebRS485Hex │ │ └── WebRS485Hex.ino │ ├── WebRelay │ │ └── WebRelay.ino │ ├── WebRelayOptoIn │ │ └── WebRelayOptoIn.ino │ ├── WebTemperature │ │ └── WebTemperature.ino │ └── projects │ │ ├── ProDinoIntRelay │ │ ├── HtmlPages.cpp │ │ ├── HtmlPages.h │ │ ├── ProDinoIntRelay.ino │ │ ├── Processing.cpp │ │ ├── Processing.h │ │ ├── Structures.cpp │ │ ├── Structures.h │ │ └── version.txt │ │ └── ProDinoWatchDog │ │ ├── HtmlPages.cpp │ │ ├── HtmlPages.h │ │ ├── ProDinoWatchDog.ino │ │ ├── Processing.cpp │ │ ├── Processing.h │ │ ├── Structures.cpp │ │ └── Structures.h │ ├── keywords.txt │ ├── library.properties │ ├── src │ ├── Base64.cpp │ ├── Base64.h │ ├── DallasTemperature.cpp │ ├── DallasTemperature.h │ ├── Ethernet │ │ ├── Dhcp.cpp │ │ ├── Dhcp.h │ │ ├── Dns.cpp │ │ ├── Dns.h │ │ ├── Ethernet.cpp │ │ ├── Ethernet.h │ │ ├── EthernetClient.cpp │ │ ├── EthernetClient.h │ │ ├── EthernetServer.cpp │ │ ├── EthernetServer.h │ │ ├── EthernetUdp.cpp │ │ ├── EthernetUdp.h │ │ ├── Twitter.cpp │ │ ├── Twitter.h │ │ └── utility │ │ │ ├── socket.cpp │ │ │ ├── socket.h │ │ │ ├── util.h │ │ │ ├── w5100.cpp │ │ │ ├── w5100.h │ │ │ ├── w5200.cpp │ │ │ ├── w5200.h │ │ │ ├── w5500.cpp │ │ │ └── w5500.h │ ├── ICMPProtocol.cpp │ ├── ICMPProtocol.h │ ├── KMPCommon.cpp │ ├── KMPCommon.h │ ├── KmpDinoEthernet.cpp │ ├── KmpDinoEthernet.h │ ├── MqttTopicHelper.cpp │ ├── MqttTopicHelper.h │ ├── OneWire.cpp │ └── OneWire.h │ └── version.txt ├── ProDinoESP32_2 ├── examples │ ├── AllE │ │ └── AllE.ino │ ├── AllW │ │ ├── AllW.ino │ │ └── arduino_secrets.h │ ├── AllWE │ │ ├── AllWE.ino │ │ └── arduino_secrets.h │ ├── AllWEG │ │ ├── AllWEG.ino │ │ └── arduino_secrets.h │ ├── AllWE_F │ │ ├── AllWE_F.ino │ │ └── arduino_secrets.h │ ├── BlynkG │ │ ├── BlynkG.ino │ │ └── arduino_secrets.h │ ├── BlynkWE │ │ ├── BlynkWE.ino │ │ └── arduino_secrets.h │ ├── MqttSimpleG │ │ ├── MqttSimpleG.ino │ │ └── arduino_secrets.h │ ├── MqttSimpleWE │ │ ├── MqttSimpleWE.ino │ │ └── arduino_secrets.h │ ├── RS485Echo │ │ └── RS485Echo.ino │ ├── RS485Input │ │ └── RS485Input.ino │ ├── RS485Relay │ │ └── RS485Relay.ino │ ├── TCPInputWE │ │ ├── TCPInputWE.ino │ │ └── arduino_secrets.h │ ├── TCPRelayWE │ │ ├── TCPRelayWE.ino │ │ └── arduino_secrets.h │ ├── UDPInputWE │ │ ├── UDPInputWE.ino │ │ └── arduino_secrets.h │ ├── UDPRelayWE │ │ ├── UDPRelayWE.ino │ │ └── arduino_secrets.h │ ├── Web1WireWE │ │ ├── Web1WireWE.ino │ │ └── arduino_secrets.h │ ├── WebDHTWE │ │ ├── WebDHTWE.ino │ │ └── arduino_secrets.h │ ├── WebInputWE │ │ ├── WebInputWE.ino │ │ └── arduino_secrets.h │ ├── WebRS485WE │ │ ├── WebRS485WE.ino │ │ └── arduino_secrets.h │ ├── WebRelayWE │ │ ├── WebRelayWE.ino │ │ └── arduino_secrets.h │ ├── _StatusLed │ │ └── _StatusLed.ino │ └── _nkrgsmlib_sms │ │ └── _nkrgsmlib_sms.ino ├── keywords.txt ├── library.properties └── src │ ├── Ethernet │ ├── Dhcp.cpp │ ├── Dhcp.h │ ├── Dns.cpp │ ├── Dns.h │ ├── Ethernet.cpp │ ├── Ethernet.h │ ├── EthernetClient.cpp │ ├── EthernetClient.h │ ├── EthernetServer.cpp │ ├── EthernetServer.h │ ├── EthernetUdp.cpp │ ├── EthernetUdp.h │ ├── socket.cpp │ └── utility │ │ ├── w5100.cpp │ │ └── w5100.h │ ├── KMPCommon.cpp │ ├── KMPCommon.h │ ├── KMPProDinoESP32.cpp │ ├── KMPProDinoESP32.h │ ├── KMPRS485Serial._cpp │ ├── KMPRS485Serial._h │ ├── MCP23S08.cpp │ ├── MCP23S08.h │ ├── MKRGSM │ ├── CHANGELOG │ ├── README.adoc │ ├── keywords.txt │ ├── library.properties │ └── src │ │ ├── GPRS.cpp │ │ ├── GPRS.h │ │ ├── GSM.cpp │ │ ├── GSM.h │ │ ├── GSMBand.cpp │ │ ├── GSMBand.h │ │ ├── GSMClient.cpp │ │ ├── GSMClient.h │ │ ├── GSMFileUtils.cpp │ │ ├── GSMFileUtils.h │ │ ├── GSMLocation.cpp │ │ ├── GSMLocation.h │ │ ├── GSMModem.cpp │ │ ├── GSMModem.h │ │ ├── GSMPIN.cpp │ │ ├── GSMPIN.h │ │ ├── GSMSSLClient.cpp │ │ ├── GSMSSLClient.h │ │ ├── GSMScanner.cpp │ │ ├── GSMScanner.h │ │ ├── GSMServer.cpp │ │ ├── GSMServer.h │ │ ├── GSMUdp.cpp │ │ ├── GSMUdp.h │ │ ├── GSMVoiceCall.cpp │ │ ├── GSMVoiceCall.h │ │ ├── GSM_SMS.cpp │ │ ├── GSM_SMS.h │ │ ├── MKRGSM.h │ │ ├── Modem.cpp │ │ ├── Modem.h │ │ └── utility │ │ ├── GSMRootCerts.h │ │ ├── GSMSocketBuffer.cpp │ │ └── GSMSocketBuffer.h │ └── NeoPixel │ ├── NeoPixelAnimator.h │ ├── NeoPixelBrightnessBus.h │ ├── NeoPixelBus.h │ └── internal │ ├── DotStarAvrMethod.h │ ├── DotStarColorFeatures.h │ ├── DotStarGenericMethod.h │ ├── DotStarSpiMethod.h │ ├── Esp32_i2s.c │ ├── Esp32_i2s.h │ ├── HsbColor.cpp │ ├── HsbColor.h │ ├── HslColor.cpp │ ├── HslColor.h │ ├── HtmlColor.cpp │ ├── HtmlColor.h │ ├── HtmlColorNameStrings.cpp │ ├── HtmlColorNameStrings.h │ ├── HtmlColorNames.cpp │ ├── HtmlColorShortNames.cpp │ ├── Layouts.h │ ├── NeoArmMethod.h │ ├── NeoAvrMethod.h │ ├── NeoBitmapFile.h │ ├── NeoBuffer.h │ ├── NeoBufferContext.h │ ├── NeoBufferMethods.h │ ├── NeoColorFeatures.h │ ├── NeoDib.h │ ├── NeoEase.h │ ├── NeoEsp32I2sMethod.h │ ├── NeoEsp8266DmaMethod.h │ ├── NeoEsp8266UartMethod.cpp │ ├── NeoEsp8266UartMethod.h │ ├── NeoEspBitBangMethod.h │ ├── NeoGamma.cpp │ ├── NeoGamma.h │ ├── NeoHueBlend.h │ ├── NeoMosaic.h │ ├── NeoPixelAnimator.cpp │ ├── NeoPixelAvr.c │ ├── NeoPixelEsp.c │ ├── NeoRingTopology.h │ ├── NeoSpriteSheet.h │ ├── NeoTiles.h │ ├── NeoTopology.h │ ├── RgbColor.cpp │ ├── RgbColor.h │ ├── RgbwColor.cpp │ └── RgbwColor.h ├── ProDinoMKRZero ├── releases │ ├── ProDinoMKRZero_1.0.0.zip │ ├── ProDinoMKRZero_1.0.1.zip │ ├── ProDinoMKRZero_1.0.4.zip │ ├── ProDinoMKRZero_1.0.5.zip │ ├── ProDinoMKRZero_1.0.6.zip │ ├── ProDinoMKRZero_1.0.7.zip │ ├── ProDinoMKRZero_1.0.8.zip │ └── last │ │ └── ProDinoMKRZero.zip └── src │ └── ProDinoMKRZero │ ├── examples │ ├── BlynkGSMTiny │ │ └── BlynkGSMTiny.ino │ ├── BlynkOne │ │ └── BlynkOne.ino │ ├── GPRSUdpNtpTest │ │ ├── GPRSUdpNtpTest.ino │ │ └── arduino_secrets.h │ ├── MqttBase │ │ └── MqttBase.ino │ ├── MqttSimple │ │ └── MqttSimple.ino │ ├── RS485Echo │ │ └── RS485Echo.ino │ ├── RS485Input │ │ └── RS485Input.ino │ ├── RS485Relay │ │ └── RS485Relay.ino │ ├── TCPInput │ │ └── TCPInput.ino │ ├── TCPRelay │ │ └── TCPRelay.ino │ ├── UDPInput │ │ └── UDPInput.ino │ ├── UDPRelay │ │ └── UDPRelay.ino │ ├── Web1Wire │ │ └── Web1Wire.ino │ ├── WebDHT │ │ └── WebDHT.ino │ ├── WebInput │ │ └── WebInput.ino │ ├── WebRS485 │ │ └── WebRS485.ino │ └── WebRelay │ │ └── WebRelay.ino │ ├── keywords.txt │ ├── library.properties │ └── src │ ├── KMPCommon.cpp │ ├── KMPCommon.h │ ├── KMPProDinoMKRZero.cpp │ ├── KMPProDinoMKRZero.h │ ├── MqttTopicHelper.cpp │ └── MqttTopicHelper.h └── ProDinoWiFiEsp ├── ProDinoWiFiArduinoSettings.PNG ├── README.md ├── releases ├── PRODINoESP8266_1.0.0.zip ├── PRODINoESP8266_1.0.2.zip ├── PRODINoESP8266_2.0.0.zip ├── PRODINoESP8266_2.0.1.zip ├── PRODINoESP8266_2.2.0.zip └── last │ └── PRODINoESP8266.zip └── src ├── .gitignore └── PRODINoESP8266 ├── examples ├── Inputs1 │ └── Inputs1.ino ├── Relays1 │ └── Relays1.ino ├── WiFiBlynk │ ├── WiFiBlynk.ino │ └── arduino_secrets.h ├── WiFiCloudMqtt │ ├── WiFiCloudMqtt.ino │ └── arduino_secrets.h ├── WiFiWeb1WireSrv │ ├── WiFiWeb1WireSrv.ino │ └── arduino_secrets.h ├── WiFiWebDHTSrv │ ├── WiFiWebDHTSrv.ino │ └── arduino_secrets.h ├── WiFiWebOptoInSrv │ ├── WiFiWebOptoInSrv.ino │ └── arduino_secrets.h ├── WiFiWebRS485 │ ├── WiFiWebRS485.ino │ └── arduino_secrets.h ├── WiFiWebRelaySrv │ ├── WiFiWebRelaySrv.ino │ └── arduino_secrets.h └── WiFiWebRelaySrvAP │ └── WiFiWebRelaySrvAP.ino ├── keywords.txt ├── library.properties └── src ├── KMPCommon.cpp ├── KMPCommon.h ├── KMPDinoWiFiESP.cpp ├── KMPDinoWiFiESP.h ├── MqttTopicHelper.cpp └── MqttTopicHelper.h /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /KMPDinoEthernet/.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.sln -------------------------------------------------------------------------------- /KMPDinoEthernet/README.md: -------------------------------------------------------------------------------- 1 | Welcome to KMPDinoEthernet Library! 2 | =================== 3 | 4 | 5 | This library supports [ProDiNo NetBoard V2.1](http://www.kmpelectronics.eu/en-us/products/prodinoethernet.aspx). More information you can see on our site http://www.kmpelectronics.eu/. 6 | 7 | ---------- 8 | 9 | Installation 10 | ------------- 11 | 12 | This library includes two files. The first includes Ethernet library which it supports Ethernet chip. The second includes board code and examples. The latest version of the library files you can download from [here](https://github.com/kmpelectronics/Arduino/tree/master/KMPDinoEthernet/Releases/Last) and they have to save on your desktop. 13 | #### The installation has two steps: 14 | 1. Ethernet library install (Sketch > Include Library > Add .ZIP Library...) 15 | 2. KMPDinoEthernet install (Sketch > Include Library > Add .ZIP Library...) 16 | 17 | ###How to use Ethernet library with different chips 18 | This library supported the follow chips: WIZnet W5100, WIZnet W5200 and WIZnet W5500 19 | In a file Ethernet\src\utility\w5100.h has block, which chip is using at the moment. 20 | By default for ProDiNo NetBoard V2.1 board we use W5200_ETHERNET_SHIELD and KMPDINOETHERNET. 21 | 22 | >//#define W5100_ETHERNET_SHIELD //Default. Arduino Ethernet Shield and Compatibles ... 23 | > #define W5200_ETHERNET_SHIELD //WIZ820io, W5200 Ethernet Shield 24 | > #define KMPDINOETHERNET //This is set KMP board W5200 specific configuration. 25 | >//#define W5500_ETHERNET_SHIELD //WIZ550io, ioShield series of WIZnet 26 | 27 | If you use standard **Arduino Ethernet shield with W5100**, you have to make follow changes: 28 | > #define W5100_ETHERNET_SHIELD // Default. Arduino Ethernet Shield and Compatibles ... 29 | >//#define W5200_ETHERNET_SHIELD // WIZ820io, W5200 Ethernet Shield 30 | >//#define KMPDINOETHERNET // This is set KMP board W5200 specific configuration. 31 | >//#define W5500_ETHERNET_SHIELD // WIZ550io, ioShield series of WIZnet 32 | 33 | If you use standard **Arduino Ethernet with W5200**, you have to make follow changes: 34 | >//#define W5100_ETHERNET_SHIELD // Default. Arduino Ethernet Shield and Compatibles ... 35 | > #define W5200_ETHERNET_SHIELD // WIZ820io, W5200 Ethernet Shield 36 | >//#define KMPDINOETHERNET // This is set KMP board W5200 specific configuration. 37 | >//#define W5500_ETHERNET_SHIELD // WIZ550io, ioShield series of WIZnet 38 | 39 | If you use standard **Arduino Ethernet shield with W5500**, you have to make follow changes: 40 | >//#define W5100_ETHERNET_SHIELD // Default. Arduino Ethernet Shield and Compatibles ... 41 | >//#define W5200_ETHERNET_SHIELD // WIZ820io, W5200 Ethernet Shield 42 | >//#define KMPDINOETHERNET // This is set KMP board W5200 specific configuration. 43 | > #define W5500_ETHERNET_SHIELD // WIZ550io, ioShield series of WIZnet 44 | -------------------------------------------------------------------------------- /KMPDinoEthernet/Releases/Ethernet_1.1.2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/KMPDinoEthernet/Releases/Ethernet_1.1.2.zip -------------------------------------------------------------------------------- /KMPDinoEthernet/Releases/Ethernet_1.1.3.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/KMPDinoEthernet/Releases/Ethernet_1.1.3.zip -------------------------------------------------------------------------------- /KMPDinoEthernet/Releases/KMPDinoEthernet_1.2.0.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/KMPDinoEthernet/Releases/KMPDinoEthernet_1.2.0.zip -------------------------------------------------------------------------------- /KMPDinoEthernet/Releases/KMPDinoEthernet_1.2.2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/KMPDinoEthernet/Releases/KMPDinoEthernet_1.2.2.zip -------------------------------------------------------------------------------- /KMPDinoEthernet/Releases/KMPDinoEthernet_1.2.3.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/KMPDinoEthernet/Releases/KMPDinoEthernet_1.2.3.zip -------------------------------------------------------------------------------- /KMPDinoEthernet/Releases/KMPDinoEthernet_1.2.4.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/KMPDinoEthernet/Releases/KMPDinoEthernet_1.2.4.zip -------------------------------------------------------------------------------- /KMPDinoEthernet/Releases/KMPDinoEthernet_1.2.5.1.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/KMPDinoEthernet/Releases/KMPDinoEthernet_1.2.5.1.zip -------------------------------------------------------------------------------- /KMPDinoEthernet/Releases/KMPDinoEthernet_1.2.5.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/KMPDinoEthernet/Releases/KMPDinoEthernet_1.2.5.zip -------------------------------------------------------------------------------- /KMPDinoEthernet/Releases/KMPDinoEthernet_1.2.6.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/KMPDinoEthernet/Releases/KMPDinoEthernet_1.2.6.zip -------------------------------------------------------------------------------- /KMPDinoEthernet/Releases/KMPDinoEthernet_1.3.0.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/KMPDinoEthernet/Releases/KMPDinoEthernet_1.3.0.zip -------------------------------------------------------------------------------- /KMPDinoEthernet/Releases/KMPDinoEthernet_1.4.0.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/KMPDinoEthernet/Releases/KMPDinoEthernet_1.4.0.zip -------------------------------------------------------------------------------- /KMPDinoEthernet/Releases/KMPDinoEthernet_1.4.1.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/KMPDinoEthernet/Releases/KMPDinoEthernet_1.4.1.zip -------------------------------------------------------------------------------- /KMPDinoEthernet/Releases/KMPDinoEthernet_1.4.2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/KMPDinoEthernet/Releases/KMPDinoEthernet_1.4.2.zip -------------------------------------------------------------------------------- /KMPDinoEthernet/Releases/KMPDinoEthernet_1.4.3.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/KMPDinoEthernet/Releases/KMPDinoEthernet_1.4.3.zip -------------------------------------------------------------------------------- /KMPDinoEthernet/Releases/KMPDinoEthernet_1.5.0.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/KMPDinoEthernet/Releases/KMPDinoEthernet_1.5.0.zip -------------------------------------------------------------------------------- /KMPDinoEthernet/Releases/KMPDinoEthernet_1.6.0.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/KMPDinoEthernet/Releases/KMPDinoEthernet_1.6.0.zip -------------------------------------------------------------------------------- /KMPDinoEthernet/Releases/KMPDinoEthernet_1.6.1.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/KMPDinoEthernet/Releases/KMPDinoEthernet_1.6.1.zip -------------------------------------------------------------------------------- /KMPDinoEthernet/Releases/Last/KMPDinoEthernet.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/KMPDinoEthernet/Releases/Last/KMPDinoEthernet.zip -------------------------------------------------------------------------------- /KMPDinoEthernet/src/KMPDinoEthernet/README.md: -------------------------------------------------------------------------------- 1 | KMPDinoEthernet 2 | =============== 3 | This library support our ProDiNo NetBoard V2.1 hardware. 4 | For more information see here: http://www.kmpelectronics.eu/en-us/products/prodinoethernet.aspx 5 | -------------------------------------------------------------------------------- /KMPDinoEthernet/src/KMPDinoEthernet/examples/RS485Echo/RS485Echo.ino: -------------------------------------------------------------------------------- 1 | // RS485Echo.ino 2 | // Company: KMP Electronics Ltd, Bulgaria 3 | // Web: https://kmpelectronics.eu/ 4 | // License: See the GNU General Public License for more details at http://www.gnu.org/copyleft/gpl.html 5 | // Supported boards: 6 | // - KMP ProDiNo Ethernet V2 https://kmpelectronics.eu/products/prodino-ethernet-v2/ 7 | // Description: 8 | // RS485 echo test example. 9 | // Example link: https://kmpelectronics.eu/tutorials-examples/prodino-ethernet-examples/ 10 | // Version: 1.3.0 11 | // Date: 27.02.2019 12 | // Author: Plamen Kovandjiev 13 | // Description: Compatibilie Arduinio version >= 1.6.5 14 | // Warning! RS485 don't work Arduino version from 1.5.6 to 1.6.4. Please use the version: >=1.6.5. 15 | 16 | #include "KmpDinoEthernet.h" 17 | #include "KMPCommon.h" 18 | 19 | // If in debug mode - print debug information in Serial. Comment in production code, this bring performance. 20 | // This method is good for development and verification of results. But increases the amount of code and decreases performance. 21 | //#define DEBUG 22 | 23 | const uint8_t BUFF_MAX = 255; 24 | 25 | uint8_t _dataBuffer[BUFF_MAX]; 26 | 27 | /** 28 | * \brief Setup void. Arduino executed first. Initialize DiNo board and prepare Ethernet connection. 29 | * 30 | * 31 | * \return void 32 | */ 33 | void setup() 34 | { 35 | #ifdef DEBUG 36 | // Open serial communications and wait for port to open: 37 | Serial.begin(9600); 38 | //while (!Serial) { 39 | // ; // wait for serial port to connect. Needed for Leonardo only. If need debug setup() void. 40 | //} 41 | #endif 42 | 43 | // Init Dino board. Set pins and stop W5200. For this example W5200 not need to work. 44 | DinoInit(false); 45 | 46 | // Start RS485 with boud 19200 and 8N1. 47 | RS485Begin(19200); 48 | } 49 | 50 | /** 51 | * \brief Loop void. Arduino executed second. 52 | * 53 | * 54 | * \return void 55 | */ 56 | void loop() 57 | { 58 | int i = RS485Read(); 59 | 60 | // if i = -1 not data to read. 61 | if (i = -1) 62 | { 63 | return; 64 | } 65 | 66 | // If data send - On status led. 67 | OnStatusLed(); 68 | 69 | uint8_t buffPos = 0; 70 | 71 | while(i > -1 && buffPos < BUFF_MAX) 72 | { 73 | _dataBuffer[buffPos++] = i; 74 | #ifdef DEBUG 75 | Serial.write((char)i); 76 | #endif 77 | // Read next char. 78 | i = RS485Read(); 79 | } 80 | 81 | uint8_t sendPos = 0; 82 | while (sendPos < buffPos) 83 | { 84 | RS485Write(_dataBuffer[sendPos++]); 85 | } 86 | 87 | // Off status led. 88 | OffStatusLed(); 89 | } -------------------------------------------------------------------------------- /KMPDinoEthernet/src/KMPDinoEthernet/examples/projects/ProDinoIntRelay/HtmlPages.h: -------------------------------------------------------------------------------- 1 | // HtmlPages.h 2 | // Company: KMP Electronics Ltd, Bulgaria 3 | // Web: http://kmpelectronics.eu/ 4 | // License: See the GNU General Public License for more details at http://www.gnu.org/copyleft/gpl.html 5 | // Project: 6 | // ProDino Internet relay. 7 | // Version: 1.0.0 8 | // Date: 10.12.2014 9 | // Author: Plamen Kovandjiev 10 | 11 | #ifndef _HTMLPAGES_h 12 | #define _HTMLPAGES_h 13 | 14 | #if defined(ARDUINO) && ARDUINO >= 100 15 | #include "Arduino.h" 16 | #else 17 | #include "WProgram.h" 18 | #endif 19 | 20 | #include 21 | #include "Structures.h" 22 | 23 | class HtmlPages 24 | { 25 | private: 26 | 27 | public: 28 | void init(EthernetClient& ec); 29 | 30 | void index(); 31 | void notFound(); 32 | //void pingIP(); 33 | void unAuthorized(); 34 | void privateSettings(RelayData* dogData, ValidationData* validData = NULL, uint8_t showError = 0, uint8_t showSuccess = 0); 35 | void privateUserAndIP(DeviceSetting& deviceSettings, ValidationData* validData = NULL, uint8_t showError = 0, uint8_t showSuccess = 0); 36 | }; 37 | 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /KMPDinoEthernet/src/KMPDinoEthernet/examples/projects/ProDinoIntRelay/Processing.h: -------------------------------------------------------------------------------- 1 | // Processing.h 2 | // Company: KMP Electronics Ltd, Bulgaria 3 | // Web: http://kmpelectronics.eu/ 4 | // License: See the GNU General Public License for more details at http://www.gnu.org/copyleft/gpl.html 5 | // Project: 6 | // ProDino Internet relay. 7 | // Version: 1.0.0 8 | // Date: 21.12.2014 9 | // Author: Plamen Kovandjiev 10 | 11 | #ifndef _PROCESSING_H 12 | #define _PROCESSING_H 13 | 14 | #if defined(ARDUINO) && ARDUINO >= 100 15 | #include "Arduino.h" 16 | #else 17 | #include "WProgram.h" 18 | #endif 19 | 20 | #include 21 | 22 | class Processing 23 | { 24 | private: 25 | 26 | public: 27 | /** 28 | * \brief Initialize data. Read from EEPROM. 29 | * 30 | * 31 | * \return void 32 | */ 33 | void init(); 34 | 35 | 36 | /** 37 | * \brief Reset settings by default. 38 | * 39 | * 40 | * \return void 41 | */ 42 | void resetSettings(); 43 | 44 | /** 45 | * \brief Read client request parse and write needed response. 46 | * 47 | * \param client Ethernet client. 48 | * 49 | * \return void 50 | */ 51 | void processRequest(EthernetClient& client); 52 | 53 | /** 54 | * \brief Check is addresses (IP, Subnet, Gateway) changed. 55 | * 56 | * 57 | * \return bool If result equal True - addresses changed, else no change. 58 | */ 59 | bool IsAddressesChanged(); 60 | 61 | /** 62 | * \brief Set value to AddressesChanged. 63 | * 64 | * \param b New value. 65 | * 66 | * \return void 67 | */ 68 | void SetAddressesChanged(bool b); 69 | }; 70 | 71 | #endif -------------------------------------------------------------------------------- /KMPDinoEthernet/src/KMPDinoEthernet/examples/projects/ProDinoIntRelay/Structures.cpp: -------------------------------------------------------------------------------- 1 | // Structures.cpp 2 | // Company: KMP Electronics Ltd, Bulgaria 3 | // Web: http://kmpelectronics.eu/ 4 | // License: See the GNU General Public License for more details at http://www.gnu.org/copyleft/gpl.html 5 | // Project: 6 | // ProDino Internet relay. 7 | // Version: 1.0.0 8 | // Date: 10.12.2014 9 | // Author: Plamen Kovandjiev 10 | 11 | #include "Structures.h" 12 | #include "KMPCommon.h" 13 | 14 | const char DEF_User[] = "admin"; 15 | const char DEF_Password[] = "admin"; 16 | const char DEF_RelayName[] = "Relay "; 17 | const char DEF_DeviceName[] = "KMP Device"; 18 | const uint8_t DEF_IPAddress[] = { 192, 168, 0, 100 }; 19 | const uint8_t DEF_SubnetMask[] = { 255, 255, 255, 0 }; 20 | const uint8_t DEF_Gateway[] = { 192, 168, 0, 1 }; 21 | 22 | DeviceSetting DeviceData; 23 | RelayData RelayDataList[RELAY_COUNT]; 24 | 25 | RelayData RelayDataNewList[RELAY_COUNT]; 26 | ValidationData ValidationForRelayDataNewList[VALID_DATA_LEN]; 27 | 28 | DeviceSetting DeviceDataNew; 29 | ValidationData ValidUserAndIP[VALID_USER_AND_IP_LEN]; 30 | 31 | void DEF_DeviceSetting(DeviceSetting & ds) 32 | { 33 | strNCopy(ds.DeviceName, DEF_DeviceName, sizeof(DEF_DeviceName)); 34 | 35 | strNCopy(ds.User, DEF_User, sizeof(DEF_User)); 36 | 37 | strNCopy(ds.Password, DEF_Password, sizeof(DEF_Password)); 38 | 39 | for (uint8_t i = 0; i < IP_LEN; i++) 40 | { 41 | ds.IP[i] = DEF_IPAddress[i]; 42 | } 43 | 44 | for (uint8_t i = 0; i < IP_LEN; i++) 45 | { 46 | ds.SubnetMask[i] = DEF_SubnetMask[i]; 47 | } 48 | 49 | for (uint8_t i = 0; i < IP_LEN; i++) 50 | { 51 | ds.Gateway[i] = DEF_Gateway[i]; 52 | } 53 | } 54 | 55 | void DEF_RelayData(RelayData & data, uint8_t relay) 56 | { 57 | data.Active = 1; // Active. 58 | 59 | uint8_t len = sizeof(DEF_RelayName); 60 | strNCopy(data.RelayName, DEF_RelayName, len); 61 | 62 | data.RelayName[len - 1] = ONE_TO_FOUR[relay]; 63 | } 64 | 65 | void DEF_RelayDataList() 66 | { 67 | for (uint8_t i = 0; i < RELAY_COUNT; i++) 68 | { 69 | DEF_RelayData(RelayDataList[i], i); 70 | } 71 | } -------------------------------------------------------------------------------- /KMPDinoEthernet/src/KMPDinoEthernet/examples/projects/ProDinoIntRelay/Structures.h: -------------------------------------------------------------------------------- 1 | // Structures.h 2 | // Company: KMP Electronics Ltd, Bulgaria 3 | // Web: http://kmpelectronics.eu/ 4 | // License: See the GNU General Public License for more details at http://www.gnu.org/copyleft/gpl.html 5 | // Project: 6 | // ProDino Internet relay. 7 | // Version: 1.0.0 8 | // Date: 10.12.2014 9 | // Author: Plamen Kovandjiev 10 | 11 | #ifndef _STRUCTURES_h 12 | #define _STRUCTURES_h 13 | 14 | #if defined(ARDUINO) && ARDUINO >= 100 15 | #include "Arduino.h" 16 | #else 17 | #include "WProgram.h" 18 | #endif 19 | 20 | #include "KmpDinoEthernet.h" 21 | #include "KMPCommon.h" 22 | 23 | // User, password length 24 | #define USER_PAS_LEN 8 25 | #define DEVICE_NAME_LEN 32 26 | #define RELAY_NAME_LEN 16 27 | 28 | const uint8_t WAN_PORT = 80; 29 | const uint8_t MAC_ADDRESS[] = { 0x80, 0x9B, 0x20, 0xBF, 0x91, 0xF6 }; 30 | 31 | const char PREFF_CB[]PROGMEM = "cb"; 32 | const char PREFF_RN[]PROGMEM = "rn"; 33 | const char PREFF_TP[]PROGMEM = "tp"; 34 | const char PREFF_HL[]PROGMEM = "hl"; 35 | const char PREFF_RW[]PROGMEM = "rw"; 36 | const char PREFF_WA[]PROGMEM = "wa"; 37 | const char PREFF_DN[]PROGMEM = "DN"; 38 | const char PREFF_US[]PROGMEM = "US"; 39 | const char PREFF_PS[]PROGMEM = "PS"; 40 | const char PREFF_SN[]PROGMEM = "SN"; 41 | const char PREFF_GW[]PROGMEM = "GW"; 42 | 43 | const char ONE_TO_FOUR[] = "1234"; 44 | 45 | const uint8_t DATA_ROW_COUNT = 2; 46 | 47 | const uint8_t VALID_DATA_LEN = RELAY_COUNT * DATA_ROW_COUNT; 48 | 49 | const uint8_t VALID_USER_AND_IP_LEN = 6; 50 | 51 | const uint8_t MAX_IP_STR_LEN = 16; 52 | 53 | const uint8_t INDEX_PAGE_REFRESH_RATE = 60; 54 | 55 | /** 56 | * \brief Web pages. 57 | */ 58 | enum WebPages 59 | { 60 | WP_NONE = -1, WP_INDEX, WP_SETTINGS, WP_USERANDIP 61 | }; 62 | 63 | 64 | /** 65 | * \brief Max web pages. 66 | */ 67 | const uint8_t WEB_PAGE_LEN = 3; 68 | 69 | /** 70 | * \brief Structure with device settings information. 71 | */ 72 | struct DeviceSetting 73 | { 74 | uint8_t IP[IP_LEN]; 75 | uint8_t SubnetMask[IP_LEN]; 76 | uint8_t Gateway[IP_LEN]; 77 | char DeviceName[DEVICE_NAME_LEN + 1]; 78 | char User[USER_PAS_LEN + 1]; 79 | char Password[USER_PAS_LEN + 1]; 80 | }; 81 | 82 | void DEF_DeviceSetting(DeviceSetting & data); 83 | 84 | /** 85 | * \brief Structure with relay settings information. 86 | */ 87 | struct RelayData 88 | { 89 | uint8_t Active; 90 | char RelayName[RELAY_NAME_LEN + 1]; 91 | }; 92 | 93 | /** 94 | * \brief Set default values DogSetting data. 95 | * 96 | * \param data Point to data well set default values. 97 | * \param relay Relay number. 98 | * 99 | * \return void 100 | */ 101 | void DEF_RelayData(RelayData & data, uint8_t relay); 102 | 103 | /** 104 | * \brief Structure stored data and check is valid. 105 | */ 106 | struct ValidationData 107 | { 108 | uint8_t IsValid; 109 | char* Value; 110 | uint8_t Length; 111 | }; 112 | 113 | /** 114 | * \brief List stored relay settings information. 115 | */ 116 | extern RelayData RelayDataList[RELAY_COUNT]; 117 | 118 | /** 119 | * \brief List stored new relay data from POST request. 120 | */ 121 | extern RelayData RelayDataNewList[RELAY_COUNT]; 122 | /** 123 | * \brief List stored validation data for new relay data from POST request. 124 | */ 125 | extern ValidationData ValidationForRelayDataNewList[VALID_DATA_LEN]; 126 | 127 | /** 128 | * \brief Stored current device setting. User, pass, IP, subnet, gateway. 129 | */ 130 | extern DeviceSetting DeviceData; 131 | 132 | extern DeviceSetting DeviceDataNew; 133 | extern ValidationData ValidUserAndIP[VALID_USER_AND_IP_LEN]; 134 | 135 | /** 136 | * \brief Set Relay list default values. 137 | * 138 | * \return void 139 | */ 140 | void DEF_RelayDataList(); 141 | 142 | #endif 143 | -------------------------------------------------------------------------------- /KMPDinoEthernet/src/KMPDinoEthernet/examples/projects/ProDinoIntRelay/version.txt: -------------------------------------------------------------------------------- 1 | Company: KMP Electronics Ltd, Bulgaria 2 | Project: ProDino Internet Relay 3 | 4 | 20160822 5 | 1.0.3 - Fix debug. 6 | 7 | 20160819 8 | 1.0.2 - Support new version KMPDinoEthernet library. 9 | 10 | 1.0.1 - Fix debug mode. 11 | 12 | History: 13 | 1.0.0 - First release. -------------------------------------------------------------------------------- /KMPDinoEthernet/src/KMPDinoEthernet/examples/projects/ProDinoWatchDog/HtmlPages.h: -------------------------------------------------------------------------------- 1 | // HtmlPages.h 2 | // Company: KMP Electronics Ltd, Bulgaria 3 | // Web: http://kmpelectronics.eu/ 4 | // License: See the GNU General Public License for more details at http://www.gnu.org/copyleft/gpl.html 5 | // Project: 6 | // ProDino Watchdog. 7 | // Description: 8 | // Build html responses. 9 | // Version: 1.0.0 10 | // Date: 10.12.2014 11 | // Author: Plamen Kovandjiev 12 | 13 | #ifndef _HTMLPAGES_h 14 | #define _HTMLPAGES_h 15 | 16 | #if defined(ARDUINO) && ARDUINO >= 100 17 | #include "Arduino.h" 18 | #else 19 | #include "WProgram.h" 20 | #endif 21 | 22 | #include 23 | #include "Structures.h" 24 | 25 | class HtmlPages 26 | { 27 | private: 28 | 29 | 30 | public: 31 | void init(EthernetClient& ec); 32 | 33 | void index(); 34 | void notFound(); 35 | void unAuthorized(); 36 | void privateSettings(DogSetting* dogData, ValidationData* validData = NULL, uint8_t showError = 0, uint8_t showSuccess = 0); 37 | void privateUserAndIP(DeviceSetting& deviceSettings, ValidationData* validData = NULL, uint8_t showError = 0, uint8_t showSuccess = 0); 38 | }; 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /KMPDinoEthernet/src/KMPDinoEthernet/examples/projects/ProDinoWatchDog/Processing.h: -------------------------------------------------------------------------------- 1 | // Processing.h 2 | // Company: KMP Electronics Ltd, Bulgaria 3 | // Web: http://kmpelectronics.eu/ 4 | // License: See the GNU General Public License for more details at http://www.gnu.org/copyleft/gpl.html 5 | // Project: 6 | // ProDino Watchdog. 7 | // Description: 8 | // Process actions and Html pages. 9 | // Version: 1.0.0 10 | // Date: 10.12.2014 11 | // Author: Plamen Kovandjiev 12 | 13 | #ifndef _PROCESSING_H 14 | #define _PROCESSING_H 15 | 16 | #if defined(ARDUINO) && ARDUINO >= 100 17 | #include "Arduino.h" 18 | #else 19 | #include "WProgram.h" 20 | #endif 21 | 22 | #include "Structures.h" 23 | #include 24 | 25 | class Processing 26 | { 27 | private: 28 | 29 | public: 30 | /** 31 | * \brief Initialize data. Read from EEPROM. 32 | * 33 | * 34 | * \return void 35 | */ 36 | void init(); 37 | 38 | /** 39 | * \brief Reset settings by default. 40 | * 41 | * 42 | * \return void 43 | */ 44 | void resetSettings(); 45 | 46 | /** 47 | * \brief Processes occurring operations. 48 | * 49 | * \return void 50 | */ 51 | void processOperaions(); 52 | 53 | /** 54 | * \brief Read client request parse and write needed response. 55 | * 56 | * \param client Ethernet client. 57 | * 58 | * \return void 59 | */ 60 | void processRequest(EthernetClient& client); 61 | 62 | /** 63 | * \brief Check is addresses (IP, Subnet, Gateway) changed. 64 | * 65 | * 66 | * \return bool If result equal True - addresses changed, else no change. 67 | */ 68 | bool IsAddressesChanged(); 69 | 70 | /** 71 | * \brief Set value to AddressesChanged. 72 | * 73 | * \param b New value. 74 | * 75 | * \return void 76 | */ 77 | void SetAddressesChanged(bool b); 78 | }; 79 | 80 | #endif -------------------------------------------------------------------------------- /KMPDinoEthernet/src/KMPDinoEthernet/examples/projects/ProDinoWatchDog/Structures.cpp: -------------------------------------------------------------------------------- 1 | // Structures.cpp 2 | // Company: KMP Electronics Ltd, Bulgaria 3 | // Web: http://kmpelectronics.eu/ 4 | // License: See the GNU General Public License for more details at http://www.gnu.org/copyleft/gpl.html 5 | // Project: 6 | // ProDino Watchdog. 7 | // Description: 8 | // Project structures. 9 | // Version: 1.0.0 10 | // Date: 10.12.2014 11 | // Author: Plamen Kovandjiev 12 | 13 | #include "Structures.h" 14 | #include "KMPCommon.h" 15 | 16 | const char DEF_User[] = "admin"; 17 | const char DEF_Password[] = "admin"; 18 | const uint8_t DEF_IPAddress[] = { 192, 168, 0, 103 }; 19 | const uint8_t DEF_SubnetMask[] = { 255, 255, 255, 0 }; 20 | const uint8_t DEF_Gateway[] = { 192, 168, 0, 1 }; 21 | const uint8_t DEF_TestPeriod = 30; // Default test period in seconds. 22 | const uint8_t DEF_HostLostAfter = 3; // Default HostLostAfter ... times. 23 | const uint8_t DEF_RestartWaitTime = 10; // Default restart wait time in second. On wait Off. 24 | const uint8_t DEF_WaitAfterRestart = 60; // Default wait after restart in seconds. Wait before start ping. 25 | 26 | DeviceSetting DeviceData; 27 | DogSetting DogList[DOG_COUNT]; 28 | ProcessInfo ProcessList[DOG_COUNT]; 29 | 30 | DogSetting DogListSettings[DOG_COUNT]; 31 | ValidationData ValidDataSettings[VALID_DATA_LEN]; 32 | DeviceSetting DeviceDataUserAndIP; 33 | ValidationData ValidUserAndIP[VALID_USER_AND_IP_LEN]; 34 | 35 | 36 | void DEF_DeviceSetting(DeviceSetting & ds) 37 | { 38 | strNCopy(ds.User, DEF_User, sizeof(DEF_User)); 39 | 40 | strNCopy(ds.Password, DEF_Password, sizeof(DEF_Password)); 41 | 42 | for (uint8_t i = 0; i < IP_LEN; i++) 43 | { 44 | ds.IP[i] = DEF_IPAddress[i]; 45 | } 46 | 47 | for (uint8_t i = 0; i < IP_LEN; i++) 48 | { 49 | ds.SubnetMask[i] = DEF_SubnetMask[i]; 50 | } 51 | 52 | for (uint8_t i = 0; i < IP_LEN; i++) 53 | { 54 | ds.Gateway[i] = DEF_Gateway[i]; 55 | } 56 | } 57 | 58 | void DEF_DogSetting(DogSetting & data) 59 | { 60 | data.Active = 0; // Not active. 61 | 62 | for (uint8_t i = 0; i < IP_LEN; i++) 63 | { 64 | data.IP[i] = 0; 65 | } 66 | 67 | data.TestPeriod = DEF_TestPeriod; 68 | data.HostLostAfter= DEF_HostLostAfter; 69 | data.RestartWaitTime = DEF_RestartWaitTime; 70 | data.WaitAfterRestart = DEF_WaitAfterRestart; 71 | } 72 | 73 | void SetLists_DEF() 74 | { 75 | for (uint8_t i = 0; i < DOG_COUNT; i++) 76 | { 77 | DEF_DogSetting(DogList[i]); 78 | 79 | ProcessInfo pd = ProcessList[i]; 80 | pd.LostTimes = 0; 81 | pd.Restarts = 0; 82 | pd.NextOpertion = OT_PING; 83 | } 84 | } -------------------------------------------------------------------------------- /KMPDinoEthernet/src/KMPDinoEthernet/examples/projects/ProDinoWatchDog/Structures.h: -------------------------------------------------------------------------------- 1 | // Structures.h 2 | // Company: KMP Electronics Ltd, Bulgaria 3 | // Web: http://kmpelectronics.eu/ 4 | // License: See the GNU General Public License for more details at http://www.gnu.org/copyleft/gpl.html 5 | // Project: 6 | // ProDino Watchdog. 7 | // Description: 8 | // Project structures. 9 | // Version: 1.0.0 10 | // Date: 10.12.2014 11 | // Author: Plamen Kovandjiev 12 | 13 | #ifndef _STRUCTURES_h 14 | #define _STRUCTURES_h 15 | 16 | #if defined(ARDUINO) && ARDUINO >= 100 17 | #include "Arduino.h" 18 | #else 19 | #include "WProgram.h" 20 | #endif 21 | 22 | #include "KmpDinoEthernet.h" 23 | #include "KMPCommon.h" 24 | 25 | // User, password length 26 | #define USER_PAS_LEN 8 27 | 28 | // Dog count. 29 | const uint8_t DOG_COUNT = RELAY_COUNT; 30 | 31 | const uint8_t WAN_PORT = 80; 32 | const uint8_t MAC_ADDRESS[] = { 0x80, 0x9B, 0x20, 0x54, 0x64, 0x68 }; 33 | 34 | const char PREFF_CB[]PROGMEM = "cb"; 35 | const char PREFF_IP[]PROGMEM = "ip"; 36 | const char PREFF_TP[]PROGMEM = "tp"; 37 | const char PREFF_HL[]PROGMEM = "hl"; 38 | const char PREFF_RW[]PROGMEM = "rw"; 39 | const char PREFF_WA[]PROGMEM = "wa"; 40 | const char PREFF_US[]PROGMEM = "US"; 41 | const char PREFF_PS[]PROGMEM = "PS"; 42 | const char PREFF_SN[]PROGMEM = "SN"; 43 | const char PREFF_GW[]PROGMEM = "GW"; 44 | 45 | const char ONE_TO_FOUR[] = "1234"; 46 | 47 | // Session timeout in minutes. 48 | const uint8_t SESSION_TIMEOUT = 10; 49 | 50 | const uint8_t DATA_ROW_COUNT = 6; 51 | 52 | const uint8_t VALID_DATA_LEN = DOG_COUNT * DATA_ROW_COUNT; 53 | 54 | const uint8_t VALID_USER_AND_IP_LEN = 5; 55 | 56 | const uint8_t MAX_IP_STR_LEN = 16; 57 | 58 | const uint8_t INDEX_PAGE_REFRESH_RATE = 60; 59 | 60 | /** 61 | * \brief Current operation type. 62 | */ 63 | enum OperationType 64 | { 65 | OT_PING, OT_RESTART 66 | }; 67 | /** 68 | * \brief Web pages. 69 | */ 70 | enum WebPages 71 | { 72 | WP_NONE = -1, WP_INDEX, WP_PRIVATE_SETTINGS, WP_PRIVATE_USERANDIP 73 | }; 74 | 75 | const uint8_t WEB_PAGE_LEN = 3; 76 | 77 | /** 78 | * \brief Structure with device settings information. 79 | */ 80 | struct DeviceSetting 81 | { 82 | uint8_t IP[IP_LEN]; 83 | uint8_t SubnetMask[IP_LEN]; 84 | uint8_t Gateway[IP_LEN]; 85 | char User[USER_PAS_LEN + 1]; 86 | char Password[USER_PAS_LEN + 1]; 87 | }; 88 | 89 | void DEF_DeviceSetting(DeviceSetting & data); 90 | 91 | /** 92 | * \brief Structure with dog settings information. 93 | */ 94 | struct DogSetting 95 | { 96 | uint8_t Active; 97 | uint8_t IP[IP_LEN]; 98 | uint8_t TestPeriod; 99 | uint8_t HostLostAfter; 100 | uint8_t RestartWaitTime; 101 | uint8_t WaitAfterRestart; 102 | }; 103 | 104 | /** 105 | * \brief Set default values DogSetting data. 106 | * 107 | * \param data Point to data well set default values. 108 | * 109 | * \return void 110 | */ 111 | void DEF_DogSetting(DogSetting & data); 112 | 113 | /** 114 | * \brief Processing information. Lost times, restarts, next time operation, current operation. 115 | */ 116 | struct ProcessInfo 117 | { 118 | uint8_t LostTimes; 119 | uint8_t Restarts; 120 | unsigned long NextTimeToOperate; 121 | OperationType NextOpertion; 122 | }; 123 | 124 | struct ValidationData 125 | { 126 | uint8_t IsValid; 127 | char* Value; 128 | uint8_t Length; 129 | }; 130 | 131 | /** 132 | * \brief List stored dog settings information. 133 | */ 134 | extern DogSetting DogList[DOG_COUNT]; 135 | 136 | /** 137 | * \brief List stored processing information. 138 | */ 139 | extern ProcessInfo ProcessList[DOG_COUNT]; 140 | 141 | extern DogSetting DogListSettings[DOG_COUNT]; 142 | extern ValidationData ValidDataSettings[VALID_DATA_LEN]; 143 | 144 | extern DeviceSetting DeviceDataUserAndIP; 145 | extern ValidationData ValidUserAndIP[VALID_USER_AND_IP_LEN]; 146 | 147 | /** 148 | * \brief Stored current device setting. User, pass, IP, subnet, gateway. 149 | */ 150 | extern DeviceSetting DeviceData; 151 | 152 | /** 153 | * \brief Set DogList and ProcessList default values. 154 | * 155 | * \return void 156 | */ 157 | void SetLists_DEF(); 158 | 159 | #endif -------------------------------------------------------------------------------- /KMPDinoEthernet/src/KMPDinoEthernet/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Ethernet 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | Ethernet KEYWORD1 10 | EthernetClient KEYWORD1 11 | EthernetServer KEYWORD1 12 | IPAddress KEYWORD1 13 | OneWire KEYWORD1 14 | DallasTemperature KEYWORD1 15 | AlarmHandler KEYWORD1 16 | DeviceAddress KEYWORD1 17 | 18 | ####################################### 19 | # Methods and Functions (KEYWORD2) 20 | ####################################### 21 | 22 | status KEYWORD2 23 | connect KEYWORD2 24 | write KEYWORD2 25 | available KEYWORD2 26 | read KEYWORD2 27 | peek KEYWORD2 28 | flush KEYWORD2 29 | stop KEYWORD2 30 | connected KEYWORD2 31 | setResolution KEYWORD2 32 | getResolution KEYWORD2 33 | getTempC KEYWORD2 34 | toFahrenheit KEYWORD2 35 | getTempF KEYWORD2 36 | getTempCByIndex KEYWORD2 37 | getTempFByIndex KEYWORD2 38 | setWaitForConversion KEYWORD2 39 | getWaitForConversion KEYWORD2 40 | requestTemperatures KEYWORD2 41 | requestTemperaturesByAddress KEYWORD2 42 | requestTemperaturesByIndex KEYWORD2 43 | isParasitePowerMode KEYWORD2 44 | begin KEYWORD2 45 | beginPacket KEYWORD2 46 | endPacket KEYWORD2 47 | parsePacket KEYWORD2 48 | remoteIP KEYWORD2 49 | remotePort KEYWORD2 50 | reset KEYWORD2 51 | write_bit KEYWORD2 52 | read_bit KEYWORD2 53 | write_bytes KEYWORD2 54 | read_bytes KEYWORD2 55 | select KEYWORD2 56 | skip KEYWORD2 57 | depower KEYWORD2 58 | reset_search KEYWORD2 59 | search KEYWORD2 60 | crc8 KEYWORD2 61 | crc16 KEYWORD2 62 | check_crc16 KEYWORD2 63 | getDeviceCount KEYWORD2 64 | getAddress KEYWORD2 65 | validAddress KEYWORD2 66 | isConnected KEYWORD2 67 | readScratchPad KEYWORD2 68 | writeScratchPad KEYWORD2 69 | readPowerSupply KEYWORD2 70 | setHighAlarmTemp KEYWORD2 71 | setLowAlarmTemp KEYWORD2 72 | getHighAlarmTemp KEYWORD2 73 | getLowAlarmTemp KEYWORD2 74 | resetAlarmSearch KEYWORD2 75 | alarmSearch KEYWORD2 76 | hasAlarm KEYWORD2 77 | toCelsius KEYWORD2 78 | processAlarmss KEYWORD2 79 | setAlarmHandlers KEYWORD2 80 | defaultAlarmHandler KEYWORD2 81 | calculateTemperature KEYWORD2 82 | 83 | ####################################### 84 | # Instances (KEYWORD2) 85 | ####################################### 86 | 87 | ####################################### 88 | # Constants (LITERAL1) 89 | ####################################### 90 | 91 | -------------------------------------------------------------------------------- /KMPDinoEthernet/src/KMPDinoEthernet/library.properties: -------------------------------------------------------------------------------- 1 | name=KMPDinoEthernet 2 | version=1.6.1 3 | author=KMP Electronics Ltd, Plamen Kovandjiev 4 | maintainer=Plamen Kovandjiev, 5 | sentence=Examples for the board ProDiNo Ethernet V2. 6 | paragraph=This library implements a specific examples for board. 7 | category=Communication 8 | url=https://kmpelectronics.eu/products/prodino-ethernet-v2/ 9 | architectures=avr 10 | -------------------------------------------------------------------------------- /KMPDinoEthernet/src/KMPDinoEthernet/src/Base64.cpp: -------------------------------------------------------------------------------- 1 | #include "Base64.h" 2 | 3 | const char b64_alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 4 | "abcdefghijklmnopqrstuvwxyz" 5 | "0123456789+/"; 6 | 7 | /* 'Private' declarations */ 8 | inline void a3_to_a4(unsigned char * a4, unsigned char * a3); 9 | inline void a4_to_a3(unsigned char * a3, unsigned char * a4); 10 | inline unsigned char b64_lookup(char c); 11 | 12 | int base64_encode(char *output, char *input, int inputLen) { 13 | int i = 0, j = 0; 14 | int encLen = 0; 15 | unsigned char a3[3]; 16 | unsigned char a4[4]; 17 | 18 | while(inputLen--) { 19 | a3[i++] = *(input++); 20 | if(i == 3) { 21 | a3_to_a4(a4, a3); 22 | 23 | for(i = 0; i < 4; i++) { 24 | output[encLen++] = b64_alphabet[a4[i]]; 25 | } 26 | 27 | i = 0; 28 | } 29 | } 30 | 31 | if(i) { 32 | for(j = i; j < 3; j++) { 33 | a3[j] = '\0'; 34 | } 35 | 36 | a3_to_a4(a4, a3); 37 | 38 | for(j = 0; j < i + 1; j++) { 39 | output[encLen++] = b64_alphabet[a4[j]]; 40 | } 41 | 42 | while((i++ < 3)) { 43 | output[encLen++] = '='; 44 | } 45 | } 46 | output[encLen] = '\0'; 47 | return encLen; 48 | } 49 | 50 | int base64_decode(char * output, char * input, int inputLen) { 51 | int i = 0, j = 0; 52 | int decLen = 0; 53 | unsigned char a3[3]; 54 | unsigned char a4[4]; 55 | 56 | 57 | while (inputLen--) { 58 | if(*input == '=') { 59 | break; 60 | } 61 | 62 | a4[i++] = *(input++); 63 | if (i == 4) { 64 | for (i = 0; i <4; i++) { 65 | a4[i] = b64_lookup(a4[i]); 66 | } 67 | 68 | a4_to_a3(a3,a4); 69 | 70 | for (i = 0; i < 3; i++) { 71 | output[decLen++] = a3[i]; 72 | } 73 | i = 0; 74 | } 75 | } 76 | 77 | if (i) { 78 | for (j = i; j < 4; j++) { 79 | a4[j] = '\0'; 80 | } 81 | 82 | for (j = 0; j <4; j++) { 83 | a4[j] = b64_lookup(a4[j]); 84 | } 85 | 86 | a4_to_a3(a3,a4); 87 | 88 | for (j = 0; j < i - 1; j++) { 89 | output[decLen++] = a3[j]; 90 | } 91 | } 92 | output[decLen] = '\0'; 93 | return decLen; 94 | } 95 | 96 | int base64_enc_len(int plainLen) { 97 | int n = plainLen; 98 | return (n + 2 - ((n + 2) % 3)) / 3 * 4; 99 | } 100 | 101 | int base64_dec_len(char * input, int inputLen) { 102 | int i = 0; 103 | int numEq = 0; 104 | for(i = inputLen - 1; input[i] == '='; i--) { 105 | numEq++; 106 | } 107 | 108 | return ((6 * inputLen) / 8) - numEq; 109 | } 110 | 111 | inline void a3_to_a4(unsigned char * a4, unsigned char * a3) { 112 | a4[0] = (a3[0] & 0xfc) >> 2; 113 | a4[1] = ((a3[0] & 0x03) << 4) + ((a3[1] & 0xf0) >> 4); 114 | a4[2] = ((a3[1] & 0x0f) << 2) + ((a3[2] & 0xc0) >> 6); 115 | a4[3] = (a3[2] & 0x3f); 116 | } 117 | 118 | inline void a4_to_a3(unsigned char * a3, unsigned char * a4) { 119 | a3[0] = (a4[0] << 2) + ((a4[1] & 0x30) >> 4); 120 | a3[1] = ((a4[1] & 0xf) << 4) + ((a4[2] & 0x3c) >> 2); 121 | a3[2] = ((a4[2] & 0x3) << 6) + a4[3]; 122 | } 123 | 124 | inline unsigned char b64_lookup(char c) { 125 | if(c >='A' && c <='Z') return c - 'A'; 126 | if(c >='a' && c <='z') return c - 71; 127 | if(c >='0' && c <='9') return c + 4; 128 | if(c == '+') return 62; 129 | if(c == '/') return 63; 130 | return -1; 131 | } 132 | -------------------------------------------------------------------------------- /KMPDinoEthernet/src/KMPDinoEthernet/src/Base64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Adam Rudd. 3 | * See LICENSE for more information 4 | */ 5 | #ifndef _BASE64_H 6 | #define _BASE64_H 7 | 8 | /* b64_alphabet: 9 | * Description: Base64 alphabet table, a mapping between integers 10 | * and base64 digits 11 | * Notes: This is an extern here but is defined in Base64.c 12 | */ 13 | extern const char b64_alphabet[]; 14 | 15 | /* base64_encode: 16 | * Description: 17 | * Encode a string of characters as base64 18 | * Parameters: 19 | * output: the output buffer for the encoding, stores the encoded string 20 | * input: the input buffer for the encoding, stores the binary to be encoded 21 | * inputLen: the length of the input buffer, in bytes 22 | * Return value: 23 | * Returns the length of the encoded string 24 | * Requirements: 25 | * 1. output must not be null or empty 26 | * 2. input must not be null 27 | * 3. inputLen must be greater than or equal to 0 28 | */ 29 | int base64_encode(char *output, char *input, int inputLen); 30 | 31 | /* base64_decode: 32 | * Description: 33 | * Decode a base64 encoded string into bytes 34 | * Parameters: 35 | * output: the output buffer for the decoding, 36 | * stores the decoded binary 37 | * input: the input buffer for the decoding, 38 | * stores the base64 string to be decoded 39 | * inputLen: the length of the input buffer, in bytes 40 | * Return value: 41 | * Returns the length of the decoded string 42 | * Requirements: 43 | * 1. output must not be null or empty 44 | * 2. input must not be null 45 | * 3. inputLen must be greater than or equal to 0 46 | */ 47 | int base64_decode(char *output, char *input, int inputLen); 48 | 49 | /* base64_enc_len: 50 | * Description: 51 | * Returns the length of a base64 encoded string whose decoded 52 | * form is inputLen bytes long 53 | * Parameters: 54 | * inputLen: the length of the decoded string 55 | * Return value: 56 | * The length of a base64 encoded string whose decoded form 57 | * is inputLen bytes long 58 | * Requirements: 59 | * None 60 | */ 61 | int base64_enc_len(int inputLen); 62 | 63 | /* base64_dec_len: 64 | * Description: 65 | * Returns the length of the decoded form of a 66 | * base64 encoded string 67 | * Parameters: 68 | * input: the base64 encoded string to be measured 69 | * inputLen: the length of the base64 encoded string 70 | * Return value: 71 | * Returns the length of the decoded form of a 72 | * base64 encoded string 73 | * Requirements: 74 | * 1. input must not be null 75 | * 2. input must be greater than or equal to zero 76 | */ 77 | int base64_dec_len(char *input, int inputLen); 78 | 79 | #endif // _BASE64_H 80 | -------------------------------------------------------------------------------- /KMPDinoEthernet/src/KMPDinoEthernet/src/Ethernet/Dns.h: -------------------------------------------------------------------------------- 1 | // Arduino DNS client for WizNet5100-based Ethernet shield 2 | // (c) Copyright 2009-2010 MCQN Ltd. 3 | // Released under Apache License, version 2.0 4 | 5 | #ifndef DNSClient_h 6 | #define DNSClient_h 7 | 8 | #include "EthernetUdp.h" 9 | 10 | class DNSClient 11 | { 12 | public: 13 | // ctor 14 | void begin(const IPAddress& aDNSServer); 15 | 16 | /** Convert a numeric IP address string into a four-byte IP address. 17 | @param aIPAddrString IP address to convert 18 | @param aResult IPAddress structure to store the returned IP address 19 | @result 1 if aIPAddrString was successfully converted to an IP address, 20 | else error code 21 | */ 22 | int inet_aton(const char *aIPAddrString, IPAddress& aResult); 23 | 24 | /** Resolve the given hostname to an IP address. 25 | @param aHostname Name to be resolved 26 | @param aResult IPAddress structure to store the returned IP address 27 | @result 1 if aIPAddrString was successfully converted to an IP address, 28 | else error code 29 | */ 30 | int getHostByName(const char* aHostname, IPAddress& aResult); 31 | 32 | protected: 33 | uint16_t BuildRequest(const char* aName); 34 | uint16_t ProcessResponse(uint16_t aTimeout, IPAddress& aAddress); 35 | 36 | IPAddress iDNSServer; 37 | uint16_t iRequestId; 38 | EthernetUDP iUdp; 39 | }; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /KMPDinoEthernet/src/KMPDinoEthernet/src/Ethernet/Ethernet.h: -------------------------------------------------------------------------------- 1 | #ifndef ethernet_h 2 | #define ethernet_h 3 | 4 | #include 5 | #include "utility/w5100.h" 6 | #include "IPAddress.h" 7 | #include "EthernetClient.h" 8 | #include "EthernetServer.h" 9 | #include "Dhcp.h" 10 | 11 | class EthernetClass { 12 | private: 13 | IPAddress _dnsServerAddress; 14 | DhcpClass* _dhcp; 15 | public: 16 | static uint8_t _state[MAX_SOCK_NUM]; 17 | static uint16_t _server_port[MAX_SOCK_NUM]; 18 | 19 | #if defined(WIZ550io_WITH_MACADDRESS) 20 | // Initialize function when use the ioShield series (included WIZ550io) 21 | // WIZ550io has a MAC address which is written after reset. 22 | // Default IP, Gateway and subnet address are also written. 23 | // so, It needs some initial time. please refer WIZ550io Datasheet in details. 24 | int begin(void); 25 | void begin(IPAddress local_ip); 26 | void begin(IPAddress local_ip, IPAddress dns_server); 27 | void begin(IPAddress local_ip, IPAddress dns_server, IPAddress gateway); 28 | void begin(IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet); 29 | #else 30 | // Initialise the Ethernet shield to use the provided MAC address and gain the rest of the 31 | // configuration through DHCP. 32 | // Returns 0 if the DHCP configuration failed, and 1 if it succeeded 33 | int begin(uint8_t *mac_address, unsigned long timeout = 60000, unsigned long responseTimeout = 4000); 34 | void begin(uint8_t *mac_address, IPAddress local_ip); 35 | void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server); 36 | void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway); 37 | void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet); 38 | #endif 39 | int maintain(); 40 | 41 | IPAddress localIP(); 42 | IPAddress subnetMask(); 43 | IPAddress gatewayIP(); 44 | IPAddress dnsServerIP(); 45 | 46 | friend class EthernetClient; 47 | friend class EthernetServer; 48 | }; 49 | 50 | extern EthernetClass Ethernet; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /KMPDinoEthernet/src/KMPDinoEthernet/src/Ethernet/EthernetClient.h: -------------------------------------------------------------------------------- 1 | #ifndef ethernetclient_h 2 | #define ethernetclient_h 3 | #include "Arduino.h" 4 | #include "Print.h" 5 | #include "Client.h" 6 | #include "IPAddress.h" 7 | 8 | class EthernetClient : public Client { 9 | 10 | public: 11 | EthernetClient(); 12 | EthernetClient(uint8_t sock); 13 | 14 | uint8_t status(); 15 | virtual int connect(IPAddress ip, uint16_t port); 16 | virtual int connect(const char *host, uint16_t port); 17 | virtual size_t write(uint8_t); 18 | virtual size_t write(const uint8_t *buf, size_t size); 19 | virtual int available(); 20 | virtual int read(); 21 | virtual int read(uint8_t *buf, size_t size); 22 | virtual int peek(); 23 | virtual void flush(); 24 | virtual void stop(); 25 | virtual uint8_t connected(); 26 | virtual operator bool(); 27 | virtual bool operator==(const bool value) { return bool() == value; } 28 | virtual bool operator!=(const bool value) { return bool() != value; } 29 | virtual bool operator==(const EthernetClient&); 30 | virtual bool operator!=(const EthernetClient& rhs) { return !this->operator==(rhs); }; 31 | uint8_t getSocketNumber(); 32 | 33 | friend class EthernetServer; 34 | 35 | using Print::write; 36 | 37 | private: 38 | static uint16_t _srcport; 39 | uint8_t _sock; 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /KMPDinoEthernet/src/KMPDinoEthernet/src/Ethernet/EthernetServer.cpp: -------------------------------------------------------------------------------- 1 | #include "utility/w5100.h" 2 | #include "utility/socket.h" 3 | extern "C" { 4 | #include "string.h" 5 | } 6 | 7 | #include "Ethernet.h" 8 | #include "EthernetClient.h" 9 | #include "EthernetServer.h" 10 | 11 | EthernetServer::EthernetServer(uint16_t port) 12 | { 13 | _port = port; 14 | } 15 | 16 | void EthernetServer::begin() 17 | { 18 | for (int sock = 0; sock < MAX_SOCK_NUM; sock++) { 19 | EthernetClient client(sock); 20 | if (client.status() == SnSR::CLOSED) { 21 | socket(sock, SnMR::TCP, _port, 0); 22 | listen(sock); 23 | EthernetClass::_server_port[sock] = _port; 24 | break; 25 | } 26 | } 27 | } 28 | 29 | void EthernetServer::accept() 30 | { 31 | int listening = 0; 32 | 33 | for (int sock = 0; sock < MAX_SOCK_NUM; sock++) { 34 | EthernetClient client(sock); 35 | 36 | if (EthernetClass::_server_port[sock] == _port) { 37 | if (client.status() == SnSR::LISTEN) { 38 | listening = 1; 39 | } 40 | else if (client.status() == SnSR::CLOSE_WAIT && !client.available()) { 41 | client.stop(); 42 | } 43 | } 44 | } 45 | 46 | if (!listening) { 47 | begin(); 48 | } 49 | } 50 | 51 | EthernetClient EthernetServer::available() 52 | { 53 | accept(); 54 | 55 | for (int sock = 0; sock < MAX_SOCK_NUM; sock++) { 56 | EthernetClient client(sock); 57 | if (EthernetClass::_server_port[sock] == _port) { 58 | uint8_t s = client.status(); 59 | if (s == SnSR::ESTABLISHED || s == SnSR::CLOSE_WAIT) { 60 | if (client.available()) { 61 | // XXX: don't always pick the lowest numbered socket. 62 | return client; 63 | } 64 | } 65 | } 66 | } 67 | 68 | return EthernetClient(MAX_SOCK_NUM); 69 | } 70 | 71 | size_t EthernetServer::write(uint8_t b) 72 | { 73 | return write(&b, 1); 74 | } 75 | 76 | size_t EthernetServer::write(const uint8_t *buffer, size_t size) 77 | { 78 | size_t n = 0; 79 | 80 | accept(); 81 | 82 | for (int sock = 0; sock < MAX_SOCK_NUM; sock++) { 83 | EthernetClient client(sock); 84 | 85 | if (EthernetClass::_server_port[sock] == _port && 86 | client.status() == SnSR::ESTABLISHED) { 87 | n += client.write(buffer, size); 88 | } 89 | } 90 | 91 | return n; 92 | } 93 | -------------------------------------------------------------------------------- /KMPDinoEthernet/src/KMPDinoEthernet/src/Ethernet/EthernetServer.h: -------------------------------------------------------------------------------- 1 | #ifndef ethernetserver_h 2 | #define ethernetserver_h 3 | 4 | #include "Server.h" 5 | 6 | class EthernetClient; 7 | 8 | class EthernetServer : 9 | public Server { 10 | private: 11 | uint16_t _port; 12 | void accept(); 13 | public: 14 | EthernetServer(uint16_t); 15 | EthernetClient available(); 16 | virtual void begin(); 17 | virtual size_t write(uint8_t); 18 | virtual size_t write(const uint8_t *buf, size_t size); 19 | using Print::write; 20 | }; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /KMPDinoEthernet/src/KMPDinoEthernet/src/Ethernet/Twitter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Twitter.cpp - Arduino library to Post messages to Twitter using OAuth. 3 | Copyright (c) NeoCat 2010-2011. All right reserved. 4 | 5 | This library is distributed in the hope that it will be useful, 6 | but WITHOUT ANY WARRANTY; without even the implied warranty of 7 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 8 | */ 9 | 10 | // ver1.2 - Use 11 | // ver1.3 - Support IDE 1.0 12 | 13 | #include 14 | #include "Twitter.h" 15 | 16 | #define LIB_DOMAIN "arduino-tweet.appspot.com" 17 | 18 | #if defined(ARDUINO) && ARDUINO < 100 19 | static uint8_t server[] = {0,0,0,0}; // IP address of LIB_DOMAIN 20 | Twitter::Twitter(const char *token) : client(server, 80), token(token) 21 | { 22 | } 23 | #else 24 | Twitter::Twitter(const char *token) : token(token) 25 | { 26 | } 27 | #endif 28 | 29 | bool Twitter::post(const char *msg) 30 | { 31 | #if defined(ARDUINO) && ARDUINO < 100 32 | DNSError err = EthernetDNS.resolveHostName(LIB_DOMAIN, server); 33 | if (err != DNSSuccess) { 34 | return false; 35 | } 36 | #endif 37 | parseStatus = 0; 38 | statusCode = 0; 39 | #if defined(ARDUINO) && ARDUINO < 100 40 | if (client.connect()) { 41 | #else 42 | if (client.connect(LIB_DOMAIN, 80)) { 43 | #endif 44 | client.println("POST http://" LIB_DOMAIN "/update HTTP/1.0"); 45 | client.print("Content-Length: "); 46 | client.println(strlen(msg)+strlen(token)+14); 47 | client.println(); 48 | client.print("token="); 49 | client.print(token); 50 | client.print("&status="); 51 | client.println(msg); 52 | } else { 53 | return false; 54 | } 55 | return true; 56 | } 57 | 58 | bool Twitter::checkStatus(Print *debug) 59 | { 60 | if (!client.connected()) { 61 | if (debug) 62 | while(client.available()) 63 | debug->print((char)client.read()); 64 | client.flush(); 65 | client.stop(); 66 | return false; 67 | } 68 | if (!client.available()) 69 | return true; 70 | char c = client.read(); 71 | if (debug) 72 | debug->print(c); 73 | switch(parseStatus) { 74 | case 0: 75 | if (c == ' ') parseStatus++; break; // skip "HTTP/1.1 " 76 | case 1: 77 | if (c >= '0' && c <= '9') { 78 | statusCode *= 10; 79 | statusCode += c - '0'; 80 | } else { 81 | parseStatus++; 82 | } 83 | } 84 | return true; 85 | } 86 | 87 | int Twitter::wait(Print *debug) 88 | { 89 | while (checkStatus(debug)); 90 | return statusCode; 91 | } 92 | -------------------------------------------------------------------------------- /KMPDinoEthernet/src/KMPDinoEthernet/src/Ethernet/Twitter.h: -------------------------------------------------------------------------------- 1 | /* 2 | Twitter.cpp - Arduino library to Post messages to Twitter using OAuth. 3 | Copyright (c) NeoCat 2010-2011. All right reserved. 4 | 5 | This library is distributed in the hope that it will be useful, 6 | but WITHOUT ANY WARRANTY; without even the implied warranty of 7 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 8 | */ 9 | 10 | // ver1.2 - Use to support IDE 0019 or later 11 | // ver1.3 - Support IDE 1.0 12 | 13 | #ifndef TWITTER_H 14 | #define TWITTER_H 15 | 16 | #include 17 | #include 18 | #if defined(ARDUINO) && ARDUINO > 18 // Arduino 0019 or later 19 | #include 20 | #endif 21 | #include "Ethernet.h" 22 | #if defined(ARDUINO) && ARDUINO < 100 // earlier than Arduino 1.0 23 | #include "EthernetDNS.h" 24 | #endif 25 | 26 | class Twitter 27 | { 28 | private: 29 | uint8_t parseStatus; 30 | int statusCode; 31 | const char *token; 32 | #if defined(ARDUINO) && ARDUINO < 100 33 | Client client; 34 | #else 35 | EthernetClient client; 36 | #endif 37 | public: 38 | Twitter(const char *user_and_passwd); 39 | 40 | bool post(const char *msg); 41 | bool checkStatus(Print *debug = NULL); 42 | int wait(Print *debug = NULL); 43 | int status(void) { return statusCode; } 44 | }; 45 | 46 | #endif //TWITTER_H 47 | -------------------------------------------------------------------------------- /KMPDinoEthernet/src/KMPDinoEthernet/src/Ethernet/utility/socket.h: -------------------------------------------------------------------------------- 1 | #ifndef _SOCKET_H_ 2 | #define _SOCKET_H_ 3 | 4 | #include "w5100.h" 5 | 6 | extern uint8_t socket(SOCKET s, uint8_t protocol, uint16_t port, uint8_t flag); // Opens a socket(TCP or UDP or IP_RAW mode) 7 | extern uint8_t socketStatus(SOCKET s); 8 | extern void close(SOCKET s); // Close socket 9 | extern uint8_t connect(SOCKET s, uint8_t * addr, uint16_t port); // Establish TCP connection (Active connection) 10 | extern void disconnect(SOCKET s); // disconnect the connection 11 | extern uint8_t listen(SOCKET s); // Establish TCP connection (Passive connection) 12 | extern uint16_t send(SOCKET s, const uint8_t * buf, uint16_t len); // Send data (TCP) 13 | extern int16_t recv(SOCKET s, uint8_t * buf, int16_t len); // Receive data (TCP) 14 | extern int16_t recvAvailable(SOCKET s); 15 | extern uint16_t peek(SOCKET s, uint8_t *buf); 16 | extern uint16_t sendto(SOCKET s, const uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port); // Send data (UDP/IP RAW) 17 | extern uint16_t recvfrom(SOCKET s, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port); // Receive data (UDP/IP RAW) 18 | extern void flush(SOCKET s); // Wait for transmission to complete 19 | 20 | extern uint16_t igmpsend(SOCKET s, const uint8_t * buf, uint16_t len); 21 | 22 | // Functions to allow buffered UDP send (i.e. where the UDP datagram is built up over a 23 | // number of calls before being sent 24 | /* 25 | @brief This function sets up a UDP datagram, the data for which will be provided by one 26 | or more calls to bufferData and then finally sent with sendUDP. 27 | @return 1 if the datagram was successfully set up, or 0 if there was an error 28 | */ 29 | extern int startUDP(SOCKET s, uint8_t* addr, uint16_t port); 30 | /* 31 | @brief This function copies up to len bytes of data from buf into a UDP datagram to be 32 | sent later by sendUDP. Allows datagrams to be built up from a series of bufferData calls. 33 | @return Number of bytes successfully buffered 34 | */ 35 | uint16_t bufferData(SOCKET s, uint16_t offset, const uint8_t* buf, uint16_t len); 36 | /* 37 | @brief Send a UDP datagram built up from a sequence of startUDP followed by one or more 38 | calls to bufferData. 39 | @return 1 if the datagram was successfully sent, or 0 if there was an error 40 | */ 41 | int sendUDP(SOCKET s); 42 | 43 | #endif 44 | /* _SOCKET_H_ */ 45 | -------------------------------------------------------------------------------- /KMPDinoEthernet/src/KMPDinoEthernet/src/Ethernet/utility/util.h: -------------------------------------------------------------------------------- 1 | #ifndef UTIL_H 2 | #define UTIL_H 3 | 4 | #define htons(x) ( ((x)<< 8 & 0xFF00) | \ 5 | ((x)>> 8 & 0x00FF) ) 6 | #define ntohs(x) htons(x) 7 | 8 | #define htonl(x) ( ((x)<<24 & 0xFF000000UL) | \ 9 | ((x)<< 8 & 0x00FF0000UL) | \ 10 | ((x)>> 8 & 0x0000FF00UL) | \ 11 | ((x)>>24 & 0x000000FFUL) ) 12 | #define ntohl(x) htonl(x) 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /KMPDinoEthernet/src/KMPDinoEthernet/src/MqttTopicHelper.h: -------------------------------------------------------------------------------- 1 | // MqttTopicHelper.h 2 | 3 | #ifndef _MQTTTOPICHELPER_h 4 | #define _MQTTTOPICHELPER_h 5 | 6 | #if defined(ARDUINO) && ARDUINO >= 100 7 | #include "arduino.h" 8 | #else 9 | #include "WProgram.h" 10 | #endif 11 | 12 | const char TOPIC_SEPARATOR = '/'; 13 | const uint16_t MAIN_TOPIC_MAXLEN = 64; 14 | const char ISREADY_TOPIC[] = "isready"; 15 | const char SET_TOPIC[] = "/set"; 16 | 17 | class MqttTopicHelperClass 18 | { 19 | public: 20 | void init(const char* baseTopic, const char* deviceTopic, Print* debugPort = NULL); 21 | void printTopicAndPayload(const char* topic, const byte* payload, unsigned int length); 22 | void printTopicAndPayload(const char* topic, const char* payload); 23 | void addCharToStr(char* str, const char chr); 24 | void addTopicSeparator(char* str); 25 | void appendTopic(char * topic, const char * nextTopic); 26 | const char* getMainTopic(); 27 | const char* getIsReadyTopic(); 28 | bool startsWithMainTopic(const char* str); 29 | void buildTopicWithMT(char * str, int num, ...); 30 | void buildTopic(char* str, int num, ...); 31 | bool isBaseTopic(char* topic); 32 | bool isMainTopic(char* topic); 33 | bool isReadyTopic(char* topic); 34 | bool getNextTopic(const char* topics, char* nextTopic, char** otherTopics, bool skipMainTopic = false); 35 | bool isTopicSet(const char* topics); 36 | protected: 37 | bool isOnlyThisTopic(const char* topic1, const char* topic2); 38 | }; 39 | 40 | extern MqttTopicHelperClass MqttTopicHelper; 41 | 42 | #endif 43 | 44 | -------------------------------------------------------------------------------- /KMPDinoEthernet/src/KMPDinoEthernet/version.txt: -------------------------------------------------------------------------------- 1 | KMPDinoEthernet library 2 | Version: 1.5 3 | Warning! RS485 don't work Arduino version from 1.5.6 to 1.6.4. Please use the version: >=1.6.5. 4 | 5 | History: 6 | Version: 1.5 - 20190227 Add Ethernet linbrary internaly in KMPDinoEthernet library. Fixing links in examples. 7 | Version: 1.4.3 - 20160822 For a project "ProDino Internet Relay" fix debug. 8 | Version: 1.4.2 - 20160819 For a project "ProDino Internet Relay" fix support new version KMPDinoEthernet library. 9 | Version: 1.4.1 - Fixed WebPing example debug mode. 10 | Version: 1.4.0 - Separate examples and ethernet library. 11 | Version: 1.3.0 - Add support >=Arduino 1.6.5 version. Change W5200 library and move in Arduino /libraries/Ethernet/src. Support default Arduino Ethernet examples. 12 | Version: 1.2.6 - fix problems with headers for Arduino 1.6.6 version. 13 | Version: 1.2.5 - add example WebRelayOptoIn mixed with WebRelay and WebOptoInputs examples. 14 | Version: 1.2.4 - add projects folder and ProDino Watch Dog project. 15 | Version: 1.2.3 - add projects folder and ProDino Internet relay project. 16 | Version: 1.2.2 - restore _client.write from _client.writeP. This bring performance and make code easy. 17 | Version: 1.2.1 - fix clear IP's and MAC addresses on W5200. -------------------------------------------------------------------------------- /ProDinoESP32_2/examples/AllW/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | // Your WiFi credentials 2 | #define SSID_NAME "" 3 | #define SSID_PASSWORD "" 4 | -------------------------------------------------------------------------------- /ProDinoESP32_2/examples/AllWE/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | // Your WiFi credentials 2 | #define SSID_NAME "" 3 | #define SSID_PASSWORD "" 4 | -------------------------------------------------------------------------------- /ProDinoESP32_2/examples/AllWEG/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | // You have to get your Authentication Token through Blynk Application. 2 | #define AUTH_TOKEN "1234567890abcdef1234567890ABCDEF" 3 | 4 | // Your WiFi credentials 5 | #define SSID_NAME "" 6 | #define SSID_PASSWORD "" 7 | 8 | // SIM card pin number if exists 9 | #define SECRET_PINNUMBER "" 10 | #define SECRET_GPRS_APN "" // replace your GPRS APN 11 | #define SECRET_GPRS_LOGIN "" // replace with your GPRS login 12 | #define SECRET_GPRS_PASSWORD "" // replace with your GPRS password -------------------------------------------------------------------------------- /ProDinoESP32_2/examples/AllWE_F/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | // Your WiFi credentials 2 | #define SSID_NAME "" 3 | #define SSID_PASSWORD "" 4 | -------------------------------------------------------------------------------- /ProDinoESP32_2/examples/BlynkG/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | // You have to get your Authentication Token through Blynk Application. 2 | #define AUTH_TOKEN "1234567890abcdef1234567890ABCDEF" 3 | 4 | // SIM card pin number if exists 5 | #define SECRET_PINNUMBER "" 6 | #define SECRET_GPRS_APN "" // replace your GPRS APN 7 | #define SECRET_GPRS_LOGIN "" // replace with your GPRS login 8 | #define SECRET_GPRS_PASSWORD "" // replace with your GPRS password 9 | -------------------------------------------------------------------------------- /ProDinoESP32_2/examples/BlynkWE/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | // You have to get your Authentication Token through Blynk Application. 2 | #define AUTH_TOKEN "1234567890abcdef1234567890ABCDEF" 3 | 4 | // Your WiFi credentials 5 | #define SSID_NAME "" 6 | #define SSID_PASSWORD "" -------------------------------------------------------------------------------- /ProDinoESP32_2/examples/MqttSimpleG/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | // SIM card pin number if exists 2 | #define SECRET_PINNUMBER "" 3 | #define SECRET_GPRS_APN "" // replace your GPRS APN 4 | #define SECRET_GPRS_LOGIN "" // replace with your GPRS login 5 | #define SECRET_GPRS_PASSWORD "" // replace with your GPRS password 6 | 7 | // MQTT server settings. 8 | #define MQTT_SERVER "" // Change it with yours data. 9 | #define MQTT_PORT 12345 // Change it with yours data. 10 | #define MQTT_USER "" // Change it with yours data. 11 | #define MQTT_PASS "" // Change it with yours data. -------------------------------------------------------------------------------- /ProDinoESP32_2/examples/MqttSimpleWE/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | const char SSID[] = ""; 2 | const char SSID_PASSWORD[] = ""; 3 | // MQTT server settings. 4 | #define MQTT_SERVER "xxx.cloudmqtt.com" // Change it with yours data. 5 | #define MQTT_PORT 12345 // Change it with yours data. 6 | #define MQTT_USER "xxxxx" // Change it with yours data. 7 | #define MQTT_PASS "xxxxx" // Change it with yours data. -------------------------------------------------------------------------------- /ProDinoESP32_2/examples/RS485Echo/RS485Echo.ino: -------------------------------------------------------------------------------- 1 | // RS485Echo.ino 2 | // Company: KMP Electronics Ltd, Bulgaria 3 | // Web: https://kmpelectronics.eu/ 4 | // Supported boards: 5 | // ProDino ESP32 V1 https://kmpelectronics.eu/products/prodino-esp32-v1/ 6 | // ProDino ESP32 Ethernet V1 https://kmpelectronics.eu/products/prodino-esp32-ethernet-v1/ 7 | // ProDino ESP32 GSM V1 https://kmpelectronics.eu/products/prodino-esp32-gsm-v1/ 8 | // ProDino ESP32 LoRa V1 https://kmpelectronics.eu/products/prodino-esp32-lora-v1/ 9 | // ProDino ESP32 LoRa RFM V1 https://kmpelectronics.eu/products/prodino-esp32-lora-rfm-v1/ 10 | // ProDino ESP32 Ethernet GSM V1 https://kmpelectronics.eu/products/prodino-esp32-ethernet-gsm-v1/ 11 | // ProDino ESP32 Ethernet LoRa V1 https://kmpelectronics.eu/products/prodino-esp32-ethernet-lora-v1/ 12 | // ProDino ESP32 Ethernet LoRa RFM V1 https://kmpelectronics.eu/products/prodino-esp32-ethernet-lora-rfm-v1/ 13 | // Description: 14 | // RS485 an echo example. It works as received data stored in a buffer and transmit it back. 15 | // Example link: https://kmpelectronics.eu/tutorials-examples/prodino-esp32-versions-examples/ 16 | // Version: 1.0.0 17 | // Date: 06.03.2020 18 | // Author: Plamen Kovandjiev 19 | 20 | #include "KMPProDinoESP32.h" 21 | #include "KMPCommon.h" 22 | 23 | const uint8_t BUFF_MAX = 255; 24 | 25 | uint8_t _dataBuffer[BUFF_MAX]; 26 | 27 | /** 28 | * @brief Setup void. Ii is Arduino executed first. Initialize DiNo board. 29 | * 30 | * 31 | * @return void 32 | */ 33 | void setup() 34 | { 35 | delay(5000); 36 | 37 | Serial.begin(115200); 38 | Serial.println("The example RS485Echo is starting..."); 39 | 40 | KMPProDinoESP32.begin(ProDino_ESP32); 41 | //KMPProDinoESP32.begin(ProDino_ESP32_Ethernet); 42 | //KMPProDinoESP32.begin(ProDino_ESP32_GSM); 43 | //KMPProDinoESP32.begin(ProDino_ESP32_LoRa); 44 | //KMPProDinoESP32.begin(ProDino_ESP32_LoRa_RFM); 45 | //KMPProDinoESP32.begin(ProDino_ESP32_Ethernet_GSM); 46 | //KMPProDinoESP32.begin(ProDino_ESP32_Ethernet_LoRa); 47 | //KMPProDinoESP32.begin(ProDino_ESP32_Ethernet_LoRa_RFM); 48 | KMPProDinoESP32.setStatusLed(blue); 49 | 50 | // Start RS485 with baud 19200 and 8N1. 51 | KMPProDinoESP32.rs485Begin(19200); 52 | 53 | Serial.println("The example RS485Echo is started"); 54 | delay(1000); 55 | KMPProDinoESP32.offStatusLed(); 56 | } 57 | 58 | /** 59 | * @brief Loop void. Arduino executed second. 60 | * 61 | * 62 | * @return void 63 | */ 64 | void loop() 65 | { 66 | KMPProDinoESP32.processStatusLed(green, 1000); 67 | 68 | // Waiting for a data. 69 | int i = KMPProDinoESP32.rs485Read(); 70 | 71 | if (i == -1) 72 | { 73 | return; 74 | } 75 | 76 | Serial.println("Receiving data..."); 77 | 78 | // If in RS485 port has any data - Status led is ON 79 | KMPProDinoESP32.setStatusLed(yellow); 80 | 81 | uint8_t buffPos = 0; 82 | 83 | // Reading data from the RS485 port. 84 | while (i > -1 && buffPos < BUFF_MAX) 85 | { 86 | // Adding received data in a buffer. 87 | _dataBuffer[buffPos++] = i; 88 | Serial.write((char)i); 89 | // Reading a next char. 90 | i = KMPProDinoESP32.rs485Read(); 91 | } 92 | 93 | // All data has been read. Off status led. 94 | KMPProDinoESP32.offStatusLed(); 95 | 96 | Serial.println(); 97 | Serial.println("Transmit received data."); 98 | 99 | KMPProDinoESP32.rs485Write(_dataBuffer, buffPos); 100 | } -------------------------------------------------------------------------------- /ProDinoESP32_2/examples/TCPInputWE/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | const char SSID[] = ""; 2 | const char SSID_PASSWORD[] = ""; -------------------------------------------------------------------------------- /ProDinoESP32_2/examples/TCPRelayWE/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | const char SSID[] = ""; 2 | const char SSID_PASSWORD[] = ""; -------------------------------------------------------------------------------- /ProDinoESP32_2/examples/UDPInputWE/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | const char SSID[] = ""; 2 | const char SSID_PASSWORD[] = ""; -------------------------------------------------------------------------------- /ProDinoESP32_2/examples/UDPRelayWE/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | const char SSID[] = ""; 2 | const char SSID_PASSWORD[] = ""; -------------------------------------------------------------------------------- /ProDinoESP32_2/examples/Web1WireWE/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | const char SSID[] = ""; 2 | const char SSID_PASSWORD[] = ""; -------------------------------------------------------------------------------- /ProDinoESP32_2/examples/WebDHTWE/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | const char SSID[] = ""; 2 | const char SSID_PASSWORD[] = ""; -------------------------------------------------------------------------------- /ProDinoESP32_2/examples/WebInputWE/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | const char SSID[] = ""; 2 | const char SSID_PASSWORD[] = ""; -------------------------------------------------------------------------------- /ProDinoESP32_2/examples/WebRS485WE/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | const char SSID[] = ""; 2 | const char SSID_PASSWORD[] = ""; -------------------------------------------------------------------------------- /ProDinoESP32_2/examples/WebRelayWE/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | const char SSID[] = ""; 2 | const char SSID_PASSWORD[] = ""; -------------------------------------------------------------------------------- /ProDinoESP32_2/examples/_StatusLed/_StatusLed.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Name: StatusLed.ino 3 | Created: 12/1/2020 4:19:55 PM 4 | Author: Dimitar Antonov 5 | */ 6 | 7 | 8 | #include "KMPProDinoESP32.h" 9 | #include "KMPCommon.h" 10 | 11 | /////////////////////////// | ETH | 3G | LoRa |LoRaRFM| LED | 12 | const BoardConfig_t MyBoard = { false, false, false, false , 3 }; 13 | 14 | // The setup() function runs once each time the micro-controller starts 15 | void setup() 16 | { 17 | KMPProDinoESP32.begin(MyBoard); 18 | } 19 | 20 | // Add the main program code into the continuous loop() function 21 | void loop() 22 | { 23 | KMPProDinoESP32.processStatusLed(red, 500, 0); 24 | KMPProDinoESP32.processStatusLed(green, 700, 1); 25 | KMPProDinoESP32.processStatusLed(blue, 900, 2); 26 | } 27 | -------------------------------------------------------------------------------- /ProDinoESP32_2/examples/_nkrgsmlib_sms/_nkrgsmlib_sms.ino: -------------------------------------------------------------------------------- 1 | /* 2 | SMS receiver 3 | 4 | This sketch waits for a SMS message 5 | and displays it through the Serial port. 6 | 7 | created 1 Dec 2020 8 | by Dimitar Antonov 9 | */ 10 | 11 | 12 | #include "KMPProDinoESP32.h" 13 | #include "KMPCommon.h" 14 | 15 | 16 | 17 | #define SECRET_PINNUMBER "" 18 | // Please enter your sensitive data in the Secret tab or arduino_secrets.h 19 | // PIN Number 20 | const char PINNUMBER[] = SECRET_PINNUMBER; 21 | 22 | // initialize the library instances 23 | GSM gsmAccess(false); 24 | GSM_SMS sms; 25 | 26 | // Array to hold the number a SMS is retreived from 27 | char senderNumber[20]; 28 | //////////////////////////// | ETH | 3G | LoRa |LoRaRFM| LED | 29 | const BoardConfig_t MyBoard = { false, false, false, false , 1 }; 30 | 31 | void setup() { 32 | // initialize serial communications and wait for port to open: 33 | Serial.begin(115200); 34 | while (!Serial) { 35 | ; // wait for serial port to connect. Needed for native USB port only 36 | } 37 | 38 | Serial.println("SMS Messages Receiver"); 39 | 40 | KMPProDinoESP32.begin(MyBoard); 41 | 42 | // connection state 43 | bool connected = false; 44 | 45 | // Start GSM connection 46 | while (!connected) { 47 | if (gsmAccess.begin(PINNUMBER) == GSM_READY) { 48 | connected = true; 49 | } 50 | else { 51 | Serial.println("Not connected"); 52 | delay(1000); 53 | } 54 | } 55 | 56 | KMPProDinoESP32.setStatusLed(blue); 57 | 58 | Serial.println("GSM initialized"); 59 | Serial.println("Waiting for messages"); 60 | } 61 | 62 | void loop() { 63 | int c; 64 | 65 | // If there are any SMSs available() 66 | if (sms.available()) { 67 | Serial.println("Message received from:"); 68 | 69 | // Get remote number 70 | sms.remoteNumber(senderNumber, 20); 71 | Serial.println(senderNumber); 72 | 73 | // An example of message disposal 74 | // Any messages starting with # should be discarded 75 | if (sms.peek() == '#') { 76 | Serial.println("Discarded SMS"); 77 | sms.flush(); 78 | } 79 | 80 | // Read message bytes and print them 81 | while ((c = sms.read()) != -1) { 82 | Serial.print((char)c); 83 | } 84 | 85 | Serial.println("\nEND OF MESSAGE"); 86 | 87 | // Delete message from modem memory 88 | sms.flush(); 89 | Serial.println("MESSAGE DELETED"); 90 | } 91 | 92 | delay(1000); 93 | 94 | } 95 | -------------------------------------------------------------------------------- /ProDinoESP32_2/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For ProDinoMKRZero 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | KMPProDinoMKRZero KEYWORD1 10 | KMPCommon KEYWORD1 11 | 12 | ####################################### 13 | # Methods and Functions (KEYWORD2) 14 | ####################################### 15 | 16 | begin KEYWORD2 17 | handleClient KEYWORD2 18 | on KEYWORD2 19 | addHandler KEYWORD2 20 | uri KEYWORD2 21 | method KEYWORD2 22 | client KEYWORD2 23 | send KEYWORD2 24 | arg KEYWORD2 25 | argName KEYWORD2 26 | args KEYWORD2 27 | hasArg KEYWORD2 28 | onNotFound KEYWORD2 29 | 30 | ####################################### 31 | # Constants (LITERAL1) 32 | ####################################### 33 | 34 | HTTP_GET LITERAL1 35 | HTTP_POST LITERAL1 36 | HTTP_ANY LITERAL1 37 | -------------------------------------------------------------------------------- /ProDinoESP32_2/library.properties: -------------------------------------------------------------------------------- 1 | name=ProDino_ESP32 2 | version=1.0.3 3 | author=KMP Electronics Ltd, Plamen Kovandjiev 4 | maintainer=Plamen Kovandjiev, 5 | sentence=Examples by our board KMP ProDino ESP32 series. 6 | paragraph=This library includes examples for KMP ProDino ESP32 series. 7 | category=Communication 8 | url=https://kmpelectronics.eu/products/prodino-esp32-v1/ 9 | architectures=esp32 -------------------------------------------------------------------------------- /ProDinoESP32_2/src/Ethernet/Dhcp.h: -------------------------------------------------------------------------------- 1 | // DHCP Library v0.3 - April 25, 2009 2 | // Author: Jordan Terrell - blog.jordanterrell.com 3 | 4 | #ifndef Dhcp_h 5 | #define Dhcp_h 6 | 7 | #include 8 | 9 | #include "Ethernet.h" 10 | #include "utility/w5100.h" 11 | 12 | /* DHCP state machine. */ 13 | #define STATE_DHCP_START 0 14 | #define STATE_DHCP_DISCOVER 1 15 | #define STATE_DHCP_REQUEST 2 16 | #define STATE_DHCP_LEASED 3 17 | #define STATE_DHCP_REREQUEST 4 18 | #define STATE_DHCP_RELEASE 5 19 | 20 | #define DHCP_FLAGSBROADCAST 0x8000 21 | 22 | /* UDP port numbers for DHCP */ 23 | #define DHCP_SERVER_PORT 67 /* from server to client */ 24 | #define DHCP_CLIENT_PORT 68 /* from client to server */ 25 | 26 | /* DHCP message OP code */ 27 | #define DHCP_BOOTREQUEST 1 28 | #define DHCP_BOOTREPLY 2 29 | 30 | /* DHCP message type */ 31 | #define DHCP_DISCOVER 1 32 | #define DHCP_OFFER 2 33 | #define DHCP_REQUEST 3 34 | #define DHCP_DECLINE 4 35 | #define DHCP_ACK 5 36 | #define DHCP_NAK 6 37 | #define DHCP_RELEASE 7 38 | #define DHCP_INFORM 8 39 | 40 | #define DHCP_HTYPE10MB 1 41 | #define DHCP_HTYPE100MB 2 42 | 43 | #define DHCP_HLENETHERNET 6 44 | #define DHCP_HOPS 0 45 | #define DHCP_SECS 0 46 | 47 | #define MAGIC_COOKIE 0x63825363 48 | #define MAX_DHCP_OPT 16 49 | 50 | #define HOST_NAME "WIZnet" 51 | #define DEFAULT_LEASE (900) //default lease time in seconds 52 | 53 | #define DHCP_CHECK_NONE (0) 54 | #define DHCP_CHECK_RENEW_FAIL (1) 55 | #define DHCP_CHECK_RENEW_OK (2) 56 | #define DHCP_CHECK_REBIND_FAIL (3) 57 | #define DHCP_CHECK_REBIND_OK (4) 58 | 59 | enum 60 | { 61 | padOption = 0, 62 | subnetMask = 1, 63 | timerOffset = 2, 64 | routersOnSubnet = 3, 65 | /* timeServer = 4, 66 | nameServer = 5,*/ 67 | dns = 6, 68 | /*logServer = 7, 69 | cookieServer = 8, 70 | lprServer = 9, 71 | impressServer = 10, 72 | resourceLocationServer = 11,*/ 73 | hostName = 12, 74 | /*bootFileSize = 13, 75 | meritDumpFile = 14,*/ 76 | domainName = 15, 77 | /*swapServer = 16, 78 | rootPath = 17, 79 | extentionsPath = 18, 80 | IPforwarding = 19, 81 | nonLocalSourceRouting = 20, 82 | policyFilter = 21, 83 | maxDgramReasmSize = 22, 84 | defaultIPTTL = 23, 85 | pathMTUagingTimeout = 24, 86 | pathMTUplateauTable = 25, 87 | ifMTU = 26, 88 | allSubnetsLocal = 27, 89 | broadcastAddr = 28, 90 | performMaskDiscovery = 29, 91 | maskSupplier = 30, 92 | performRouterDiscovery = 31, 93 | routerSolicitationAddr = 32, 94 | staticRoute = 33, 95 | trailerEncapsulation = 34, 96 | arpCacheTimeout = 35, 97 | ethernetEncapsulation = 36, 98 | tcpDefaultTTL = 37, 99 | tcpKeepaliveInterval = 38, 100 | tcpKeepaliveGarbage = 39, 101 | nisDomainName = 40, 102 | nisServers = 41, 103 | ntpServers = 42, 104 | vendorSpecificInfo = 43, 105 | netBIOSnameServer = 44, 106 | netBIOSdgramDistServer = 45, 107 | netBIOSnodeType = 46, 108 | netBIOSscope = 47, 109 | xFontServer = 48, 110 | xDisplayManager = 49,*/ 111 | dhcpRequestedIPaddr = 50, 112 | dhcpIPaddrLeaseTime = 51, 113 | /*dhcpOptionOverload = 52,*/ 114 | dhcpMessageType = 53, 115 | dhcpServerIdentifier = 54, 116 | dhcpParamRequest = 55, 117 | /*dhcpMsg = 56, 118 | dhcpMaxMsgSize = 57,*/ 119 | dhcpT1value = 58, 120 | dhcpT2value = 59, 121 | /*dhcpClassIdentifier = 60,*/ 122 | dhcpClientIdentifier = 61, 123 | endOption = 255 124 | }; 125 | 126 | typedef struct _RIP_MSG_FIXED 127 | { 128 | uint8_t op; 129 | uint8_t htype; 130 | uint8_t hlen; 131 | uint8_t hops; 132 | uint32_t xid; 133 | uint16_t secs; 134 | uint16_t flags; 135 | uint8_t ciaddr[4]; 136 | uint8_t yiaddr[4]; 137 | uint8_t siaddr[4]; 138 | uint8_t giaddr[4]; 139 | uint8_t chaddr[6]; 140 | } RIP_MSG_FIXED; 141 | 142 | #endif 143 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/Ethernet/Dns.h: -------------------------------------------------------------------------------- 1 | // Arduino DNS client for WizNet5100-based Ethernet shield 2 | // (c) Copyright 2009-2010 MCQN Ltd. 3 | // Released under Apache License, version 2.0 4 | 5 | #ifndef DNSClient_h 6 | #define DNSClient_h 7 | 8 | #include 9 | 10 | #include "Ethernet.h" 11 | #include "Dns.h" 12 | #include "utility/w5100.h" 13 | 14 | class DNSClient 15 | { 16 | public: 17 | void begin(const IPAddress& aDNSServer); 18 | 19 | /** Convert a numeric IP address string into a four-byte IP address. 20 | @param aIPAddrString IP address to convert 21 | @param aResult IPAddress structure to store the returned IP address 22 | @result 1 if aIPAddrString was successfully converted to an IP address, 23 | else error code 24 | */ 25 | int inet_aton(const char *aIPAddrString, IPAddress& aResult); 26 | 27 | /** Resolve the given hostname to an IP address. 28 | @param aHostname Name to be resolved 29 | @param aResult IPAddress structure to store the returned IP address 30 | @result 1 if aIPAddrString was successfully converted to an IP address, 31 | else error code 32 | */ 33 | int getHostByName(const char* aHostname, IPAddress& aResult, uint16_t timeout=5000); 34 | 35 | protected: 36 | uint16_t BuildRequest(const char* aName); 37 | uint16_t ProcessResponse(uint16_t aTimeout, IPAddress& aAddress); 38 | 39 | IPAddress iDNSServer; 40 | uint16_t iRequestId; 41 | EthernetUDP iUdp; 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/Ethernet/EthernetClient.h: -------------------------------------------------------------------------------- 1 | // This file is in the public domain. No copyright is claimed. 2 | 3 | #include 4 | 5 | #include "Ethernet.h" 6 | #include "Dns.h" 7 | #include "utility/w5100.h" -------------------------------------------------------------------------------- /ProDinoESP32_2/src/Ethernet/EthernetServer.h: -------------------------------------------------------------------------------- 1 | // This file is in the public domain. No copyright is claimed. 2 | 3 | #include 4 | 5 | #include "Ethernet.h" 6 | #include "utility/w5100.h" -------------------------------------------------------------------------------- /ProDinoESP32_2/src/Ethernet/EthernetUdp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Udp.cpp: Library to send/receive UDP packets with the Arduino ethernet shield. 3 | * This version only offers minimal wrapping of socket.cpp 4 | * Drop Udp.h/.cpp into the Ethernet library directory at hardware/libraries/Ethernet/ 5 | * 6 | * NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these) 7 | * 1) UDP does not guarantee the order in which assembled UDP packets are received. This 8 | * might not happen often in practice, but in larger network topologies, a UDP 9 | * packet can be received out of sequence. 10 | * 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being 11 | * aware of it. Again, this may not be a concern in practice on small local networks. 12 | * For more information, see http://www.cafeaulait.org/course/week12/35.html 13 | * 14 | * MIT License: 15 | * Copyright (c) 2008 Bjoern Hartmann 16 | * Permission is hereby granted, free of charge, to any person obtaining a copy 17 | * of this software and associated documentation files (the "Software"), to deal 18 | * in the Software without restriction, including without limitation the rights 19 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 20 | * copies of the Software, and to permit persons to whom the Software is 21 | * furnished to do so, subject to the following conditions: 22 | * 23 | * The above copyright notice and this permission notice shall be included in 24 | * all copies or substantial portions of the Software. 25 | * 26 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 27 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 28 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 29 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 30 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 31 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 32 | * THE SOFTWARE. 33 | * 34 | * bjoern@cs.stanford.edu 12/30/2008 35 | */ 36 | 37 | #include 38 | 39 | #include "Ethernet.h" 40 | #include "Dns.h" 41 | #include "utility/w5100.h" 42 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/KMPRS485Serial._cpp: -------------------------------------------------------------------------------- 1 | #include "KMPRS485Serial.h" 2 | #include 3 | #include 4 | 5 | #define RS485Transmit HIGH 6 | #define RS485Receive LOW 7 | 8 | KMPRS485SerialClass KMPRS485Serial; 9 | 10 | uint32_t _txFlushDelayuS; 11 | uint8_t _rs485Pin; 12 | 13 | void KMPRS485SerialClass::begin(uint8_t rs485Pin, unsigned long baud, 14 | int8_t rxPin, int8_t txPin, uint32_t config, bool invert, unsigned long timeout_ms) 15 | { 16 | _rs485Pin = rs485Pin; 17 | begin(baud, config, rxPin, txPin, invert, timeout_ms); 18 | _txFlushDelayuS = (uint32_t)((1000000 / baud) * 15); 19 | } 20 | 21 | /** 22 | * @brief Begin write data to RS485. 23 | * 24 | * @return void 25 | */ 26 | void KMPRS485SerialClass::rs485BeginWrite() 27 | { 28 | digitalWrite(_rs485Pin, RS485Transmit); 29 | // Allowing transmit pin should wait for 50 nS 30 | delayMicroseconds(70); 31 | } 32 | 33 | /** 34 | * @brief End write data to RS485. 35 | * 36 | * @return void 37 | */ 38 | void KMPRS485SerialClass::rs485EndWrite() 39 | { 40 | flush(); 41 | delayMicroseconds(_txFlushDelayuS); 42 | digitalWrite(_rs485Pin, RS485Receive); 43 | } 44 | 45 | size_t KMPRS485SerialClass::write(uint8_t n) 46 | { 47 | rs485BeginWrite(); 48 | 49 | size_t result = HardwareSerial::write(n); 50 | 51 | rs485EndWrite(); 52 | 53 | return result; 54 | } 55 | 56 | size_t KMPRS485SerialClass::write(const uint8_t *buffer, size_t size) 57 | { 58 | rs485BeginWrite(); 59 | 60 | size_t result = HardwareSerial::write(buffer, size); 61 | 62 | rs485EndWrite(); 63 | 64 | return result; 65 | } -------------------------------------------------------------------------------- /ProDinoESP32_2/src/KMPRS485Serial._h: -------------------------------------------------------------------------------- 1 | // KMPRS485Serial.h 2 | // Company: KMP Electronics Ltd, Bulgaria 3 | // Web: https://kmpelectronics.eu/ 4 | // Supported boards: 5 | // ProDino ESP32 V1 https://kmpelectronics.eu/products/prodino-esp32-v1/ 6 | // ProDino ESP32 Ethernet V1 https://kmpelectronics.eu/products/prodino-esp32-ethernet-v1/ 7 | // ProDino ESP32 GSM V1 https://kmpelectronics.eu/products/prodino-esp32-gsm-v1/ 8 | // ProDino ESP32 LoRa V1 https://kmpelectronics.eu/products/prodino-esp32-lora-v1/ 9 | // ProDino ESP32 LoRa RFM V1 https://kmpelectronics.eu/products/prodino-esp32-lora-rfm-v1/ 10 | // ProDino ESP32 Ethernet GSM V1 https://kmpelectronics.eu/products/prodino-esp32-ethernet-gsm-v1/ 11 | // ProDino ESP32 Ethernet LoRa V1 https://kmpelectronics.eu/products/prodino-esp32-ethernet-lora-v1/ 12 | // ProDino ESP32 Ethernet LoRa RFM V1 https://kmpelectronics.eu/products/prodino-esp32-ethernet-lora-rfm-v1/ 13 | // Description: 14 | // Header for KMP RS485 Serial. 15 | // Version: 1.0.0 16 | // Date: 11.03.2020 17 | // Authors: Plamen Kovandjiev & Dimitar Antonov 18 | 19 | #ifndef _KMPRS485SERIAL_H 20 | #define _KMPRS485SERIAL_H 21 | 22 | #include 23 | #include 24 | 25 | class KMPRS485SerialClass : public HardwareSerial 26 | { 27 | public: 28 | void begin(uint8_t rs485Pin, unsigned long baud, int8_t rxPin, int8_t txPin, uint32_t config = SERIAL_8N1, bool invert = false, unsigned long timeout_ms = 20000UL); 29 | 30 | size_t write(uint8_t n); 31 | size_t write(const uint8_t *buffer, size_t size); 32 | private: 33 | void rs485BeginWrite(); 34 | void rs485EndWrite(); 35 | }; 36 | 37 | extern KMPRS485SerialClass KMPRS485Serial; 38 | 39 | #endif -------------------------------------------------------------------------------- /ProDinoESP32_2/src/MCP23S08.cpp: -------------------------------------------------------------------------------- 1 | // MCP23S08.cpp 2 | // Company: KMP Electronics Ltd, Bulgaria 3 | // Web: http://kmpelectronics.eu/ 4 | // Supported hardware: 5 | // Expander MCP23S08 6 | // Description: 7 | // Source file for work with expander. 8 | // Version: 0.0.1 9 | // Date: 14.12.2018 10 | // Author: Plamen Kovandjiev 11 | 12 | #include "MCP23S08.h" 13 | 14 | #define READ_CMD 0x41 15 | #define WRITE_CMD 0x40 16 | 17 | #define IODIR 0x00 18 | #define IPOL 0x01 19 | #define GPINTEN 0x02 20 | #define DEFVAL 0x03 21 | #define INTCON 0x04 22 | #define IOCON 0x05 23 | #define GPPU 0x06 24 | #define INTF 0x07 25 | #define INTCAP 0x08 26 | #define GPIO 0x09 27 | #define OLAT 0x0A 28 | 29 | #define MAX_PIN_POS 7 30 | 31 | int _cs; 32 | 33 | uint8_t _expTxData[16] __attribute__((aligned(4))); 34 | uint8_t _expRxData[16] __attribute__((aligned(4))); 35 | 36 | void MCP23S08Class::init(int cs) 37 | { 38 | _cs = cs; 39 | // Expander settings. 40 | SPI.begin(); 41 | SPI.setHwCs(true); 42 | #ifndef ESP32 43 | SPI.setFrequency(1000000); 44 | SPI.setDataMode(SPI_MODE0); 45 | #endif // ESP32 46 | 47 | pinMode(_cs, OUTPUT); 48 | digitalWrite(_cs, HIGH); 49 | } 50 | 51 | /** 52 | * @brief Set a pin state. 53 | * 54 | * @param pinNumber The number of pin to be set. 55 | * @param state The pin state, true - 1, false - 0. 56 | * 57 | * @return void 58 | */ 59 | void MCP23S08Class::SetPinState(uint8_t pinNumber, bool state) 60 | { 61 | if (pinNumber > MAX_PIN_POS) 62 | { 63 | return; 64 | } 65 | 66 | uint8_t registerData = ReadRegister(OLAT); 67 | 68 | if (state) 69 | { 70 | registerData |= (1 << pinNumber); 71 | } 72 | else 73 | { 74 | registerData &= ~(1 << pinNumber); 75 | } 76 | 77 | WriteRegister(OLAT, registerData); 78 | } 79 | 80 | /** 81 | * @brief Get a pin state. 82 | * 83 | * @param pinNumber The number of pin to be get. 84 | * 85 | * @return State true - 1, false - 0. 86 | */ 87 | bool MCP23S08Class::GetPinState(uint8_t pinNumber) 88 | { 89 | if (pinNumber > MAX_PIN_POS) 90 | { 91 | return false; 92 | } 93 | 94 | uint8_t registerData = ReadRegister(GPIO); 95 | 96 | return registerData & (1 << pinNumber); 97 | } 98 | 99 | /** 100 | * @brief Read an expander MCP23S08 a register. 101 | * 102 | * @param address A register address. 103 | * 104 | * @return The data from the register. 105 | */ 106 | uint8_t MCP23S08Class::ReadRegister(uint8_t address) 107 | { 108 | _expTxData[0] = READ_CMD; 109 | _expTxData[1] = address; 110 | 111 | TransferBytes(); 112 | 113 | return _expRxData[2]; 114 | } 115 | 116 | /** 117 | * @brief Write data in expander MCP23S08 register. 118 | * 119 | * @param address A register address. 120 | * @param data A byte for write. 121 | * 122 | * @return void. 123 | */ 124 | void MCP23S08Class::WriteRegister(uint8_t address, uint8_t data) 125 | { 126 | _expTxData[0] = WRITE_CMD; 127 | _expTxData[1] = address; 128 | _expTxData[2] = data; 129 | 130 | TransferBytes(); 131 | } 132 | 133 | void MCP23S08Class::TransferBytes() 134 | { 135 | digitalWrite(_cs, LOW); 136 | SPI.transferBytes(_expTxData, _expRxData, 3); 137 | digitalWrite(_cs, HIGH); 138 | } 139 | 140 | /** 141 | * @brief Set the expander MCP23S08 a pin direction. 142 | * 143 | * @param pinNumber Pin number for set. 144 | * @param mode direction mode. 0 - INPUT, 1 - OUTPUT. 145 | * 146 | * @return void 147 | */ 148 | void MCP23S08Class::SetPinDirection(uint8_t pinNumber, uint8_t mode) 149 | { 150 | if (pinNumber > MAX_PIN_POS) 151 | { 152 | return; 153 | } 154 | 155 | uint8_t registerData = ReadRegister(IODIR); 156 | 157 | if (INPUT == mode) 158 | { 159 | registerData |= (1 << pinNumber); 160 | } 161 | else 162 | { 163 | registerData &= ~(1 << pinNumber); 164 | } 165 | 166 | WriteRegister(IODIR, registerData); 167 | } 168 | 169 | MCP23S08Class MCP23S08; 170 | 171 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/MCP23S08.h: -------------------------------------------------------------------------------- 1 | // MCP23S08.h 2 | // Company: KMP Electronics Ltd, Bulgaria 3 | // Web: https://kmpelectronics.eu/ 4 | // Supported hardware: 5 | // Expander MCP23S08 6 | // Description: 7 | // Header file for work with expander. 8 | // Version: 0.0.1 9 | // Date: 14.12.2018 10 | // Author: Plamen Kovandjiev 11 | 12 | #ifndef _MCP23S08_h 13 | #define _MCP2S308_h 14 | 15 | #include "arduino.h" 16 | #include 17 | 18 | class MCP23S08Class 19 | { 20 | protected: 21 | uint8_t ReadRegister(uint8_t address); 22 | void WriteRegister(uint8_t address, uint8_t data); 23 | void TransferBytes(); 24 | 25 | public: 26 | void init(int cs); 27 | void SetPinState(uint8_t pinNumber, bool state); 28 | bool GetPinState(uint8_t pinNumber); 29 | void SetPinDirection(uint8_t pinNumber, uint8_t mode); 30 | }; 31 | 32 | extern MCP23S08Class MCP23S08; 33 | 34 | #endif 35 | 36 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/MKRGSM/CHANGELOG: -------------------------------------------------------------------------------- 1 | MKRGSM ?.?.? - ????.??.?? 2 | 3 | MKRGSM 1.4.2 - 2019.06.18 4 | 5 | * fixed compilation under gcc 7.4.0 6 | 7 | MKRGSM 1.4.1 - 2019.04.15 8 | 9 | * Corrected GSMClient::connect(...) return code on failure 10 | * Corrected manage SSL profile AT command for GSMSSLClient 11 | * Replaced bundled "Amazon Root CA 1" root certificate with "Starfield Services Root Certificate Authority - G2 root CA" 12 | 13 | MKRGSM 1.4.0 - 2019.03.26 14 | 15 | * GSMBand, BandManagement example: Added support for 1800 MHz and UMTS 2100 MHz bands. 16 | * Added GSMModem::getICCID() API. 17 | * Added MODEM.setBaudRate(...) and MODEM.debug(print) API's. Thanks @dzindra. 18 | * Added Amazon Root CA 1. 19 | 20 | MKRGSM 1.3.3 - 2019.01.15 21 | 22 | * Fixed GSMClient::write for write lengths of > 256. 23 | 24 | MKRGSM 1.3.2 - 2018.12.17 25 | 26 | * Fixed one character SMS not being received correctly 27 | * Fixed warning and incorrect enum comparision in GSM::shutdown() 28 | 29 | MKRGSM 1.3.1 - 2018.11.12 30 | 31 | * Changed where required, in MKRGSM's examples, the server's URL arduino.cc\80 in example.org\80, because http://arduino.cc will be no longer available 32 | * Updated src/GSMClient.cpp in order to support asynchronous use of MKRGSM's library, moved the state assignement in the first line of stop() API. Thanks @Nels52 33 | * Added GSM status check in GSM::shutdown() to fix socket close errors generation by consecutive shutdown API's calling 34 | 35 | MKRGSM 1.3.0 - 2018.10.22 36 | 37 | * Changed GSM to GSM_OFF. Thanks @FrancMunoz 38 | * Added GSM::getLocalTime() API. Thanks @FrancMunoz 39 | * Added socket buffer to improve TCP socket read performance 40 | * Replaced boolean type with bool in examples. Thanks @per1234 41 | * Changed AT command handling to wait at least 20 ms for URC's, after receiving an AT command response before sending a new command. Thanks @FrancMunoz 42 | * Added root SSL certs and enabled SSL cert validation 43 | * Added GSM::setTimeout(...) and GPRS::setTimeout(...) API's 44 | * Added GSM::status() API 45 | 46 | MKRGSM 1.2.1 - 2018.09.13 47 | 48 | * Fixed GPRS credentials (username and password) not being used by the modem. Now auth type is set to automatic. 49 | 50 | MKRGSM 1.2.0 - 2018.07.23 51 | 52 | * Added MODEM.noDebug() API to disable debug output 53 | * GSM::isAccessAlive() now checks if network is registered 54 | * Added timeout to ping operations 55 | * Added GPRS::status() API to retrieve the current GPRS status 56 | * Fixed GSMClient::write(uint8_t c) 57 | 58 | MKRGSM 1.1.2 - 2018.02.20 59 | 60 | * Improved stability of low power mode 61 | * Improved stability and performance when using GSMClient and GSMUDP 62 | 63 | MKRGSM 1.1.1 - 2018.01.24 64 | 65 | * Fixed GSMServer.available() behaviour when client.stop() is called on an accepted socket 66 | 67 | MKRGSM 1.1.0 - 2018.01.02 68 | 69 | * Added new GSMLocation API 70 | * Fixed GSMClient write failing for lengths of 512 or over 71 | * Removed use of double negatives and corrected some bit wise ANDs with logical ANDs in example sketches 72 | 73 | MKRGSM 1.0.2 - 2017.12.11 74 | 75 | * Added new GPRSPing, GsmSSLWebClient, GPRSUdpNtpClient and SerialGSMPassthrough example sketches 76 | 77 | MKRGSM 1.0.1 - 2017.12.04 78 | 79 | * Examples updated with support for the Arduino Create secret tab 80 | 81 | MKRGSM 1.0.0 - 2017.11.29 82 | 83 | * Initial release 84 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/MKRGSM/README.adoc: -------------------------------------------------------------------------------- 1 | = MKRGSM Library for Arduino = 2 | 3 | image:https://travis-ci.org/arduino-libraries/MKRGSM.svg?branch=master["Build Status", link="https://travis-ci.org/arduino-libraries/MKRGSM"] 4 | 5 | This library enables an Arduino MKR GSM 1400 board to do most of the operations you can do with a GSM phone: place and receive voice calls, send and receive SMS, and connect to the internet over a GPRS network. 6 | 7 | For more information about this library please visit us at 8 | http://www.arduino.cc/en/Reference/MKRGSM 9 | 10 | == License == 11 | 12 | Copyright (c) 2017 Arduino AG. All right reserved. 13 | 14 | This library is free software; you can redistribute it and/or 15 | modify it under the terms of the GNU Lesser General Public 16 | License as published by the Free Software Foundation; either 17 | version 2.1 of the License, or (at your option) any later version. 18 | 19 | This library is distributed in the hope that it will be useful, 20 | but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | Lesser General Public License for more details. 23 | 24 | You should have received a copy of the GNU Lesser General Public 25 | License along with this library; if not, write to the Free Software 26 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -------------------------------------------------------------------------------- /ProDinoESP32_2/src/MKRGSM/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For MKRGSM 3 | ####################################### 4 | # Class 5 | ####################################### 6 | 7 | MKRGSM KEYWORD1 8 | GSM KEYWORD1 9 | GSMVoiceCall KEYWORD1 10 | GSM_SMS KEYWORD1 11 | GPRS KEYWORD1 12 | GSMClient KEYWORD1 13 | GSMServer KEYWORD1 14 | GSMModem KEYWORD1 15 | GSMScanner KEYWORD1 16 | GSMPIN KEYWORD1 17 | GSMBand KEYWORD1 18 | GSMSSLClient KEYWORD1 19 | GSMUdp KEYWORD1 20 | GSMLocation KEYWORD1 21 | 22 | ####################################### 23 | # Methods and Functions 24 | ####################################### 25 | 26 | begin KEYWORD2 27 | shutdown KEYWORD2 28 | gatVoiceCallStatus KEYWORD2 29 | ready KEYWORD2 30 | setTimeout KEYWORD2 31 | voiceCall KEYWORD2 32 | answerCall KEYWORD2 33 | hangCall KEYWORD2 34 | retrieveCallingNumber KEYWORD2 35 | beginSMS KEYWORD2 36 | endSMS KEYWORD2 37 | remoteNumber KEYWORD2 38 | attachGPRS KEYWORD2 39 | begnWrite KEYWORD2 40 | endWrite KEYWORD2 41 | getIMEI KEYWORD2 42 | getICCID KEYWORD2 43 | getCurrentCarrier KEYWORD2 44 | getSignalStrength KEYWORD2 45 | readNetworks KEYWORD2 46 | isPIN KEYWORD2 47 | checkPIN KEYWORD2 48 | checkPUK KEYWORD2 49 | changePIN KEYWORD2 50 | switchPIN KEYWORD2 51 | checkReg KEYWORD2 52 | getPINUsed KEYWORD2 53 | setPINUsed KEYWORD2 54 | getBand KEYWORD2 55 | setBand KEYWORD2 56 | getvoiceCallStatus KEYWORD2 57 | hostByName KEYWORD2 58 | ping KEYWORD2 59 | getTime KEYWORD2 60 | getLocalTime KEYWORD2 61 | lowPowerMode KEYWORD2 62 | noLowPowerMode KEYWORD2 63 | peekDTMF KEYWORD2 64 | readDTMF KEYWORD2 65 | writeDTMF KEYWORD2 66 | enableI2SInput KEYWORD2 67 | disableI2SInput KEYWORD2 68 | latitude KEYWORD2 69 | longitude KEYWORD2 70 | altitude KEYWORD2 71 | accuracy KEYWORD2 72 | 73 | ####################################### 74 | # Constants 75 | ####################################### 76 | 77 | ERROR LITERAL1 78 | IDLE LITERAL1 79 | CONNECTING LITERAL1 80 | GSM_READY LITERAL1 81 | GPRS_READY LITERAL1 82 | TRANSPARENT_CONNECTED LITERAL1 83 | IDLE_CALL LITERAL1 84 | CALLING LITERAL1 85 | RECEIVINGCALL LITERAL1 86 | TALKING LITERAL1 87 | GSM_MODE_UNDEFINED LITERAL1 88 | GSM_MODE_EGSM LITERAL1 89 | GSM_MODE_DCS LITERAL1 90 | GSM_MODE_PCS LITERAL1 91 | GSM_MODE_EGSM_DCS LITERAL1 92 | GSM_MODE_GSM850_PCS LITERAL1 93 | GSM_MODE_GSM850_EGSM_DCS_PCS LITERAL1 94 | GSM_MODE_UMTS LITERAL1 95 | GSM_MODE_GSM850_EGSM_PCS_UMTS LITERAL1 96 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/MKRGSM/library.properties: -------------------------------------------------------------------------------- 1 | name=MKRGSM 2 | version=1.5.0 3 | author=Arduino 4 | maintainer=Arduino 5 | sentence=Enables GSM/GRPS network connection using the Arduino MKR GSM 1400 board. 6 | paragraph=Use this library to make/receive voice calls, to send and receive SMS with the u-blox SARA-U201 module.
This library also allows you to connect to internet through the GPRS networks. You can either use web Clients and Servers.
7 | category=Communication 8 | url=http://www.arduino.cc/en/Reference/MKRGSM 9 | architectures=samd 10 | includes=MKRGSM.h 11 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/MKRGSM/src/GPRS.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of the MKR GSM library. 3 | Copyright (C) 2017 Arduino AG (http://www.arduino.cc/) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef _GPRS_H_INCLUDED 21 | #define _GPRS_H_INCLUDED 22 | 23 | #include 24 | #include "GSM.h" 25 | 26 | #include "Modem.h" 27 | 28 | enum { 29 | GPRS_PING_DEST_UNREACHABLE = -1, 30 | GPRS_PING_TIMEOUT = -2, 31 | GPRS_PING_UNKNOWN_HOST = -3, 32 | GPRS_PING_ERROR = -4 33 | }; 34 | 35 | class GPRS : public ModemUrcHandler { 36 | 37 | public: 38 | 39 | GPRS(); 40 | virtual ~GPRS(); 41 | 42 | /** Attach to GPRS/GSM network 43 | @param networkId APN GPRS 44 | @param user Username 45 | @param pass Password 46 | @return connection status 47 | */ 48 | GSM3_NetworkStatus_t networkAttach(char* networkId, char* user, char* pass) 49 | { 50 | return attachGPRS(networkId, user, pass); 51 | }; 52 | 53 | /** Detach GPRS/GSM network 54 | @return connection status 55 | */ 56 | GSM3_NetworkStatus_t networkDetach(){ return detachGPRS(); }; 57 | 58 | /** Attach to GPRS service 59 | @param apn APN GPRS 60 | @param user_name Username 61 | @param password Password 62 | @param synchronous Sync mode 63 | @return connection status 64 | */ 65 | GSM3_NetworkStatus_t attachGPRS(const char* apn, const char* user_name, const char* password, bool synchronous = true); 66 | 67 | /** Detach GPRS service 68 | @param synchronous Sync mode 69 | @return connection status 70 | */ 71 | GSM3_NetworkStatus_t detachGPRS(bool synchronous = true); 72 | 73 | /** Returns 0 if last command is still executing 74 | @return 1 if success, >1 if error 75 | */ 76 | int ready(); 77 | 78 | /** Get actual assigned IP address in IPAddress format 79 | @return IP address in IPAddress format 80 | */ 81 | IPAddress getIPAddress(); 82 | 83 | void setTimeout(unsigned long timeout); 84 | 85 | int hostByName(const char* hostname, IPAddress& result); 86 | int hostByName(const String &hostname, IPAddress& result) { return hostByName(hostname.c_str(), result); } 87 | 88 | int ping(const char* hostname, uint8_t ttl = 128); 89 | int ping(const String& hostname, uint8_t ttl = 128); 90 | int ping(IPAddress ip, uint8_t ttl = 128); 91 | 92 | GSM3_NetworkStatus_t status(); 93 | 94 | void handleUrc(const String& urc); 95 | 96 | private: 97 | const char* _apn; 98 | const char* _username; 99 | const char* _password; 100 | int _state; 101 | GSM3_NetworkStatus_t _status; 102 | String _response; 103 | int _pingResult; 104 | unsigned long _timeout; 105 | }; 106 | 107 | #endif 108 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/MKRGSM/src/GSM.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of the MKR GSM library. 3 | Copyright (C) 2017 Arduino AG (http://www.arduino.cc/) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef _GSM_H_INCLUDED 21 | #define _GSM_H_INCLUDED 22 | 23 | #include 24 | 25 | enum GSM3_NetworkStatus_t { ERROR, IDLE, CONNECTING, GSM_READY, GPRS_READY, TRANSPARENT_CONNECTED, GSM_OFF}; 26 | 27 | class GSM { 28 | 29 | public: 30 | /** Constructor 31 | @param debug Determines debug mode 32 | */ 33 | GSM(bool debug = false); 34 | 35 | /** Start the GSM/GPRS modem, attaching to the GSM network 36 | @param pin SIM PIN number (4 digits in a string, example: "1234"). If 37 | NULL the SIM has no configured PIN. 38 | @param restart Restart the modem. Default is TRUE. The modem receives 39 | a signal through the Ctrl/D7 pin. If it is shut down, it will 40 | start-up. If it is running, it will restart. Takes up to 10 41 | seconds 42 | @param synchronous If TRUE the call only returns after the Start is complete 43 | or fails. If FALSE the call will return inmediately. You have 44 | to call repeatedly ready() until you get a result. Default is TRUE. 45 | @return If synchronous, GSM3_NetworkStatus_t. If asynchronous, returns 0. 46 | */ 47 | GSM3_NetworkStatus_t begin(const char* pin = 0, bool restart = true, bool synchronous = true); 48 | 49 | /** Check network access status 50 | @return 1 if Alive, 0 if down 51 | */ 52 | int isAccessAlive(); 53 | 54 | /** Shutdown the modem (power off really) 55 | @return true if successful 56 | */ 57 | bool shutdown(); 58 | 59 | /** Secure shutdown the modem (power off really) 60 | @return always true 61 | */ 62 | bool secureShutdown(); 63 | 64 | /** Get last command status 65 | @return returns 0 if last command is still executing, 1 success, >1 error 66 | */ 67 | int ready(); 68 | 69 | void setTimeout(unsigned long timeout); 70 | 71 | unsigned long getTime(); 72 | unsigned long getLocalTime(); 73 | 74 | int lowPowerMode(); 75 | int noLowPowerMode(); 76 | 77 | GSM3_NetworkStatus_t status(); 78 | 79 | private: 80 | GSM3_NetworkStatus_t _state; 81 | int _readyState; 82 | const char* _pin; 83 | String _response; 84 | unsigned long _timeout; 85 | }; 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/MKRGSM/src/GSMBand.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of the MKR GSM library. 3 | Copyright (C) 2017 Arduino AG (http://www.arduino.cc/) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include "Modem.h" 21 | 22 | #include "GSMBand.h" 23 | 24 | /* Used in URAT for set the access technology, the first value indicate 25 | the technology used (0 GSM/GPRS/eGSM (single mode) , 1 GSM/GPRS/eGSM and UMTS(dual mode)) 26 | the second parameter set, if more than one, which technology's bands should be preferred(0 GSM/GPRS/eGSM, 2 UTRAN)*/ 27 | #define GSM_BANDS "1,0" 28 | #define UMTS_BANDS "1,2" 29 | 30 | GSMBand::GSMBand(bool trace) 31 | { 32 | if (trace) { 33 | MODEM.debug(); 34 | } 35 | } 36 | 37 | GSM3_NetworkStatus_t GSMBand::begin() 38 | { 39 | return (GSM3_NetworkStatus_t)MODEM.begin(); 40 | } 41 | 42 | bool GSMBand::setRAT(const char* act) { 43 | 44 | MODEM.sendf("AT+URAT=%s", act); 45 | if (MODEM.waitForResponse(10000) == 1) { 46 | return true; 47 | } 48 | return false; 49 | } 50 | 51 | String GSMBand::getBand() 52 | { 53 | String response; 54 | 55 | MODEM.send("AT+UBANDSEL?"); 56 | 57 | if (MODEM.waitForResponse(100, &response) == 1) { 58 | if (response.startsWith("+UBANDSEL: ")) { 59 | response.remove(0, 11); 60 | 61 | if (response == "900") { 62 | return GSM_MODE_EGSM; 63 | } else if (response == "1800") { 64 | return GSM_MODE_DCS; 65 | } else if (response == "1900") { 66 | return GSM_MODE_PCS; 67 | } else if (response == "900,1800") { 68 | return GSM_MODE_EGSM_DCS; 69 | } else if (response == "850,1900") { 70 | return GSM_MODE_GSM850_PCS; 71 | } else if (response == "850,900,1800,1900") { 72 | return GSM_MODE_GSM850_EGSM_DCS_PCS; 73 | } else if (response == "2100") { 74 | return GSM_MODE_UMTS; 75 | } else if (response == "850,900,1900,2100") { 76 | return GSM_MODE_GSM850_EGSM_PCS_UMTS; 77 | } 78 | } 79 | } 80 | 81 | return GSM_MODE_UNDEFINED; 82 | } 83 | 84 | bool GSMBand::setBand(String band) 85 | { 86 | const char* bands; 87 | 88 | // Set the Radio Access Technology to support the 1800 MHz frequency 89 | // in accord with the bands selected 90 | if (band == "DCS_MODE" || band == "EGSM_DCS_MODE" || band == "GSM850_EGSM_DCS_PCS_MODE") { 91 | setRAT(GSM_BANDS); 92 | } else { 93 | setRAT(UMTS_BANDS); 94 | } 95 | 96 | if (band == GSM_MODE_EGSM) { 97 | bands = "900"; 98 | } else if (band == GSM_MODE_DCS) { 99 | bands = "1800"; 100 | } else if (band == GSM_MODE_PCS) { 101 | bands = "1900"; 102 | } else if (band == GSM_MODE_EGSM_DCS) { 103 | bands = "900,1800"; 104 | } else if (band == GSM_MODE_GSM850_PCS) { 105 | bands = "850,1900"; 106 | } else if (band == GSM_MODE_GSM850_EGSM_DCS_PCS) { 107 | bands = "850,900,1800,1900"; 108 | } else if (band == GSM_MODE_UMTS) { 109 | bands = "2100"; 110 | } else if (band == GSM_MODE_GSM850_EGSM_PCS_UMTS) { 111 | bands = "850,900,1900,2100"; 112 | } else { 113 | return false; 114 | } 115 | 116 | for (int i = 0; i < 10; i++) { 117 | MODEM.sendf("AT+UBANDSEL=%s", bands); 118 | int result = MODEM.waitForResponse(10000); 119 | 120 | if (result == 1) { 121 | return true; 122 | } else if (result == 2) { 123 | return false; 124 | } 125 | 126 | // retry ... 127 | delay(100); 128 | } 129 | 130 | return false; 131 | } 132 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/MKRGSM/src/GSMBand.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of the MKR GSM library. 3 | Copyright (C) 2017 Arduino AG (http://www.arduino.cc/) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef _GSM_BAND_H_INCLUDED 21 | #define _GSM_BAND_H_INCLUDED 22 | 23 | #include "GSM.h" 24 | 25 | #define NUMBEROFBANDS 9 26 | #define GSM_MODE_UNDEFINED "UNDEFINED" 27 | #define GSM_MODE_EGSM "EGSM_MODE" 28 | #define GSM_MODE_DCS "DCS_MODE" 29 | #define GSM_MODE_PCS "PCS_MODE" 30 | #define GSM_MODE_EGSM_DCS "EGSM_DCS_MODE" 31 | #define GSM_MODE_GSM850_PCS "GSM850_PCS_MODE" 32 | #define GSM_MODE_GSM850_EGSM_DCS_PCS "GSM850_EGSM_DCS_PCS_MODE" 33 | #define GSM_MODE_UMTS "UMTS_MODE" 34 | #define GSM_MODE_GSM850_EGSM_PCS_UMTS "GSM850_EGSM_PCS_UMTS_MODE" 35 | 36 | 37 | enum GSM3GSMBand {UNDEFINED, EGSM_MODE, DCS_MODE, PCS_MODE, EGSM_DCS_MODE, GSM850_PCS_MODE, GSM850_EGSM_DCS_PCS_MODE, GSM_UMTS_MODE, GSM_GSM850_EGSM_PCS_UMTS_MODE}; 38 | 39 | class GSMBand { 40 | 41 | public: 42 | 43 | /** Constructor 44 | @param trace If true, dumps all AT dialogue to Serial 45 | */ 46 | GSMBand(bool trace = false); 47 | 48 | /** Forces modem hardware restart, so we begin from scratch 49 | @return always returns IDLE status 50 | */ 51 | GSM3_NetworkStatus_t begin(); 52 | 53 | /** Get current modem work band 54 | @return current modem work band 55 | */ 56 | String getBand(); 57 | 58 | /** Changes the modem operating band 59 | @param band Desired new band 60 | @return true if success, false otherwise 61 | */ 62 | bool setBand(String band); 63 | 64 | private: 65 | 66 | /** Change the Radio access technology 67 | @param act desired access technology 68 | @return true if success, false otherwise 69 | */ 70 | bool setRAT(const char* act); 71 | }; 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/MKRGSM/src/GSMFileUtils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | 6 | class GSMFileUtils { 7 | public: 8 | GSMFileUtils(bool debug = false); 9 | 10 | bool begin(const bool restart); 11 | bool begin() { return begin(true); }; 12 | 13 | uint32_t fileCount() const { return _count; }; 14 | size_t listFiles(String list[]) const; 15 | uint32_t listFile(const String filename) const; 16 | 17 | uint32_t downloadFile(const String filename, const char buf[], const uint32_t size, const bool append); 18 | uint32_t downloadFile(const String filename, const char buf[], const uint32_t size) { return downloadFile(filename, buf, size, false); }; 19 | uint32_t downloadFile(const String filename, const String& buf) { return downloadFile(filename, buf.c_str(), buf.length(), false); } 20 | 21 | uint32_t appendFile(const String filename, const String& buf) { return downloadFile(filename, buf.c_str(), buf.length(), true); } 22 | uint32_t appendFile(const String filename, const char buf[], const uint32_t size) { return downloadFile(filename, buf, size, true); } 23 | 24 | bool deleteFile(const String filename); 25 | int deleteFiles(); 26 | 27 | uint32_t readFile(const String filename, String* content); 28 | uint32_t readFile(const String filename, uint8_t* content); 29 | uint32_t readBlock(const String filename, const uint32_t offset, const uint32_t len, uint8_t* content); 30 | 31 | uint32_t freeSpace(); 32 | 33 | private: 34 | int _count; 35 | String _files; 36 | 37 | bool _debug; 38 | 39 | void _countFiles(); 40 | int _getFileList(); 41 | 42 | }; 43 | 44 | void printFiles(const GSMFileUtils fileUtils); -------------------------------------------------------------------------------- /ProDinoESP32_2/src/MKRGSM/src/GSMLocation.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of the MKR GSM library. 3 | Copyright (C) 2017 Arduino AG (http://www.arduino.cc/) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include "GSMLocation.h" 21 | 22 | #define GSM_LOCATION_UPDATE_INTERVAL 1100 23 | 24 | GSMLocation::GSMLocation() : 25 | _commandSent(false), 26 | _locationAvailable(false), 27 | _latitude(0), 28 | _longitude(0), 29 | _altitude(0), 30 | _uncertainty(0) 31 | { 32 | MODEM.addUrcHandler(this); 33 | } 34 | 35 | GSMLocation::~GSMLocation() 36 | { 37 | MODEM.removeUrcHandler(this); 38 | } 39 | 40 | int GSMLocation::begin() 41 | { 42 | MODEM.send("AT+ULOCCELL=1"); 43 | 44 | if (MODEM.waitForResponse() != 1) { 45 | return 0; 46 | } 47 | 48 | return 1; 49 | } 50 | 51 | int GSMLocation::available() 52 | { 53 | MODEM.poll(); 54 | 55 | if (!_commandSent) { 56 | _commandSent = true; 57 | _locationAvailable = false; 58 | 59 | MODEM.send("AT+ULOC=2,2,0,1,1"); 60 | MODEM.waitForResponse(); 61 | } 62 | 63 | if (_locationAvailable) { 64 | _commandSent = false; 65 | _locationAvailable = false; 66 | 67 | return 1; 68 | } 69 | 70 | return 0; 71 | } 72 | 73 | float GSMLocation::latitude() 74 | { 75 | return _latitude; 76 | } 77 | 78 | float GSMLocation::longitude() 79 | { 80 | return _longitude; 81 | } 82 | 83 | long GSMLocation::altitude() 84 | { 85 | return _altitude; 86 | } 87 | 88 | long GSMLocation::accuracy() 89 | { 90 | return _uncertainty; 91 | } 92 | 93 | void GSMLocation::handleUrc(const String& urc) 94 | { 95 | if (urc.startsWith("+UULOC: ")) { 96 | String temp = urc; 97 | int lastCommaIndex; 98 | 99 | _locationAvailable = true; 100 | 101 | lastCommaIndex = temp.lastIndexOf(','); 102 | _uncertainty = temp.substring(lastCommaIndex + 1).toInt(); 103 | temp.remove(lastCommaIndex); 104 | 105 | lastCommaIndex = temp.lastIndexOf(','); 106 | _altitude = temp.substring(lastCommaIndex + 1).toInt(); 107 | temp.remove(lastCommaIndex); 108 | 109 | lastCommaIndex = temp.lastIndexOf(','); 110 | _longitude = temp.substring(lastCommaIndex + 1).toFloat(); 111 | temp.remove(lastCommaIndex); 112 | 113 | lastCommaIndex = temp.lastIndexOf(','); 114 | _latitude = temp.substring(lastCommaIndex + 1).toFloat(); 115 | temp.remove(lastCommaIndex); 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/MKRGSM/src/GSMLocation.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of the MKR GSM library. 3 | Copyright (C) 2017 Arduino AG (http://www.arduino.cc/) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef _GSM_LOCATION_H_INCLUDED 21 | #define _GSM_LOCATION_H_INCLUDED 22 | 23 | #include 24 | 25 | #include "Modem.h" 26 | 27 | class GSMLocation : public ModemUrcHandler { 28 | 29 | public: 30 | GSMLocation(); 31 | virtual ~GSMLocation(); 32 | 33 | int begin(); 34 | 35 | int available(); 36 | 37 | float latitude(); 38 | float longitude(); 39 | long altitude(); 40 | long accuracy(); 41 | 42 | void handleUrc(const String& urc); 43 | 44 | private: 45 | bool _commandSent; 46 | bool _locationAvailable; 47 | 48 | float _latitude; 49 | float _longitude; 50 | long _altitude; 51 | long _uncertainty; 52 | }; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/MKRGSM/src/GSMModem.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of the MKR GSM library. 3 | Copyright (C) 2017 Arduino AG (http://www.arduino.cc/) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include "Modem.h" 21 | 22 | #include "GSMModem.h" 23 | 24 | GSMModem::GSMModem() 25 | { 26 | } 27 | 28 | int GSMModem::begin() 29 | { 30 | if (!MODEM.begin()) { 31 | return 0; 32 | } 33 | 34 | return 1; 35 | } 36 | 37 | String GSMModem::getIMEI() 38 | { 39 | String imei; 40 | 41 | imei.reserve(15); 42 | 43 | MODEM.send("AT+CGSN"); 44 | MODEM.waitForResponse(100, &imei); 45 | 46 | return imei; 47 | } 48 | 49 | String GSMModem::getICCID() 50 | { 51 | String iccid; 52 | 53 | iccid.reserve(7 + 20); 54 | 55 | MODEM.send("AT+CCID"); 56 | MODEM.waitForResponse(1000, &iccid); 57 | 58 | if (iccid.startsWith("+CCID: ")) { 59 | iccid.remove(0, 7); 60 | } else { 61 | iccid = ""; 62 | } 63 | 64 | return iccid; 65 | } 66 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/MKRGSM/src/GSMModem.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of the MKR GSM library. 3 | Copyright (C) 2017 Arduino AG (http://www.arduino.cc/) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef _GSM_MODEM_H_INCLUDED 21 | #define _GSM_MODEM_H_INCLUDED 22 | 23 | #include 24 | 25 | class GSMModem { 26 | 27 | public: 28 | 29 | /** Constructor */ 30 | GSMModem(); 31 | 32 | /** Check modem response and restart it 33 | */ 34 | int begin(); 35 | 36 | /** Obtain modem IMEI (command AT) 37 | @return modem IMEI number 38 | */ 39 | String getIMEI(); 40 | 41 | /** Obtain SIM card ICCID (command AT) 42 | @return SIM ICCID number 43 | */ 44 | String getICCID(); 45 | }; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/MKRGSM/src/GSMPIN.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of the MKR GSM library. 3 | Copyright (C) 2017 Arduino AG (http://www.arduino.cc/) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include "Modem.h" 21 | 22 | #include "GSMPIN.h" 23 | 24 | GSMPIN::GSMPIN() : 25 | _pinUsed(false) 26 | { 27 | } 28 | 29 | void GSMPIN::begin() 30 | { 31 | MODEM.begin(); 32 | } 33 | 34 | int GSMPIN::isPIN() 35 | { 36 | String response; 37 | 38 | for (unsigned long start = millis(); (millis() - start) < 1000;) { 39 | MODEM.send("AT+CPIN?"); 40 | 41 | if (MODEM.waitForResponse(10000, &response) == 1) { 42 | if (response.startsWith("+CPIN: ")) { 43 | if (response.endsWith("READY")) { 44 | return 0; 45 | } else if (response.endsWith("SIM PIN")) { 46 | return 1; 47 | } else if (response.endsWith("SIM PUK")) { 48 | return -1; 49 | } else { 50 | return -2; 51 | } 52 | } 53 | } 54 | 55 | delay(100); 56 | } 57 | 58 | return -2; 59 | } 60 | 61 | int GSMPIN::checkPIN(String pin) 62 | { 63 | MODEM.sendf("AT+CPIN=\"%s\"", pin.c_str()); 64 | if (MODEM.waitForResponse(10000) == 1) { 65 | return 0; 66 | } 67 | 68 | return -1; 69 | } 70 | 71 | 72 | int GSMPIN::checkPUK(String puk, String pin) 73 | { 74 | MODEM.sendf("AT+CPIN=\"%s\",\"%s\"", puk.c_str(), pin.c_str()); 75 | if (MODEM.waitForResponse(10000) == 1) { 76 | return 0; 77 | } 78 | 79 | return -1; 80 | } 81 | 82 | void GSMPIN::changePIN(String old, String pin) 83 | { 84 | MODEM.sendf("AT+CPWD=\"SC\",\"%s\",\"%s\"", old.c_str(), pin.c_str()); 85 | if (MODEM.waitForResponse(10000) == 1) { 86 | Serial.println("Pin changed succesfully."); 87 | } else { 88 | Serial.println("ERROR"); 89 | } 90 | } 91 | 92 | void GSMPIN::switchPIN(String pin) 93 | { 94 | String response; 95 | 96 | MODEM.send("AT+CLCK=\"SC\",2"); 97 | if (MODEM.waitForResponse(180000, &response) != 1) { 98 | Serial.println("ERROR"); 99 | return; 100 | } 101 | 102 | if (response == "+CLCK: 0") { 103 | MODEM.sendf("AT+CLCK=\"SC\",1,\"%s\"", pin.c_str()); 104 | if (MODEM.waitForResponse(180000, &response) == 1) { 105 | Serial.println("OK. PIN lock on."); 106 | _pinUsed = true; 107 | } else { 108 | Serial.println("ERROR"); 109 | _pinUsed = false; 110 | } 111 | } else if (response == "+CLCK: 1") { 112 | MODEM.sendf("AT+CLCK=\"SC\",0,\"%s\"", pin.c_str()); 113 | if (MODEM.waitForResponse(180000, &response) == 1) { 114 | Serial.println("OK. PIN lock off."); 115 | _pinUsed = false; 116 | } else { 117 | Serial.println("ERROR"); 118 | _pinUsed = true; 119 | } 120 | } else { 121 | Serial.println("ERROR"); 122 | } 123 | } 124 | 125 | int GSMPIN::checkReg() 126 | { 127 | for (unsigned long start = millis(); (millis() - start) < 10000L;) { 128 | MODEM.send("AT+CREG?"); 129 | 130 | String response = ""; 131 | 132 | if (MODEM.waitForResponse(100, &response) == 1) { 133 | if (response.startsWith("+CREG: ")) { 134 | if (response.endsWith(",1")) { 135 | return 0; 136 | } else if (response.endsWith(",5")) { 137 | return 1; 138 | } 139 | } 140 | } 141 | 142 | delay(100); 143 | } 144 | 145 | return -1; 146 | } 147 | 148 | bool GSMPIN::getPINUsed() 149 | { 150 | return _pinUsed; 151 | } 152 | 153 | void GSMPIN::setPINUsed(bool used) 154 | { 155 | _pinUsed = used; 156 | } 157 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/MKRGSM/src/GSMPIN.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of the MKR GSM library. 3 | Copyright (C) 2017 Arduino AG (http://www.arduino.cc/) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef _GSM_PIN_H_INCLUDED 21 | #define _GSM_PIN_H_INCLUDED 22 | 23 | #include 24 | 25 | class GSMPIN { 26 | 27 | public: 28 | 29 | /** Constructor */ 30 | GSMPIN(); 31 | 32 | /** Check modem response and restart it 33 | */ 34 | void begin(); 35 | 36 | /** Check if PIN lock or PUK lock is activated 37 | @return 0 if PIN lock is off, 1 if PIN lock is on, -1 if PUK lock is on, -2 if error exists 38 | */ 39 | int isPIN(); 40 | 41 | /** Check if PIN code is correct and valid 42 | @param pin PIN code 43 | @return 0 if is correct, -1 if is incorrect 44 | */ 45 | int checkPIN(String pin); 46 | 47 | /** Check if PUK code is correct and establish new PIN code 48 | @param puk PUK code 49 | @param pin New PIN code 50 | @return 0 if successful, otherwise return -1 51 | */ 52 | int checkPUK(String puk, String pin); 53 | 54 | /** Change PIN code 55 | @param old Old PIN code 56 | @param pin New PIN code 57 | */ 58 | void changePIN(String old, String pin); 59 | 60 | /** Change PIN lock status 61 | @param pin PIN code 62 | */ 63 | void switchPIN(String pin); 64 | 65 | /** Check if modem was registered in GSM/GPRS network 66 | @return 0 if modem was registered, 1 if modem was registered in roaming, -1 if error exists 67 | */ 68 | int checkReg(); 69 | 70 | /** Return if PIN lock is used 71 | @return true if PIN lock is used, otherwise, return false 72 | */ 73 | bool getPINUsed(); 74 | 75 | /** Set PIN lock status 76 | @param used New PIN lock status 77 | */ 78 | void setPINUsed(bool used); 79 | 80 | private: 81 | bool _pinUsed; 82 | }; 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/MKRGSM/src/GSMSSLClient.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of the MKR GSM library. 3 | Copyright (C) 2017 Arduino AG (http://www.arduino.cc/) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef _GSM_SSL_CLIENT_H_INCLUDED 21 | #define _GSM_SSL_CLIENT_H_INCLUDED 22 | 23 | #include "GSMClient.h" 24 | #include "utility/GSMRootCerts.h" 25 | class GSMSSLClient : public GSMClient { 26 | 27 | public: 28 | GSMSSLClient(bool synch = true); 29 | virtual ~GSMSSLClient(); 30 | 31 | virtual int ready(); 32 | 33 | virtual int connect(IPAddress ip, uint16_t port); 34 | virtual int connect(const char* host, uint16_t port); 35 | virtual void setSignedCertificate(const uint8_t* cert, const char* name, size_t size); 36 | virtual void setPrivateKey(const uint8_t* key, const char* name, size_t size); 37 | virtual void useSignedCertificate(const char* name); 38 | virtual void usePrivateKey(const char* name); 39 | virtual void setTrustedRoot(const char* name); 40 | virtual void setUserRoots(const GSMRootCert * userRoots, size_t size); 41 | virtual void eraseTrustedRoot(); 42 | 43 | private: 44 | static bool _rootCertsLoaded; 45 | int _certIndex; 46 | int _state; 47 | const GSMRootCert * _gsmRoots; 48 | int _sizeRoot; 49 | 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/MKRGSM/src/GSMScanner.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of the MKR GSM library. 3 | Copyright (C) 2017 Arduino AG (http://www.arduino.cc/) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include "Modem.h" 21 | 22 | #include "GSMScanner.h" 23 | 24 | GSMScanner::GSMScanner(bool trace) 25 | { 26 | if (trace) { 27 | MODEM.debug(); 28 | } 29 | } 30 | 31 | GSM3_NetworkStatus_t GSMScanner::begin() 32 | { 33 | MODEM.begin(); 34 | 35 | return IDLE; 36 | } 37 | 38 | String GSMScanner::getCurrentCarrier() 39 | { 40 | String response; 41 | 42 | MODEM.send("AT+COPS?"); 43 | if (MODEM.waitForResponse(180000, &response) == 1) { 44 | int firstQuoteIndex = response.indexOf('"'); 45 | int lastQuoteIndex = response.lastIndexOf('"'); 46 | 47 | if (firstQuoteIndex != -1 && lastQuoteIndex != -1 && firstQuoteIndex != lastQuoteIndex) { 48 | return response.substring(firstQuoteIndex + 1, lastQuoteIndex); 49 | } 50 | } 51 | 52 | return ""; 53 | } 54 | 55 | String GSMScanner::getSignalStrength() 56 | { 57 | String response; 58 | 59 | MODEM.send("AT+CSQ"); 60 | if (MODEM.waitForResponse(100, &response) == 1) { 61 | int firstSpaceIndex = response.indexOf(' '); 62 | int lastCommaIndex = response.lastIndexOf(','); 63 | 64 | if (firstSpaceIndex != -1 && lastCommaIndex != -1) { 65 | return response.substring(firstSpaceIndex + 1, lastCommaIndex); 66 | } 67 | } 68 | 69 | return ""; 70 | } 71 | 72 | String GSMScanner::readNetworks() 73 | { 74 | String response; 75 | 76 | MODEM.send("AT+COPS=?"); 77 | if (MODEM.waitForResponse(180000, &response) == 1) { 78 | String result; 79 | unsigned int responseLength = response.length(); 80 | 81 | for(unsigned int i = 0; i < responseLength; i++) { 82 | for (; i < responseLength; i++) { 83 | if (response[i] == '"') { 84 | result += "> "; 85 | break; 86 | } 87 | } 88 | 89 | for (i++; i < responseLength; i++) { 90 | if (response[i] == '"') { 91 | result += '\n'; 92 | break; 93 | } 94 | 95 | result += response[i]; 96 | } 97 | 98 | for (i++; i < responseLength; i++) { 99 | if (response[i] == ')') { 100 | break; 101 | } 102 | } 103 | } 104 | 105 | return result; 106 | } 107 | 108 | return ""; 109 | } 110 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/MKRGSM/src/GSMScanner.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of the MKR GSM library. 3 | Copyright (C) 2017 Arduino AG (http://www.arduino.cc/) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef _GSM_SCANNER_H_INCLUDED 21 | #define _GSM_SCANNER_H_INCLUDED 22 | 23 | #include "GSM.h" 24 | 25 | class GSMScanner { 26 | 27 | public: 28 | /** Constructor 29 | @param trace if true, dumps all AT dialogue to Serial 30 | @return - 31 | */ 32 | GSMScanner(bool trace = false); 33 | 34 | /** begin (forces modem hardware restart, so we begin from scratch) 35 | @return Always returns IDLE status 36 | */ 37 | GSM3_NetworkStatus_t begin(); 38 | 39 | /** Read current carrier 40 | @return Current carrier 41 | */ 42 | String getCurrentCarrier(); 43 | 44 | /** Obtain signal strength 45 | @return Signal Strength 46 | */ 47 | String getSignalStrength(); 48 | 49 | /** Search available carriers 50 | @return A string with list of networks available 51 | */ 52 | String readNetworks(); 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/MKRGSM/src/GSMServer.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of the MKR GSM library. 3 | Copyright (C) 2017 Arduino AG (http://www.arduino.cc/) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef _GSM_SERVER_H_INCLUDED 21 | #define _GSM_SERVER_H_INCLUDED 22 | 23 | #include 24 | #include "GSMClient.h" 25 | 26 | #include "Modem.h" 27 | 28 | class GSMServer : public Server, public ModemUrcHandler { 29 | 30 | public: 31 | 32 | /** Constructor 33 | @param port Port 34 | @param synch True if the server acts synchronously 35 | */ 36 | GSMServer(uint16_t port, bool synch = true); 37 | 38 | ~GSMServer(); 39 | 40 | /** Get last command status 41 | @return returns 0 if last command is still executing, 1 success, >1 error 42 | */ 43 | int ready(); 44 | 45 | /** Initialize server 46 | */ 47 | void begin(); 48 | 49 | /** Check if there is an incoming client request 50 | @param synch If true, the returned client is synchronous or 51 | blocking. 52 | @return Client if successful, else error 53 | */ 54 | GSMClient available(bool synch = true); 55 | 56 | // Just to keep in line with Ethernet. 57 | // Write to every open socket... 58 | //void write(uint8_t); 59 | //void write(const uint8_t *buf, size_t size); 60 | 61 | /** Begin write in socket 62 | */ 63 | void beginWrite(); 64 | 65 | /** Write character in socket 66 | @param c Character 67 | @return size 68 | */ 69 | size_t write(uint8_t c); 70 | 71 | /** Write buffer in socket 72 | @param buf Buffer 73 | @return size 74 | */ 75 | size_t write(const uint8_t *buf); 76 | 77 | /** Write buffer in socket with size 78 | @param buf Buffer 79 | @param sz Buffer size 80 | @return size 81 | */ 82 | size_t write(const uint8_t *buf, size_t sz); 83 | 84 | /** End write in socket 85 | */ 86 | void endWrite(); 87 | 88 | /** Stop server 89 | */ 90 | void stop(); 91 | 92 | virtual void handleUrc(const String& urc); 93 | 94 | private: 95 | uint16_t _port; 96 | bool _synch; 97 | 98 | int _socket; 99 | int _state; 100 | String _response; 101 | 102 | #define MAX_CHILD_SOCKETS 6 103 | struct { 104 | int socket; 105 | bool accepted; 106 | int available; 107 | } _childSockets[MAX_CHILD_SOCKETS]; 108 | }; 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/MKRGSM/src/GSMUdp.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of the MKR GSM library. 3 | Copyright (C) 2017 Arduino AG (http://www.arduino.cc/) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef _GSM_UDP_H_INCLUDED 21 | #define _GSM_UDP_H_INCLUDED 22 | 23 | #include 24 | 25 | #include "Modem.h" 26 | 27 | class GSMUDP : public UDP, public ModemUrcHandler { 28 | 29 | public: 30 | GSMUDP(); // Constructor 31 | virtual ~GSMUDP(); 32 | 33 | virtual uint8_t begin(uint16_t); // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use 34 | virtual void stop(); // Finish with the UDP socket 35 | 36 | // Sending UDP packets 37 | 38 | // Start building up a packet to send to the remote host specific in ip and port 39 | // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port 40 | virtual int beginPacket(IPAddress ip, uint16_t port); 41 | // Start building up a packet to send to the remote host specific in host and port 42 | // Returns 1 if successful, 0 if there was a problem resolving the hostname or port 43 | virtual int beginPacket(const char *host, uint16_t port); 44 | // Finish off this packet and send it 45 | // Returns 1 if the packet was sent successfully, 0 if there was an error 46 | virtual int endPacket(); 47 | // Write a single byte into the packet 48 | virtual size_t write(uint8_t); 49 | // Write size bytes from buffer into the packet 50 | virtual size_t write(const uint8_t *buffer, size_t size); 51 | 52 | using Print::write; 53 | 54 | // Start processing the next available incoming packet 55 | // Returns the size of the packet in bytes, or 0 if no packets are available 56 | virtual int parsePacket(); 57 | // Number of bytes remaining in the current packet 58 | virtual int available(); 59 | // Read a single byte from the current packet 60 | virtual int read(); 61 | // Read up to len bytes from the current packet and place them into buffer 62 | // Returns the number of bytes read, or 0 if none are available 63 | virtual int read(unsigned char* buffer, size_t len); 64 | // Read up to len characters from the current packet and place them into buffer 65 | // Returns the number of characters read, or 0 if none are available 66 | virtual int read(char* buffer, size_t len) { return read((unsigned char*)buffer, len); }; 67 | // Return the next byte from the current packet without moving on to the next byte 68 | virtual int peek(); 69 | virtual void flush(); // Finish reading the current packet 70 | 71 | // Return the IP address of the host who sent the current incoming packet 72 | virtual IPAddress remoteIP(); 73 | // Return the port of the host who sent the current incoming packet 74 | virtual uint16_t remotePort(); 75 | 76 | virtual void handleUrc(const String& urc); 77 | 78 | private: 79 | int _socket; 80 | bool _packetReceived; 81 | 82 | IPAddress _txIp; 83 | const char* _txHost; 84 | uint16_t _txPort; 85 | size_t _txSize; 86 | uint8_t _txBuffer[512]; 87 | 88 | IPAddress _rxIp; 89 | uint16_t _rxPort; 90 | size_t _rxSize; 91 | size_t _rxIndex; 92 | uint8_t _rxBuffer[512]; 93 | }; 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/MKRGSM/src/GSMVoiceCall.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of the MKR GSM library. 3 | Copyright (C) 2017 Arduino AG (http://www.arduino.cc/) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef _GSM_VOICE_CALL_H_INCLUDED 21 | #define _GSM_VOICE_CALL_H_INCLUDED 22 | 23 | #include "Modem.h" 24 | 25 | enum GSM3_voiceCall_st { IDLE_CALL, CALLING, RECEIVINGCALL, TALKING}; 26 | 27 | class GSMVoiceCall : public ModemUrcHandler { 28 | 29 | public: 30 | /** Service creation 31 | @param synch If true, the service calls are synchronois 32 | */ 33 | GSMVoiceCall(bool synch = true); 34 | 35 | virtual ~GSMVoiceCall(); 36 | 37 | /** Voice call status 38 | @return Status of the voice call, as described in GSM3MobileVoiceProvider.h 39 | { IDLE_CALL, CALLING, RECEIVINGCALL, TALKING}; 40 | */ 41 | GSM3_voiceCall_st getvoiceCallStatus(); 42 | 43 | /** Get last command status 44 | @return Returns 0 if last command is still executing, 1 success, >1 error 45 | */ 46 | int ready(); 47 | 48 | /** Place a voice call. If asynchronous, returns while ringing. If synchronous 49 | returns if the call is stablished or cancelled. 50 | @param to Receiver number. Country extension can be used or not. 51 | Char buffer should not be released or used until command is over 52 | @param timeout In millisecods. Time ringing before closing the call. 53 | Only used in synchronous mode. 54 | If zero, ring undefinitely 55 | @return In asynchronous mode returns 0 if last command is still executing, 1 success, >1 error 56 | In synchronous mode returns 1 if the call is placed, 0 if not. 57 | */ 58 | int voiceCall(const char* to, unsigned long timeout = 30000); 59 | 60 | /** Accept an incoming voice call 61 | @return In asynchronous mode returns 0 if last command is still executing, 1 success, >1 error 62 | In synchronous mode returns 1 if the call is answered, 0 if not. 63 | */ 64 | int answerCall(); 65 | 66 | /** Hang a stablished call or an incoming ring 67 | @return In asynchronous mode returns 0 if last command is still executing, 1 success, >1 error 68 | In synchronous mode returns 1 if the call is answered, 0 if not. 69 | */ 70 | int hangCall(); 71 | 72 | /** Retrieve the calling number, put it in buffer 73 | @param buffer pointer to the buffer memory 74 | @param bufsize size of available memory area, at least should be 10 characters 75 | @return In asynchronous mode returns 0 if last command is still executing, 1 success, >1 error 76 | In synchronous mode returns 1 if the number is correcty taken 0 if not 77 | */ 78 | int retrieveCallingNumber(char* buffer, int bufsize); 79 | 80 | int peekDTMF(); 81 | int readDTMF(); 82 | int writeDTMF(char c); 83 | 84 | int enableI2SInput(long sampleRate); 85 | int disableI2SInput(); 86 | 87 | virtual void handleUrc(const String& urc); 88 | private: 89 | int _synch; 90 | GSM3_voiceCall_st _callStatus; 91 | String _dtmfBuffer; 92 | }; 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/MKRGSM/src/GSM_SMS.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of the MKR GSM library. 3 | Copyright (C) 2017 Arduino AG (http://www.arduino.cc/) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef _GSM_SMS_H_INCLUDED 21 | #define _GSM_SMS_H_INCLUDED 22 | 23 | #include 24 | 25 | class GSM_SMS : public Stream { 26 | 27 | public: 28 | /** Constructor 29 | @param synch Determines sync mode 30 | */ 31 | GSM_SMS(bool synch = true); 32 | 33 | /** Write a character in SMS message 34 | @param c Character 35 | @return size 36 | */ 37 | size_t write(uint8_t c); 38 | 39 | /** Begin a SMS to send it 40 | @param to Destination 41 | @return error command if it exists 42 | */ 43 | int beginSMS(const char* to); 44 | 45 | /** Get last command status 46 | @return returns 0 if last command is still executing, 1 success, >1 error 47 | */ 48 | int ready(); 49 | 50 | /** End SMS 51 | @return error command if it exists 52 | */ 53 | int endSMS(); 54 | 55 | /** Check if SMS available and prepare it to be read 56 | @return number of bytes in a received SMS 57 | */ 58 | int available(); 59 | 60 | /** Read sender number phone 61 | @param number Buffer for save number phone 62 | @param nlength Buffer length 63 | @return 1 success, >1 error 64 | */ 65 | int remoteNumber(char* number, int nlength); 66 | 67 | /** Read one char for SMS buffer (advance circular buffer) 68 | @return byte 69 | */ 70 | int read(); 71 | 72 | /** Read a byte but do not advance the buffer header (circular buffer) 73 | @return byte 74 | */ 75 | int peek(); 76 | 77 | /** Delete the SMS from Modem memory and proccess answer 78 | */ 79 | void flush(); 80 | 81 | private: 82 | bool _synch; 83 | int _state; 84 | String _incomingBuffer; 85 | int _smsDataIndex; 86 | int _smsDataEndIndex; 87 | bool _smsTxActive; 88 | }; 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/MKRGSM/src/MKRGSM.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of the MKR GSM library. 3 | Copyright (C) 2017 Arduino AG (http://www.arduino.cc/) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef _MKRGSM_H_INCLUDED 21 | #define _MKRGSM_H_INCLUDED 22 | 23 | #include "GSM.h" 24 | #include "GSMVoiceCall.h" 25 | #include "GSM_SMS.h" 26 | #include "GPRS.h" 27 | #include "GSMClient.h" 28 | #include "GSMServer.h" 29 | #include "GSMModem.h" 30 | #include "GSMScanner.h" 31 | #include "GSMPIN.h" 32 | #include "GSMBand.h" 33 | 34 | #include "GSMSSLClient.h" 35 | #include "GSMUdp.h" 36 | #include "GSMLocation.h" 37 | 38 | #include "GSMFileUtils.h" 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/MKRGSM/src/Modem.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of the MKR GSM library. 3 | Copyright (C) 2017 Arduino AG (http://www.arduino.cc/) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef _MODEM_INCLUDED_H 21 | #define _MODEM_INCLUDED_H 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | class ModemUrcHandler { 29 | public: 30 | virtual void handleUrc(const String& urc) = 0; 31 | }; 32 | 33 | class ModemClass { 34 | public: 35 | ModemClass(HardwareSerial& uart, unsigned long baud, int resetPin, int dtrPin, int ctsPin, int rtsPin, int rxPin, int txPin); 36 | 37 | int begin(bool restart = true); 38 | void end(); 39 | 40 | void debug(); 41 | void debug(Print& p); 42 | void noDebug(); 43 | 44 | int autosense(unsigned int timeout = 10000); 45 | 46 | int noop(); 47 | int reset(); 48 | 49 | int lowPowerMode(); 50 | int noLowPowerMode(); 51 | 52 | size_t write(uint8_t c); 53 | size_t write(const uint8_t*, size_t); 54 | 55 | void send(const char* command); 56 | void send(const String& command) { send(command.c_str()); } 57 | void sendf(const char *fmt, ...); 58 | 59 | int waitForResponse(unsigned long timeout = 100, String* responseDataStorage = NULL); 60 | int waitForPrompt(unsigned long timeout = 500); 61 | int ready(); 62 | void poll(); 63 | void setResponseDataStorage(String* responseDataStorage); 64 | 65 | void addUrcHandler(ModemUrcHandler* handler); 66 | void removeUrcHandler(ModemUrcHandler* handler); 67 | 68 | void setBaudRate(unsigned long baud); 69 | 70 | private: 71 | HardwareSerial* _uart; 72 | unsigned long _baud; 73 | int _resetPin; 74 | int _dtrPin; 75 | int _ctsPin; 76 | int _rtsPin; 77 | int _rxPin; 78 | int _txPin; 79 | bool _lowPowerMode; 80 | unsigned long _lastResponseOrUrcMillis; 81 | 82 | enum { 83 | AT_COMMAND_IDLE, 84 | AT_RECEIVING_RESPONSE 85 | } _atCommandState; 86 | int _ready; 87 | String _buffer; 88 | String* _responseDataStorage; 89 | 90 | #define MAX_URC_HANDLERS 10 // 7 sockets + GPRS + GSMLocation + GSMVoiceCall 91 | static ModemUrcHandler* _urcHandlers[MAX_URC_HANDLERS]; 92 | static Print* _debugPrint; 93 | }; 94 | 95 | extern ModemClass MODEM; 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/MKRGSM/src/utility/GSMSocketBuffer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of the MKR GSM library. 3 | Copyright (C) 2018 Arduino AG (http://www.arduino.cc/) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | #include "../Modem.h" 24 | 25 | #include "GSMSocketBuffer.h" 26 | 27 | #define GSM_SOCKET_NUM_BUFFERS (sizeof(_buffers) / sizeof(_buffers[0])) 28 | 29 | #define GSM_SOCKET_BUFFER_SIZE 512 30 | 31 | GSMSocketBufferClass::GSMSocketBufferClass() 32 | { 33 | memset(&_buffers, 0x00, sizeof(_buffers)); 34 | } 35 | 36 | GSMSocketBufferClass::~GSMSocketBufferClass() 37 | { 38 | for (unsigned int i = 0; i < GSM_SOCKET_NUM_BUFFERS; i++) { 39 | close(i); 40 | } 41 | } 42 | 43 | void GSMSocketBufferClass::close(int socket) 44 | { 45 | if (_buffers[socket].data) { 46 | free(_buffers[socket].data); 47 | _buffers[socket].data = _buffers[socket].head = NULL; 48 | _buffers[socket].length = 0; 49 | } 50 | } 51 | 52 | int GSMSocketBufferClass::available(int socket) 53 | { 54 | if (_buffers[socket].length == 0) { 55 | if (_buffers[socket].data == NULL) { 56 | _buffers[socket].data = _buffers[socket].head = (uint8_t*)malloc(GSM_SOCKET_BUFFER_SIZE); 57 | _buffers[socket].length = 0; 58 | } 59 | 60 | String response; 61 | 62 | MODEM.sendf("AT+USORD=%d,%d", socket, GSM_SOCKET_BUFFER_SIZE); 63 | int status = MODEM.waitForResponse(10000, &response); 64 | if (status != 1) { 65 | return -1; 66 | } 67 | 68 | if (!response.startsWith("+USORD: ")) { 69 | return 0; 70 | } 71 | 72 | int firstQuoteIndex = response.indexOf("\""); 73 | 74 | response.remove(0, firstQuoteIndex + 1); 75 | response.remove(response.length() - 1); 76 | 77 | size_t size = response.length() / 2; 78 | 79 | for (size_t i = 0; i < size; i++) { 80 | byte n1 = response[i * 2]; 81 | byte n2 = response[i * 2 + 1]; 82 | 83 | if (n1 > '9') { 84 | n1 = (n1 - 'A') + 10; 85 | } else { 86 | n1 = (n1 - '0'); 87 | } 88 | 89 | if (n2 > '9') { 90 | n2 = (n2 - 'A') + 10; 91 | } else { 92 | n2 = (n2 - '0'); 93 | } 94 | 95 | _buffers[socket].data[i] = (n1 << 4) | n2; 96 | } 97 | 98 | _buffers[socket].head = _buffers[socket].data; 99 | _buffers[socket].length = size; 100 | } 101 | 102 | return _buffers[socket].length; 103 | } 104 | 105 | int GSMSocketBufferClass::peek(int socket) 106 | { 107 | if (!available(socket)) { 108 | return -1; 109 | } 110 | 111 | return *_buffers[socket].head; 112 | } 113 | 114 | int GSMSocketBufferClass::read(int socket, uint8_t* data, size_t length) 115 | { 116 | int avail = available(socket); 117 | 118 | if (!avail) { 119 | return 0; 120 | } 121 | 122 | if (avail < (int)length) { 123 | length = avail; 124 | } 125 | 126 | memcpy(data, _buffers[socket].head, length); 127 | _buffers[socket].head += length; 128 | _buffers[socket].length -= length; 129 | 130 | return length; 131 | } 132 | 133 | GSMSocketBufferClass GSMSocketBuffer; 134 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/MKRGSM/src/utility/GSMSocketBuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of the MKR GSM library. 3 | Copyright (C) 2018 Arduino AG (http://www.arduino.cc/) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef _GSMSOCKET_BUFFER_H_INCLUDED 21 | #define _GSMSOCKET_BUFFER_H_INCLUDED 22 | 23 | #include 24 | #include 25 | 26 | class GSMSocketBufferClass { 27 | 28 | public: 29 | public: 30 | GSMSocketBufferClass(); 31 | virtual ~GSMSocketBufferClass(); 32 | 33 | void close(int socket); 34 | 35 | int available(int socket); 36 | int peek(int socket); 37 | int read(int socket, uint8_t* data, size_t length); 38 | 39 | private: 40 | struct { 41 | uint8_t* data; 42 | uint8_t* head; 43 | int length; 44 | } _buffers[7]; 45 | }; 46 | 47 | extern GSMSocketBufferClass GSMSocketBuffer; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/NeoPixel/internal/DotStarGenericMethod.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | NeoPixel library helper functions for DotStars using general Pins (APA102). 3 | 4 | Written by Michael C. Miller. 5 | 6 | I invest time and resources providing this open source code, 7 | please support me by dontating (see https://github.com/Makuna/NeoPixelBus) 8 | 9 | ------------------------------------------------------------------------- 10 | This file is part of the Makuna/NeoPixelBus library. 11 | 12 | NeoPixelBus is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU Lesser General Public License as 14 | published by the Free Software Foundation, either version 3 of 15 | the License, or (at your option) any later version. 16 | 17 | NeoPixelBus is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU Lesser General Public License for more details. 21 | 22 | You should have received a copy of the GNU Lesser General Public 23 | License along with NeoPixel. If not, see 24 | . 25 | -------------------------------------------------------------------------*/ 26 | 27 | #pragma once 28 | 29 | class DotStarGenericMethod 30 | { 31 | public: 32 | DotStarGenericMethod(uint8_t pinClock, uint8_t pinData, uint16_t pixelCount, size_t elementSize) : 33 | _pinClock(pinClock), 34 | _pinData(pinData), 35 | _sizePixels(pixelCount * elementSize) 36 | { 37 | pinMode(pinClock, OUTPUT); 38 | pinMode(pinData, OUTPUT); 39 | 40 | _pixels = (uint8_t*)malloc(_sizePixels); 41 | memset(_pixels, 0, _sizePixels); 42 | } 43 | 44 | ~DotStarGenericMethod() 45 | { 46 | pinMode(_pinClock, INPUT); 47 | pinMode(_pinData, INPUT); 48 | 49 | free(_pixels); 50 | } 51 | 52 | bool IsReadyToUpdate() const 53 | { 54 | return true; // dot stars don't have a required delay 55 | } 56 | 57 | void Initialize() 58 | { 59 | digitalWrite(_pinClock, LOW); 60 | digitalWrite(_pinData, LOW); 61 | } 62 | 63 | void Update() 64 | { 65 | // start frame 66 | for (int startFrameByte = 0; startFrameByte < 4; startFrameByte++) 67 | { 68 | _transmitByte(0x00); 69 | } 70 | 71 | // data 72 | uint8_t* data = _pixels; 73 | const uint8_t* endData = _pixels + _sizePixels; 74 | while (data < endData) 75 | { 76 | _transmitByte(*data++); 77 | } 78 | 79 | // end frame 80 | // one bit for every two pixels with no less than 1 byte 81 | const uint16_t countEndFrameBytes = ((_sizePixels / 4) + 15) / 16; 82 | for (uint16_t endFrameByte = 0; endFrameByte < countEndFrameBytes; endFrameByte++) 83 | { 84 | _transmitByte(0xff); 85 | } 86 | 87 | // set clock and data back to low between updates 88 | digitalWrite(_pinData, LOW); 89 | } 90 | 91 | uint8_t* getPixels() const 92 | { 93 | return _pixels; 94 | }; 95 | 96 | size_t getPixelsSize() const 97 | { 98 | return _sizePixels; 99 | }; 100 | 101 | private: 102 | const uint8_t _pinClock; // output pin number for clock line 103 | const uint8_t _pinData; // output pin number for data line 104 | const size_t _sizePixels; // Size of '_pixels' buffer below 105 | 106 | uint8_t* _pixels; // Holds LED color values 107 | 108 | void _transmitByte(uint8_t data) 109 | { 110 | for (int bit = 7; bit >= 0; bit--) 111 | { 112 | // set data bit on pin 113 | digitalWrite(_pinData, (data & 0x80) == 0x80 ? HIGH : LOW); 114 | 115 | // set clock high as data is ready 116 | digitalWrite(_pinClock, HIGH); 117 | 118 | data <<= 1; 119 | 120 | // set clock low as data pin is changed 121 | digitalWrite(_pinClock, LOW); 122 | } 123 | } 124 | }; 125 | 126 | typedef DotStarGenericMethod DotStarMethod; 127 | 128 | 129 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/NeoPixel/internal/Esp32_i2s.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(ARDUINO_ARCH_ESP32) 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | #include "esp_err.h" 10 | 11 | typedef enum { 12 | I2S_CHAN_STEREO, I2S_CHAN_RIGHT_TO_LEFT, I2S_CHAN_LEFT_TO_RIGHT, I2S_CHAN_RIGHT_ONLY, I2S_CHAN_LEFT_ONLY 13 | } i2s_tx_chan_mod_t; 14 | 15 | typedef enum { 16 | I2S_FIFO_16BIT_DUAL, I2S_FIFO_16BIT_SINGLE, I2S_FIFO_32BIT_DUAL, I2S_FIFO_32BIT_SINGLE 17 | } i2s_tx_fifo_mod_t; 18 | 19 | void i2sInit(uint8_t bus_num, uint32_t bits_per_sample, uint32_t sample_rate, i2s_tx_chan_mod_t chan_mod, i2s_tx_fifo_mod_t fifo_mod, size_t dma_count, size_t dma_len); 20 | 21 | void i2sSetPins(uint8_t bus_num, int8_t out, int8_t ws, int8_t bck, int8_t in); 22 | void i2sSetDac(uint8_t bus_num, bool right, bool left); 23 | 24 | esp_err_t i2sSetClock(uint8_t bus_num, uint8_t div_num, uint8_t div_b, uint8_t div_a, uint8_t bck, uint8_t bits_per_sample); 25 | esp_err_t i2sSetSampleRate(uint8_t bus_num, uint32_t sample_rate, uint8_t bits_per_sample); 26 | 27 | void i2sSetTxDataMode(uint8_t bus_num, i2s_tx_chan_mod_t chan_mod, i2s_tx_fifo_mod_t fifo_mod); 28 | 29 | void i2sSetSilenceBuf(uint8_t bus_num, uint8_t* data, size_t len); 30 | 31 | size_t i2sWrite(uint8_t bus_num, uint8_t* data, size_t len, bool copy, bool free_when_sent); 32 | bool i2sWriteDone(uint8_t bus_num); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/NeoPixel/internal/HsbColor.cpp: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | HsbColor provides a color object that can be directly consumed by NeoPixelBus 3 | 4 | Written by Michael C. Miller. 5 | 6 | I invest time and resources providing this open source code, 7 | please support me by dontating (see https://github.com/Makuna/NeoPixelBus) 8 | 9 | ------------------------------------------------------------------------- 10 | This file is part of the Makuna/NeoPixelBus library. 11 | 12 | NeoPixelBus is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU Lesser General Public License as 14 | published by the Free Software Foundation, either version 3 of 15 | the License, or (at your option) any later version. 16 | 17 | NeoPixelBus is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU Lesser General Public License for more details. 21 | 22 | You should have received a copy of the GNU Lesser General Public 23 | License along with NeoPixel. If not, see 24 | . 25 | -------------------------------------------------------------------------*/ 26 | 27 | #include "RgbColor.h" 28 | #include "HsbColor.h" 29 | 30 | 31 | HsbColor::HsbColor(const RgbColor& color) 32 | { 33 | // convert colors to float between (0.0 - 1.0) 34 | float r = color.R / 255.0f; 35 | float g = color.G / 255.0f; 36 | float b = color.B / 255.0f; 37 | 38 | float max = (r > g && r > b) ? r : (g > b) ? g : b; 39 | float min = (r < g && r < b) ? r : (g < b) ? g : b; 40 | 41 | float d = max - min; 42 | 43 | float h = 0.0; 44 | float v = max; 45 | float s = (v == 0.0f) ? 0 : (d / v); 46 | 47 | if (d != 0.0f) 48 | { 49 | if (r == max) 50 | { 51 | h = (g - b) / d + (g < b ? 6.0f : 0.0f); 52 | } 53 | else if (g == max) 54 | { 55 | h = (b - r) / d + 2.0f; 56 | } 57 | else 58 | { 59 | h = (r - g) / d + 4.0f; 60 | } 61 | h /= 6.0f; 62 | } 63 | 64 | 65 | H = h; 66 | S = s; 67 | B = v; 68 | } 69 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/NeoPixel/internal/HslColor.cpp: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | HslColor provides a color object that can be directly consumed by NeoPixelBus 3 | 4 | 5 | Written by Michael C. Miller. 6 | 7 | I invest time and resources providing this open source code, 8 | please support me by dontating (see https://github.com/Makuna/NeoPixelBus) 9 | 10 | ------------------------------------------------------------------------- 11 | This file is part of the Makuna/NeoPixelBus library. 12 | 13 | NeoPixelBus is free software: you can redistribute it and/or modify 14 | it under the terms of the GNU Lesser General Public License as 15 | published by the Free Software Foundation, either version 3 of 16 | the License, or (at your option) any later version. 17 | 18 | NeoPixelBus is distributed in the hope that it will be useful, 19 | but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | GNU Lesser General Public License for more details. 22 | 23 | You should have received a copy of the GNU Lesser General Public 24 | License along with NeoPixel. If not, see 25 | . 26 | -------------------------------------------------------------------------*/ 27 | 28 | #include "RgbColor.h" 29 | #include "HslColor.h" 30 | 31 | 32 | HslColor::HslColor(const RgbColor& color) 33 | { 34 | // convert colors to float between (0.0 - 1.0) 35 | float r = color.R / 255.0f; 36 | float g = color.G / 255.0f; 37 | float b = color.B / 255.0f; 38 | 39 | float max = (r > g && r > b) ? r : (g > b) ? g : b; 40 | float min = (r < g && r < b) ? r : (g < b) ? g : b; 41 | 42 | float h, s, l; 43 | l = (max + min) / 2.0f; 44 | 45 | if (max == min) 46 | { 47 | h = s = 0.0f; 48 | } 49 | else 50 | { 51 | float d = max - min; 52 | s = (l > 0.5f) ? d / (2.0f - (max + min)) : d / (max + min); 53 | 54 | if (r > g && r > b) 55 | { 56 | h = (g - b) / d + (g < b ? 6.0f : 0.0f); 57 | } 58 | else if (g > b) 59 | { 60 | h = (b - r) / d + 2.0f; 61 | } 62 | else 63 | { 64 | h = (r - g) / d + 4.0f; 65 | } 66 | h /= 6.0f; 67 | } 68 | 69 | H = h; 70 | S = s; 71 | L = l; 72 | } 73 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/NeoPixel/internal/HtmlColor.cpp: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | This file contains the HtmlColor implementation 3 | 4 | Written by Unai Uribarri 5 | 6 | I invest time and resources providing this open source code, 7 | please support me by dontating (see https://github.com/Makuna/NeoPixelBus) 8 | 9 | ------------------------------------------------------------------------- 10 | This file is part of the Makuna/NeoPixelBus library. 11 | 12 | NeoPixelBus is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU Lesser General Public License as 14 | published by the Free Software Foundation, either version 3 of 15 | the License, or (at your option) any later version. 16 | 17 | NeoPixelBus is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU Lesser General Public License for more details. 21 | 22 | You should have received a copy of the GNU Lesser General Public 23 | License along with NeoPixel. If not, see 24 | . 25 | -------------------------------------------------------------------------*/ 26 | #include "HtmlColor.h" 27 | 28 | static inline char hexdigit(uint8_t v) 29 | { 30 | return v + (v < 10 ? '0' : 'a' - 10); 31 | } 32 | 33 | 34 | size_t HtmlColor::ToNumericalString(char* buf, size_t bufSize) const 35 | { 36 | size_t bufLen = bufSize - 1; 37 | 38 | if (bufLen-- > 0) 39 | { 40 | if (bufLen > 0) 41 | { 42 | buf[0] = '#'; 43 | } 44 | 45 | uint32_t color = Color; 46 | for (uint8_t indexDigit = 6; indexDigit > 0; indexDigit--) 47 | { 48 | if (bufLen > indexDigit) 49 | { 50 | buf[indexDigit] = hexdigit(color & 0x0000000f); 51 | } 52 | color >>= 4; 53 | } 54 | 55 | buf[(bufLen < 7 ? bufLen : 7)] = 0; 56 | } 57 | return 7; 58 | } 59 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/NeoPixel/internal/HtmlColorShortNames.cpp: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | HtmlShortColorNames provides a template class for access to the short name table 3 | 4 | Written by Michael C. Miller. 5 | 6 | I invest time and resources providing this open source code, 7 | please support me by dontating (see https://github.com/Makuna/NeoPixelBus) 8 | 9 | ------------------------------------------------------------------------- 10 | This file is part of the Makuna/NeoPixelBus library. 11 | 12 | NeoPixelBus is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU Lesser General Public License as 14 | published by the Free Software Foundation, either version 3 of 15 | the License, or (at your option) any later version. 16 | 17 | NeoPixelBus is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU Lesser General Public License for more details. 21 | 22 | You should have received a copy of the GNU Lesser General Public 23 | License along with NeoPixel. If not, see 24 | . 25 | -------------------------------------------------------------------------*/ 26 | 27 | #include "HtmlColor.h" 28 | #include "HtmlColorNameStrings.h" 29 | 30 | static const HtmlColorPair c_ShortColorNames[] PROGMEM = { 31 | { c_HtmlNameAqua, 0xffff }, 32 | { c_HtmlNameBlack, 0x0 }, 33 | { c_HtmlNameBlue, 0xff }, 34 | { c_HtmlNameFuchsia, 0xff00ff }, 35 | { c_HtmlNameGray, 0x808080 }, 36 | { c_HtmlNameGreen, 0x8000 }, 37 | { c_HtmlNameLime, 0xff00 }, 38 | { c_HtmlNameMaroon, 0x800000 }, 39 | { c_HtmlNameNavy, 0x80 }, 40 | { c_HtmlNameOlive, 0x808000 }, 41 | { c_HtmlNameOrange, 0xffa500 }, 42 | { c_HtmlNamePurple, 0x800080 }, 43 | { c_HtmlNameRed, 0xff0000 }, 44 | { c_HtmlNameSilver, 0xc0c0c0 }, 45 | { c_HtmlNameTeal, 0x8080 }, 46 | { c_HtmlNameWhite, 0xffffff }, 47 | { c_HtmlNameYellow, 0xffff00 }, 48 | }; 49 | 50 | 51 | const HtmlColorPair* HtmlShortColorNames::Pair(uint8_t index) 52 | { 53 | return &c_ShortColorNames[index]; 54 | } 55 | 56 | uint8_t HtmlShortColorNames::Count() 57 | { 58 | return countof(c_ShortColorNames); 59 | } -------------------------------------------------------------------------------- /ProDinoESP32_2/src/NeoPixel/internal/NeoBufferContext.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | NeoPixel library 3 | 4 | Written by Michael C. Miller. 5 | 6 | I invest time and resources providing this open source code, 7 | please support me by dontating (see https://github.com/Makuna/NeoPixelBus) 8 | 9 | ------------------------------------------------------------------------- 10 | This file is part of the Makuna/NeoPixelBus library. 11 | 12 | NeoPixelBus is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU Lesser General Public License as 14 | published by the Free Software Foundation, either version 3 of 15 | the License, or (at your option) any later version. 16 | 17 | NeoPixelBus is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU Lesser General Public License for more details. 21 | 22 | You should have received a copy of the GNU Lesser General Public 23 | License along with NeoPixel. If not, see 24 | . 25 | -------------------------------------------------------------------------*/ 26 | #pragma once 27 | 28 | // This is used to allow a template classes that share common buffer concept to 29 | // be able to pass that common information to functions 30 | // The template classes just need to expose a conversion operator to this type 31 | template struct NeoBufferContext 32 | { 33 | NeoBufferContext(uint8_t* pixels, 34 | size_t sizePixels) : 35 | Pixels(pixels), 36 | SizePixels(sizePixels) 37 | { 38 | } 39 | 40 | uint16_t PixelCount() const 41 | { 42 | return SizePixels / T_COLOR_FEATURE::PixelSize; 43 | }; 44 | 45 | uint8_t* Pixels; 46 | const size_t SizePixels; 47 | 48 | }; -------------------------------------------------------------------------------- /ProDinoESP32_2/src/NeoPixel/internal/NeoGamma.cpp: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | NeoPixelGamma class is used to correct RGB colors for human eye gamma levels 3 | 4 | Written by Michael C. Miller. 5 | 6 | I invest time and resources providing this open source code, 7 | please support me by dontating (see https://github.com/Makuna/NeoPixelBus) 8 | 9 | ------------------------------------------------------------------------- 10 | This file is part of the Makuna/NeoPixelBus library. 11 | 12 | NeoPixelBus is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU Lesser General Public License as 14 | published by the Free Software Foundation, either version 3 of 15 | the License, or (at your option) any later version. 16 | 17 | NeoPixelBus is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU Lesser General Public License for more details. 21 | 22 | You should have received a copy of the GNU Lesser General Public 23 | License along with NeoPixel. If not, see 24 | . 25 | -------------------------------------------------------------------------*/ 26 | 27 | #include 28 | #include "RgbColor.h" 29 | #include "RgbwColor.h" 30 | #include "NeoEase.h" 31 | #include "NeoGamma.h" 32 | 33 | const uint8_t NeoGammaTableMethod::_table[] = { 34 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 36 | 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 37 | 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 11, 11, 11, 38 | 12, 12, 13, 13, 14, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 39 | 19, 20, 20, 21, 22, 22, 23, 23, 24, 25, 25, 26, 26, 27, 28, 28, 40 | 29, 30, 30, 31, 32, 33, 33, 34, 35, 35, 36, 37, 38, 39, 39, 40, 41 | 41, 42, 43, 43, 44, 45, 46, 47, 48, 49, 50, 50, 51, 52, 53, 54, 42 | 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 71, 43 | 72, 73, 74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 86, 87, 88, 89, 44 | 91, 92, 93, 94, 96, 97, 98, 100, 101, 102, 104, 105, 106, 108, 109, 110, 45 | 112, 113, 115, 116, 118, 119, 121, 122, 123, 125, 126, 128, 130, 131, 133, 134, 46 | 136, 137, 139, 140, 142, 144, 145, 147, 149, 150, 152, 154, 155, 157, 159, 160, 47 | 162, 164, 166, 167, 169, 171, 173, 175, 176, 178, 180, 182, 184, 186, 187, 189, 48 | 191, 193, 195, 197, 199, 201, 203, 205, 207, 209, 211, 213, 215, 217, 219, 221, 49 | 223, 225, 227, 229, 231, 233, 235, 238, 240, 242, 244, 246, 248, 251, 253, 255 50 | }; -------------------------------------------------------------------------------- /ProDinoESP32_2/src/NeoPixel/internal/NeoGamma.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | NeoPixelGamma class is used to correct RGB colors for human eye gamma levels 3 | 4 | Written by Michael C. Miller. 5 | 6 | I invest time and resources providing this open source code, 7 | please support me by dontating (see https://github.com/Makuna/NeoPixelBus) 8 | 9 | ------------------------------------------------------------------------- 10 | This file is part of the Makuna/NeoPixelBus library. 11 | 12 | NeoPixelBus is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU Lesser General Public License as 14 | published by the Free Software Foundation, either version 3 of 15 | the License, or (at your option) any later version. 16 | 17 | NeoPixelBus is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU Lesser General Public License for more details. 21 | 22 | You should have received a copy of the GNU Lesser General Public 23 | License along with NeoPixel. If not, see 24 | . 25 | -------------------------------------------------------------------------*/ 26 | #pragma once 27 | 28 | // NeoGammaEquationMethod uses no memory but is slower than NeoGammaTableMethod 29 | class NeoGammaEquationMethod 30 | { 31 | public: 32 | static uint8_t Correct(uint8_t value) 33 | { 34 | return static_cast(255.0f * NeoEase::Gamma(value / 255.0f) + 0.5f); 35 | } 36 | }; 37 | 38 | // NeoGammaTableMethod uses 256 bytes of memory, but is significantly faster 39 | class NeoGammaTableMethod 40 | { 41 | public: 42 | static uint8_t Correct(uint8_t value) 43 | { 44 | return _table[value]; 45 | } 46 | 47 | private: 48 | static const uint8_t _table[256]; 49 | }; 50 | 51 | 52 | // use one of the method classes above as a converter for this template class 53 | template class NeoGamma 54 | { 55 | public: 56 | RgbColor Correct(const RgbColor& original) 57 | { 58 | return RgbColor(T_METHOD::Correct(original.R), 59 | T_METHOD::Correct(original.G), 60 | T_METHOD::Correct(original.B)); 61 | } 62 | 63 | RgbwColor Correct(const RgbwColor& original) 64 | { 65 | return RgbwColor(T_METHOD::Correct(original.R), 66 | T_METHOD::Correct(original.G), 67 | T_METHOD::Correct(original.B), 68 | T_METHOD::Correct(original.W) ); 69 | } 70 | }; 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/NeoPixel/internal/NeoHueBlend.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | NeoHueBlend provides method objects that can be directly consumed by 3 | blend template functions in HslColor and HsbColor 4 | 5 | Written by Michael C. Miller. 6 | 7 | I invest time and resources providing this open source code, 8 | please support me by dontating (see https://github.com/Makuna/NeoPixelBus) 9 | 10 | ------------------------------------------------------------------------- 11 | This file is part of the Makuna/NeoPixelBus library. 12 | 13 | NeoPixelBus is free software: you can redistribute it and/or modify 14 | it under the terms of the GNU Lesser General Public License as 15 | published by the Free Software Foundation, either version 3 of 16 | the License, or (at your option) any later version. 17 | 18 | NeoPixelBus is distributed in the hope that it will be useful, 19 | but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | GNU Lesser General Public License for more details. 22 | 23 | You should have received a copy of the GNU Lesser General Public 24 | License along with NeoPixel. If not, see 25 | . 26 | -------------------------------------------------------------------------*/ 27 | #pragma once 28 | 29 | class NeoHueBlendBase 30 | { 31 | protected: 32 | static float FixWrap(float value) 33 | { 34 | if (value < 0.0f) 35 | { 36 | value += 1.0f; 37 | } 38 | else if (value > 1.0f) 39 | { 40 | value -= 1.0f; 41 | } 42 | return value; 43 | } 44 | }; 45 | 46 | class NeoHueBlendShortestDistance : NeoHueBlendBase 47 | { 48 | public: 49 | static float HueBlend(float left, float right, float progress) 50 | { 51 | float delta = right - left; 52 | float base = left; 53 | if (delta > 0.5f) 54 | { 55 | base = right; 56 | delta = 1.0f - delta; 57 | progress = 1.0f - progress; 58 | } 59 | else if (delta < -0.5f) 60 | { 61 | delta = 1.0f + delta; 62 | } 63 | return FixWrap(base + (delta) * progress); 64 | }; 65 | }; 66 | 67 | class NeoHueBlendLongestDistance : NeoHueBlendBase 68 | { 69 | public: 70 | static float HueBlend(float left, float right, float progress) 71 | { 72 | float delta = right - left; 73 | float base = left; 74 | if (delta < 0.5f && delta >= 0.0f) 75 | { 76 | base = right; 77 | delta = 1.0f - delta; 78 | progress = 1.0f - progress; 79 | } 80 | else if (delta > -0.5f && delta < 0.0f) 81 | { 82 | delta = 1.0f + delta; 83 | } 84 | return FixWrap(base + delta * progress); 85 | }; 86 | }; 87 | 88 | class NeoHueBlendClockwiseDirection : NeoHueBlendBase 89 | { 90 | public: 91 | static float HueBlend(float left, float right, float progress) 92 | { 93 | float delta = right - left; 94 | float base = left; 95 | if (delta < 0.0f) 96 | { 97 | delta = 1.0f + delta; 98 | } 99 | 100 | return FixWrap(base + delta * progress); 101 | }; 102 | }; 103 | 104 | class NeoHueBlendCounterClockwiseDirection : NeoHueBlendBase 105 | { 106 | public: 107 | static float HueBlend(float left, float right, float progress) 108 | { 109 | float delta = right - left; 110 | float base = left; 111 | if (delta > 0.0f) 112 | { 113 | delta = delta - 1.0f; 114 | } 115 | 116 | return FixWrap(base + delta * progress); 117 | }; 118 | }; 119 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/NeoPixel/internal/NeoRingTopology.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /*------------------------------------------------------------------------- 4 | NeoRingTopology provides a mapping feature of a 2d polar cordinate to a 5 | linear 1d cordinate. 6 | It is used to map a series of concentric rings of NeoPixels to a index on 7 | the NeoPixelBus. 8 | 9 | Written by Michael C. Miller. 10 | 11 | I invest time and resources providing this open source code, 12 | please support me by dontating (see https://github.com/Makuna/NeoPixelBus) 13 | 14 | ------------------------------------------------------------------------- 15 | This file is part of the Makuna/NeoPixelBus library. 16 | 17 | NeoPixelBus is free software: you can redistribute it and/or modify 18 | it under the terms of the GNU Lesser General Public License as 19 | published by the Free Software Foundation, either version 3 of 20 | the License, or (at your option) any later version. 21 | 22 | NeoPixelBus is distributed in the hope that it will be useful, 23 | but WITHOUT ANY WARRANTY; without even the implied warranty of 24 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25 | GNU Lesser General Public License for more details. 26 | 27 | You should have received a copy of the GNU Lesser General Public 28 | License along with NeoPixel. If not, see 29 | . 30 | -------------------------------------------------------------------------*/ 31 | 32 | template class NeoRingTopology : protected T_LAYOUT 33 | { 34 | public: 35 | NeoRingTopology() 36 | { 37 | } 38 | 39 | uint16_t Map(uint8_t ring, uint16_t pixel) const 40 | { 41 | if (pixel >= getPixelCountAtRing(ring)) 42 | { 43 | return 0; // invalid ring and/or pixel argument, always return a valid value, the first one 44 | } 45 | 46 | return _map(ring, pixel); 47 | } 48 | 49 | uint16_t MapProbe(uint8_t ring, uint16_t pixel) const 50 | { 51 | if (pixel >= getPixelCountAtRing(ring)) 52 | { 53 | return getPixelCount(); // total count, out of bounds 54 | } 55 | 56 | return _map(ring, pixel); 57 | } 58 | 59 | uint16_t RingPixelShift(uint8_t ring, uint16_t pixel, int16_t shift) 60 | { 61 | int32_t ringPixel = pixel; 62 | ringPixel += shift; 63 | 64 | if (ringPixel < 0) 65 | { 66 | ringPixel = 0; 67 | } 68 | else 69 | { 70 | uint16_t count = getPixelCountAtRing(ring); 71 | if (ringPixel >= count) 72 | { 73 | ringPixel = count - 1; 74 | } 75 | } 76 | return ringPixel; 77 | } 78 | 79 | uint16_t RingPixelRotate(uint8_t ring, uint16_t pixel, int16_t rotate) 80 | { 81 | int32_t ringPixel = pixel; 82 | ringPixel += rotate; 83 | return ringPixel % getPixelCountAtRing(ring); 84 | } 85 | 86 | uint8_t getCountOfRings() const 87 | { 88 | return _ringCount() - 1; // minus one as the Rings includes the extra value 89 | } 90 | 91 | uint16_t getPixelCountAtRing(uint8_t ring) const 92 | { 93 | if (ring >= getCountOfRings()) 94 | { 95 | return 0; // invalid, no pixels 96 | } 97 | 98 | return T_LAYOUT::Rings[ring + 1] - T_LAYOUT::Rings[ring]; // using the extra value for count calc 99 | } 100 | 101 | uint16_t getPixelCount() const 102 | { 103 | return T_LAYOUT::Rings[_ringCount() - 1]; // the last entry is the total count 104 | } 105 | 106 | private: 107 | uint16_t _map(uint8_t ring, uint16_t pixel) const 108 | { 109 | return T_LAYOUT::Rings[ring] + pixel; 110 | } 111 | 112 | uint8_t _ringCount() const 113 | { 114 | return sizeof(T_LAYOUT::Rings) / sizeof(T_LAYOUT::Rings[0]); 115 | } 116 | }; 117 | -------------------------------------------------------------------------------- /ProDinoESP32_2/src/NeoPixel/internal/NeoTopology.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /*------------------------------------------------------------------------- 4 | NeoTopology provides a mapping feature of a 2d cordinate to linear 1d cordinate 5 | It is used to map a matrix of NeoPixels to a index on the NeoPixelBus 6 | 7 | Written by Michael C. Miller. 8 | 9 | I invest time and resources providing this open source code, 10 | please support me by dontating (see https://github.com/Makuna/NeoPixelBus) 11 | 12 | ------------------------------------------------------------------------- 13 | This file is part of the Makuna/NeoPixelBus library. 14 | 15 | NeoPixelBus is free software: you can redistribute it and/or modify 16 | it under the terms of the GNU Lesser General Public License as 17 | published by the Free Software Foundation, either version 3 of 18 | the License, or (at your option) any later version. 19 | 20 | NeoPixelBus is distributed in the hope that it will be useful, 21 | but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | GNU Lesser General Public License for more details. 24 | 25 | You should have received a copy of the GNU Lesser General Public 26 | License along with NeoPixel. If not, see 27 | . 28 | -------------------------------------------------------------------------*/ 29 | 30 | enum NeoTopologyHint 31 | { 32 | NeoTopologyHint_FirstOnPanel, 33 | NeoTopologyHint_InPanel, 34 | NeoTopologyHint_LastOnPanel, 35 | NeoTopologyHint_OutOfBounds 36 | }; 37 | 38 | template class NeoTopology 39 | { 40 | public: 41 | NeoTopology(uint16_t width, uint16_t height) : 42 | _width(width), 43 | _height(height) 44 | { 45 | 46 | } 47 | 48 | uint16_t Map(int16_t x, int16_t y) const 49 | { 50 | if (x >= _width) 51 | { 52 | x = _width - 1; 53 | } 54 | else if (x < 0) 55 | { 56 | x = 0; 57 | } 58 | if (y >= _height) 59 | { 60 | y = _height - 1; 61 | } 62 | else if (y < 0) 63 | { 64 | y = 0; 65 | } 66 | return T_LAYOUT::Map(_width, _height, x, y); 67 | } 68 | 69 | uint16_t MapProbe(int16_t x, int16_t y) const 70 | { 71 | if (x < 0 || x >= _width || y < 0 || y >= _height) 72 | { 73 | return _width * _height; // count, out of bounds 74 | } 75 | return T_LAYOUT::Map(_width, _height, x, y); 76 | } 77 | 78 | uint16_t getWidth() const 79 | { 80 | return _width; 81 | } 82 | 83 | uint16_t getHeight() const 84 | { 85 | return _height; 86 | } 87 | 88 | private: 89 | const uint16_t _width; 90 | const uint16_t _height; 91 | }; 92 | -------------------------------------------------------------------------------- /ProDinoMKRZero/releases/ProDinoMKRZero_1.0.0.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/ProDinoMKRZero/releases/ProDinoMKRZero_1.0.0.zip -------------------------------------------------------------------------------- /ProDinoMKRZero/releases/ProDinoMKRZero_1.0.1.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/ProDinoMKRZero/releases/ProDinoMKRZero_1.0.1.zip -------------------------------------------------------------------------------- /ProDinoMKRZero/releases/ProDinoMKRZero_1.0.4.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/ProDinoMKRZero/releases/ProDinoMKRZero_1.0.4.zip -------------------------------------------------------------------------------- /ProDinoMKRZero/releases/ProDinoMKRZero_1.0.5.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/ProDinoMKRZero/releases/ProDinoMKRZero_1.0.5.zip -------------------------------------------------------------------------------- /ProDinoMKRZero/releases/ProDinoMKRZero_1.0.6.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/ProDinoMKRZero/releases/ProDinoMKRZero_1.0.6.zip -------------------------------------------------------------------------------- /ProDinoMKRZero/releases/ProDinoMKRZero_1.0.7.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/ProDinoMKRZero/releases/ProDinoMKRZero_1.0.7.zip -------------------------------------------------------------------------------- /ProDinoMKRZero/releases/ProDinoMKRZero_1.0.8.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/ProDinoMKRZero/releases/ProDinoMKRZero_1.0.8.zip -------------------------------------------------------------------------------- /ProDinoMKRZero/releases/last/ProDinoMKRZero.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/ProDinoMKRZero/releases/last/ProDinoMKRZero.zip -------------------------------------------------------------------------------- /ProDinoMKRZero/src/ProDinoMKRZero/examples/GPRSUdpNtpTest/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | #define SECRET_PINNUMBER "" 2 | #define SECRET_GPRS_APN "" // replace your GPRS APN 3 | #define SECRET_GPRS_LOGIN "" // replace with your GPRS login 4 | #define SECRET_GPRS_PASSWORD "" // replace with your GPRS password 5 | -------------------------------------------------------------------------------- /ProDinoMKRZero/src/ProDinoMKRZero/examples/RS485Echo/RS485Echo.ino: -------------------------------------------------------------------------------- 1 | // RS485Echo.ino 2 | // Company: KMP Electronics Ltd, Bulgaria 3 | // Web: https://kmpelectronics.eu/ 4 | // Supported boards: 5 | // All KMP ProDino MKR Zero series (https://kmpelectronics.eu/product-category/arduino-mkr-zero/) 6 | // Description: 7 | // RS485 echo example. It works as received data stored in a buffer and transmit it back. 8 | // Example link: https://kmpelectronics.eu/tutorials-examples/prodino-mkr-versions-examples/ 9 | // Version: 1.0.0 10 | // Date: 11.09.2018 11 | // Author: Plamen Kovandjiev 12 | 13 | #include "KMPProDinoMKRZero.h" 14 | #include "KMPCommon.h" 15 | 16 | // If in debug mode - print debug information in Serial. Comment in production code, this bring performance. 17 | // This method is good for development and verification of results. But increases the amount of code and decreases productivity. 18 | #define DEBUG 19 | 20 | const uint8_t BUFF_MAX = 255; 21 | 22 | uint8_t _dataBuffer[BUFF_MAX]; 23 | 24 | /** 25 | * @brief Setup void. Ii is Arduino executed first. Initialize DiNo board. 26 | * 27 | * 28 | * @return void 29 | */ 30 | void setup() 31 | { 32 | delay(5000); 33 | #ifdef DEBUG 34 | Serial.begin(115200); 35 | #endif 36 | 37 | // Init Dino board. Set pins, start W5500. 38 | KMPProDinoMKRZero.init(ProDino_MKR_Zero); 39 | // Start RS485 with bound 19200 and 8N1. 40 | KMPProDinoMKRZero.RS485Begin(19200); 41 | 42 | #ifdef DEBUG 43 | Serial.println("The example RS485Echo is started."); 44 | #endif 45 | } 46 | 47 | /** 48 | * @brief Loop void. Arduino executed second. 49 | * 50 | * 51 | * @return void 52 | */ 53 | void loop() { 54 | // Waiting for a data. 55 | int i = KMPProDinoMKRZero.RS485Read(); 56 | 57 | if (i == -1) 58 | { 59 | return; 60 | } 61 | 62 | #ifdef DEBUG 63 | Serial.println("Receiving data..."); 64 | #endif 65 | 66 | // If in RS485 port has any data - Status led is ON 67 | KMPProDinoMKRZero.OnStatusLed(); 68 | 69 | uint8_t buffPos = 0; 70 | 71 | // Reading data from the RS485 port. 72 | while (i > -1 && buffPos < BUFF_MAX) 73 | { 74 | // Adding received data in a buffer. 75 | _dataBuffer[buffPos++] = i; 76 | #ifdef DEBUG 77 | Serial.write((char)i); 78 | #endif 79 | // Reading a next char. 80 | i = KMPProDinoMKRZero.RS485Read(); 81 | } 82 | 83 | // All data has been read. Off status led. 84 | KMPProDinoMKRZero.OffStatusLed(); 85 | 86 | #ifdef DEBUG 87 | Serial.println(); 88 | Serial.println("Transmit received data."); 89 | #endif 90 | 91 | KMPProDinoMKRZero.RS485Write(_dataBuffer, buffPos); 92 | } -------------------------------------------------------------------------------- /ProDinoMKRZero/src/ProDinoMKRZero/examples/RS485Input/RS485Input.ino: -------------------------------------------------------------------------------- 1 | // RS485Input.ino 2 | // Company: KMP Electronics Ltd, Bulgaria 3 | // Web: https://kmpelectronics.eu/ 4 | // Supported boards: 5 | // All KMP ProDino MKR Zero series (https://kmpelectronics.eu/product-category/arduino-mkr-zero/) 6 | // Description: 7 | // RS485 reads isolated input example. It works as receive a command and execute it. 8 | // Command: 9 | // FFI - sending current inputs statuses 10 | // Example link: https://kmpelectronics.eu/tutorials-examples/prodino-mkr-versions-examples/ 11 | // Version: 1.0.0 12 | // Date: 17.09.2018 13 | // Author: Plamen Kovandjiev 14 | 15 | #include "KMPProDinoMKRZero.h" 16 | #include "KMPCommon.h" 17 | 18 | // If in debug mode - print debug information in Serial. Comment in production code, this bring performance. 19 | // This method is good for development and verification of results. But increases the amount of code and decreases productivity. 20 | #define DEBUG 21 | 22 | 23 | const int CMD_PREFFIX_LEN = 3; 24 | const char CMD_PREFFIX[CMD_PREFFIX_LEN + 1] = "FFI"; 25 | 26 | const uint8_t BUFF_MAX = 16; 27 | 28 | char _dataBuffer[BUFF_MAX]; 29 | char _resultBuffer[BUFF_MAX]; 30 | 31 | /** 32 | * @brief Setup void. Ii is Arduino executed first. Initialize DiNo board. 33 | * 34 | * 35 | * @return void 36 | */ 37 | void setup() 38 | { 39 | delay(5000); 40 | #ifdef DEBUG 41 | Serial.begin(115200); 42 | #endif 43 | 44 | // Init Dino board. Set pins, start W5500. 45 | KMPProDinoMKRZero.init(ProDino_MKR_Zero); 46 | // Start RS485 with bound 19200 and 8N1. 47 | KMPProDinoMKRZero.RS485Begin(19200); 48 | 49 | #ifdef DEBUG 50 | Serial.println("The example RS485Input is started."); 51 | #endif 52 | } 53 | 54 | /** 55 | * @brief Loop void. Arduino executed second. 56 | * 57 | * 58 | * @return void 59 | */ 60 | void loop() { 61 | // Waiting for a data. 62 | int i = KMPProDinoMKRZero.RS485Read(); 63 | 64 | if (i == -1) 65 | { 66 | return; 67 | } 68 | 69 | #ifdef DEBUG 70 | Serial.println("Receiving data..."); 71 | #endif 72 | 73 | // If in RS485 port has any data - Status led is ON 74 | KMPProDinoMKRZero.OnStatusLed(); 75 | 76 | uint8_t buffPos = 0; 77 | 78 | // Reading data from the RS485 port. 79 | while (i > -1 && buffPos < BUFF_MAX) 80 | { 81 | // Adding received data in a buffer. 82 | _dataBuffer[buffPos++] = (char)i; 83 | #ifdef DEBUG 84 | Serial.write((char)i); 85 | #endif 86 | // Reading a next char. 87 | i = KMPProDinoMKRZero.RS485Read(); 88 | } 89 | 90 | _dataBuffer[buffPos] = CH_NONE; 91 | 92 | #ifdef DEBUG 93 | Serial.println(); 94 | #endif 95 | 96 | // All data has been read. Off status led. 97 | KMPProDinoMKRZero.OffStatusLed(); 98 | 99 | ProcessData(); 100 | } 101 | 102 | void ProcessData() 103 | { 104 | int len = strlen(_dataBuffer); 105 | 106 | // Validate input data. 107 | if (len < CMD_PREFFIX_LEN || !startsWith(_dataBuffer, CMD_PREFFIX)) 108 | { 109 | #ifdef DEBUG 110 | Serial.print("Command is not valid."); 111 | #endif 112 | 113 | return; 114 | } 115 | 116 | // Prepare Inputs statuses. 117 | strcpy(_resultBuffer, CMD_PREFFIX); 118 | int inputState = 0; 119 | for (int j = CMD_PREFFIX_LEN; j < CMD_PREFFIX_LEN + OPTOIN_COUNT; j++) 120 | { 121 | _resultBuffer[j] = KMPProDinoMKRZero.GetOptoInState(inputState++) ? CH_1 : CH_0; 122 | } 123 | 124 | _resultBuffer[CMD_PREFFIX_LEN + OPTOIN_COUNT] = CH_NONE; 125 | 126 | #ifdef DEBUG 127 | Serial.println("Transmiting isolated inputs statuses..."); 128 | Serial.println(_resultBuffer); 129 | #endif 130 | 131 | // Transmit result. 132 | KMPProDinoMKRZero.RS485Write(_resultBuffer); 133 | } -------------------------------------------------------------------------------- /ProDinoMKRZero/src/ProDinoMKRZero/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For ProDinoMKRZero 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | KMPProDinoMKRZero KEYWORD1 10 | KMPCommon KEYWORD1 11 | 12 | ####################################### 13 | # Methods and Functions (KEYWORD2) 14 | ####################################### 15 | 16 | begin KEYWORD2 17 | handleClient KEYWORD2 18 | on KEYWORD2 19 | addHandler KEYWORD2 20 | uri KEYWORD2 21 | method KEYWORD2 22 | client KEYWORD2 23 | send KEYWORD2 24 | arg KEYWORD2 25 | argName KEYWORD2 26 | args KEYWORD2 27 | hasArg KEYWORD2 28 | onNotFound KEYWORD2 29 | 30 | ####################################### 31 | # Constants (LITERAL1) 32 | ####################################### 33 | 34 | HTTP_GET LITERAL1 35 | HTTP_POST LITERAL1 36 | HTTP_ANY LITERAL1 37 | -------------------------------------------------------------------------------- /ProDinoMKRZero/src/ProDinoMKRZero/library.properties: -------------------------------------------------------------------------------- 1 | name=ProDino_MKRZero 2 | version=1.0.8 3 | author=KMP Electronics Ltd, Plamen Kovandjiev 4 | maintainer=Plamen Kovandjiev, 5 | sentence=Examples by our board KMP ProDino MKR Zero series. 6 | paragraph=This library includes examples for the KMP ProDino MKR Zero series boards. 7 | category=Communication 8 | url=https://kmpelectronics.eu/tutorials-examples/prodino-mkr-versions-examples/ 9 | architectures=samd -------------------------------------------------------------------------------- /ProDinoMKRZero/src/ProDinoMKRZero/src/MqttTopicHelper.h: -------------------------------------------------------------------------------- 1 | // MqttTopicHelper.h 2 | 3 | #ifndef _MQTTTOPICHELPER_h 4 | #define _MQTTTOPICHELPER_h 5 | 6 | #if defined(ARDUINO) && ARDUINO >= 100 7 | #include "Arduino.h" 8 | #else 9 | #include "WProgram.h" 10 | #endif 11 | 12 | const char TOPIC_SEPARATOR = '/'; 13 | const uint16_t MAIN_TOPIC_MAXLEN = 64; 14 | const char ISREADY_TOPIC[] = "isready"; 15 | const char SET_TOPIC[] = "/set"; 16 | 17 | class MqttTopicHelperClass 18 | { 19 | public: 20 | void init(const char* baseTopic, const char* deviceTopic, Print* debugPort = NULL); 21 | void printTopicAndPayload(const char* topic, const byte* payload, unsigned int length); 22 | void printTopicAndPayload(const char* topic, const char* payload); 23 | void addCharToStr(char* str, const char chr); 24 | void addTopicSeparator(char* str); 25 | void appendTopic(char * topic, const char * nextTopic); 26 | const char* getMainTopic(); 27 | const char* getIsReadyTopic(); 28 | bool startsWithMainTopic(const char* str); 29 | void buildTopicWithMT(char * str, int num, ...); 30 | void buildTopic(char* str, int num, ...); 31 | bool isBaseTopic(char* topic); 32 | bool isMainTopic(char* topic); 33 | bool isReadyTopic(char* topic); 34 | bool getNextTopic(const char* topics, char* nextTopic, char** otherTopics, bool skipMainTopic = false); 35 | bool isTopicSet(const char* topics); 36 | protected: 37 | bool isOnlyThisTopic(const char* topic1, const char* topic2); 38 | }; 39 | 40 | extern MqttTopicHelperClass MqttTopicHelper; 41 | 42 | #endif 43 | 44 | -------------------------------------------------------------------------------- /ProDinoWiFiEsp/ProDinoWiFiArduinoSettings.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/ProDinoWiFiEsp/ProDinoWiFiArduinoSettings.PNG -------------------------------------------------------------------------------- /ProDinoWiFiEsp/README.md: -------------------------------------------------------------------------------- 1 | PRODINo_WiFi-ESP_WROOM-02 library 2 | =============== 3 | This library support PRODINo WiFi-ESP WROOM-02 board. 4 | For more information see here: http://kmpelectronics.eu/en-us/examples/prodinowifi-esp.aspx 5 | -------------------------------------------------------------------------------- /ProDinoWiFiEsp/releases/PRODINoESP8266_1.0.0.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/ProDinoWiFiEsp/releases/PRODINoESP8266_1.0.0.zip -------------------------------------------------------------------------------- /ProDinoWiFiEsp/releases/PRODINoESP8266_1.0.2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/ProDinoWiFiEsp/releases/PRODINoESP8266_1.0.2.zip -------------------------------------------------------------------------------- /ProDinoWiFiEsp/releases/PRODINoESP8266_2.0.0.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/ProDinoWiFiEsp/releases/PRODINoESP8266_2.0.0.zip -------------------------------------------------------------------------------- /ProDinoWiFiEsp/releases/PRODINoESP8266_2.0.1.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/ProDinoWiFiEsp/releases/PRODINoESP8266_2.0.1.zip -------------------------------------------------------------------------------- /ProDinoWiFiEsp/releases/PRODINoESP8266_2.2.0.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/ProDinoWiFiEsp/releases/PRODINoESP8266_2.2.0.zip -------------------------------------------------------------------------------- /ProDinoWiFiEsp/releases/last/PRODINoESP8266.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmpelectronics/Arduino/e8a2908ed095dff93221eae5d3553991b7505aea/ProDinoWiFiEsp/releases/last/PRODINoESP8266.zip -------------------------------------------------------------------------------- /ProDinoWiFiEsp/src/PRODINoESP8266/examples/Inputs1/Inputs1.ino: -------------------------------------------------------------------------------- 1 | // Inputs1.ino 2 | // Company: KMP Electronics Ltd, Bulgaria 3 | // Web: https://kmpelectronics.eu/ 4 | // Supported boards: 5 | // KMP PRODINo WIFI-ESP WROOM-02 https://kmpelectronics.eu/products/prodino-wifi-esp-wroom-02-v1/ 6 | // Description: 7 | // Test inputs. When we add power to the some input the example switch on the same relay. 8 | // Example link: https://kmpelectronics.eu/tutorials-examples/prodino-wifi-examples/ 9 | // Version: 1.0.0 10 | // Date: 26.01.2021 11 | // Author: Plamen Kovandjiev 12 | // -------------------------------------------------------------------------------- 13 | // Prerequisites: 14 | // Nothing 15 | 16 | #include 17 | 18 | void setup() 19 | { 20 | delay(5000); 21 | Serial.begin(115200); 22 | Serial.println("Inputs1 example is starting..."); 23 | 24 | // Init Dino board. 25 | KMPDinoWiFiESP.init(); 26 | } 27 | 28 | void loop() 29 | { 30 | for (size_t i = 0; i < OPTOIN_COUNT; i++) 31 | { 32 | // We read input state KMPDinoWiFiESP.GetOptoInState(i) and set relay with input state. 33 | KMPDinoWiFiESP.SetRelayState(i, KMPDinoWiFiESP.GetOptoInState(i)); 34 | } 35 | } -------------------------------------------------------------------------------- /ProDinoWiFiEsp/src/PRODINoESP8266/examples/WiFiBlynk/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | // You have to get your Authentication Token through Blynk Application. 2 | #define AUTH_TOKEN "" 3 | 4 | // Your WiFi credentials 5 | #define SSID_NAME "" 6 | #define SSID_PASSWORD "" -------------------------------------------------------------------------------- /ProDinoWiFiEsp/src/PRODINoESP8266/examples/WiFiCloudMqtt/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | // WiFi settings 2 | #define SSID "" 3 | #define SSID_PASSWORD "" 4 | 5 | // MQTT server settings. 6 | #define MQTT_SERVER "xxx.cloudmqtt.com" // Change it with yours data. 7 | #define MQTT_PORT 12345 // Change it with yours data. 8 | #define MQTT_USER "" // Change it with yours data. 9 | #define MQTT_PASS "" // Change it with yours data. -------------------------------------------------------------------------------- /ProDinoWiFiEsp/src/PRODINoESP8266/examples/WiFiWeb1WireSrv/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | // Your WiFi credentials 2 | #define SSID_NAME "" 3 | #define SSID_PASSWORD "" -------------------------------------------------------------------------------- /ProDinoWiFiEsp/src/PRODINoESP8266/examples/WiFiWebDHTSrv/WiFiWebDHTSrv.ino: -------------------------------------------------------------------------------- 1 | // WiFiWebDHTSrv.ino 2 | // Company: KMP Electronics Ltd, Bulgaria 3 | // Web: https://kmpelectronics.eu/ 4 | // Supported boards: 5 | // KMP PRODINo WIFI-ESP WROOM-02 https://kmpelectronics.eu/products/prodino-wifi-esp-wroom-02-v1/ 6 | // Description: 7 | // Web server example with DHT sensor. 8 | // Example link: http://www.kmpelectronics.eu/en-us/examples/prodinowifi-esp/wifiwebdhtserver.aspx 9 | // Version: 1.1.0 10 | // Date: 02.02.2021 11 | // Author: Plamen Kovandjiev 12 | // -------------------------------------------------------------------------------- 13 | // Prerequisites: 14 | // You have to fill your credentials in arduino_secrets.h file 15 | // Before start this example you need to install DHT library: https://github.com/adafruit/DHT-sensor-library 16 | // Connect DHT22 sensor to External GROVE connector. Use pins: 17 | // - first sensor EXT_GROVE_D0, Vcc+, Gnd(-); 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include "arduino_secrets.h" 26 | 27 | DHT _dht(EXT_GROVE_D0, DHT22, 11); 28 | 29 | ESP8266WebServer _server(80); 30 | 31 | /** 32 | * @brief Execute first after start device. Initialize hardware. 33 | * 34 | * @return void 35 | */ 36 | void setup(void) 37 | { 38 | // You can open the Arduino IDE Serial Monitor window to see what the code is doing 39 | // Serial connection from ESP-01 via 3.3v console cable 40 | Serial.begin(115200); 41 | 42 | // Init KMP ProDino WiFi-ESP board. 43 | KMPDinoWiFiESP.init(); 44 | 45 | // Connect to WiFi network 46 | WiFi.begin(SSID_NAME, SSID_PASSWORD); 47 | Serial.print("\n\r \n\rWorking to connect"); 48 | 49 | // Wait for connection 50 | while (WiFi.status() != WL_CONNECTED) { 51 | delay(500); 52 | Serial.print("."); 53 | } 54 | Serial.println(""); 55 | Serial.println("KMP DHT Server"); 56 | Serial.print("Connected to "); 57 | Serial.println(SSID_NAME); 58 | Serial.print("IP address: "); 59 | Serial.println(WiFi.localIP()); 60 | 61 | _server.on("/", HandleRootPage); 62 | _server.begin(); 63 | 64 | _dht.begin(); 65 | } 66 | 67 | /** 68 | * @brief Main method. 69 | * 70 | * @return void 71 | */ 72 | void loop(void) 73 | { 74 | _server.handleClient(); 75 | } 76 | 77 | /** 78 | * @brief Handle root page "/". 79 | * 80 | * @return void 81 | */ 82 | void HandleRootPage() 83 | { 84 | //KMPDinoWiFiESP.LedOn(); 85 | 86 | _server.send(200, TEXT_HTML, BuildPage()); 87 | 88 | //KMPDinoWiFiESP.LedOff(); 89 | } 90 | 91 | /** 92 | * @brief Build HTML page. 93 | * 94 | * @return void 95 | */ 96 | String BuildPage() 97 | { 98 | String page = 99 | "" + String(KMP_ELECTRONICS_LTD) + " " + String(PRODINO_WIFI) + " - Web DHT" 100 | + "
" 101 | + "

" 102 | + "

" + String(PRODINO_WIFI) + " - Web DHT example

" 103 | + "


" 104 | + "" 105 | + ""; 106 | 107 | // Add table rows, relay information. 108 | String tableBody = ""; 109 | // Row i, cell 1 110 | _dht.read(true); 111 | _dht.readHumidity(); 112 | _dht.readTemperature(); 113 | 114 | tableBody += ""; 115 | 116 | // Cell i,2 117 | tableBody += ""; 118 | 119 | // Cell i,3 120 | tableBody += ""; 121 | 122 | tableBody += ""; 123 | 124 | return page + tableBody 125 | + "
Temperature C°Humidity
" + String(_dht.readTemperature()) + "" + String(_dht.readTemperature()) + "



Visit " + String(KMP_ELECTRONICS_LTD) + "

" 126 | + "

Information about " + String(PRODINO_WIFI) + " board

" 127 | + "
"; 128 | } -------------------------------------------------------------------------------- /ProDinoWiFiEsp/src/PRODINoESP8266/examples/WiFiWebDHTSrv/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | // Your WiFi credentials 2 | #define SSID_NAME "" 3 | #define SSID_PASSWORD "" -------------------------------------------------------------------------------- /ProDinoWiFiEsp/src/PRODINoESP8266/examples/WiFiWebOptoInSrv/WiFiWebOptoInSrv.ino: -------------------------------------------------------------------------------- 1 | // WiFiWebOptoInSrv.ino 2 | // Company: KMP Electronics Ltd, Bulgaria 3 | // Web: https://kmpelectronics.eu/ 4 | // Supported boards: 5 | // KMP PRODINo WIFI-ESP WROOM-02 https://kmpelectronics.eu/products/prodino-wifi-esp-wroom-02-v1/ 6 | // Description: 7 | // Web server example present how we can work with Opto inputs. 8 | // Example link: http://www.kmpelectronics.eu/en-us/examples/prodinowifi-esp/wifiwebdhtserver.aspx 9 | // Version: 1.1.0 10 | // Date: 02.02.2021 11 | // Author: Plamen Kovandjiev 12 | // -------------------------------------------------------------------------------- 13 | // Prerequisites: 14 | // You have to fill your credentials in arduino_secrets.h file 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include "arduino_secrets.h" 22 | 23 | ESP8266WebServer _server(80); 24 | 25 | const char GREEN[] = "#90EE90"; // LightGreen 26 | const char RED[] = "#FF4500"; // OrangeRed 27 | 28 | /** 29 | * @brief Execute first after start device. Initialize hardware. 30 | * 31 | * @return void 32 | */ 33 | void setup(void) 34 | { 35 | // You can open the Arduino IDE Serial Monitor window to see what the code is doing 36 | // Serial connection from ESP-01 via 3.3v console cable 37 | Serial.begin(115200); 38 | // Init KMP Dino WiFi board. 39 | KMPDinoWiFiESP.init(); 40 | 41 | WiFi.mode(WIFI_STA); 42 | 43 | // Connect to WiFi network 44 | WiFi.begin(SSID_NAME, SSID_PASSWORD); 45 | Serial.print("\n\r \n\rWorking to connect"); 46 | 47 | // Wait for connection 48 | while (WiFi.status() != WL_CONNECTED) { 49 | delay(500); 50 | Serial.print("."); 51 | } 52 | Serial.println(""); 53 | Serial.println("KMP Relay Server"); 54 | Serial.print("Connected to "); 55 | Serial.println(SSID_NAME); 56 | Serial.print("IP address: "); 57 | Serial.println(WiFi.localIP()); 58 | 59 | _server.on("/", HandleRootPage); 60 | _server.begin(); 61 | } 62 | 63 | /** 64 | * @brief Main method. 65 | * 66 | * @return void 67 | */ 68 | void loop(void) 69 | { 70 | _server.handleClient(); 71 | } 72 | 73 | /** 74 | * @brief Handle root page "/". 75 | * 76 | * @return void 77 | */ 78 | void HandleRootPage() 79 | { 80 | _server.send(200, TEXT_HTML, BuildPage()); 81 | } 82 | 83 | /** 84 | * @brief Build HTML page. 85 | * 86 | * @return void 87 | */ 88 | String BuildPage() 89 | { 90 | String page = 91 | "" + String(KMP_ELECTRONICS_LTD) + " " + String(PRODINO_WIFI) + " - Opto inputs" 92 | + "
" 93 | + "

" 94 | + "

" + String(PRODINO_WIFI) + " - Opto inputs example

" 95 | + "


" 96 | + ""; 97 | 98 | String tableBody = ""; 99 | String tableHeader = ""; 100 | for (uint8_t i = 0; i < OPTOIN_COUNT; i++) 101 | { 102 | String optoInNumber = String(i + 1); 103 | tableHeader += ""; 104 | 105 | char* cellColor; 106 | char* cellStatus; 107 | if (KMPDinoWiFiESP.GetOptoInState(i)) 108 | { 109 | cellColor = (char*)RED; 110 | cellStatus = (char*)W_ON; 111 | } 112 | else 113 | { 114 | cellColor = (char*)GREEN; 115 | cellStatus = (char*)W_OFF; 116 | } 117 | 118 | tableBody += ""; 119 | } 120 | 121 | tableHeader += ""; 122 | tableBody += ""; 123 | 124 | return page + tableHeader + tableBody + 125 | + "
In " + optoInNumber + "" + String(cellStatus) + "



Visit " + String(KMP_ELECTRONICS_LTD) + "

" 126 | + "

Information about " + String(PRODINO_WIFI) + " board

" 127 | + "
"; 128 | } -------------------------------------------------------------------------------- /ProDinoWiFiEsp/src/PRODINoESP8266/examples/WiFiWebOptoInSrv/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | // Your WiFi credentials 2 | #define SSID_NAME "" 3 | #define SSID_PASSWORD "" -------------------------------------------------------------------------------- /ProDinoWiFiEsp/src/PRODINoESP8266/examples/WiFiWebRS485/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | // Your WiFi credentials 2 | #define SSID_NAME "" 3 | #define SSID_PASSWORD "" -------------------------------------------------------------------------------- /ProDinoWiFiEsp/src/PRODINoESP8266/examples/WiFiWebRelaySrv/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | // Your WiFi credentials 2 | #define SSID_NAME "" 3 | #define SSID_PASSWORD "" -------------------------------------------------------------------------------- /ProDinoWiFiEsp/src/PRODINoESP8266/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For DiNoWiFi 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | KMPDinoWiFiESP KEYWORD1 10 | KMPCommon KEYWORD1 11 | 12 | ####################################### 13 | # Methods and Functions (KEYWORD2) 14 | ####################################### 15 | 16 | begin KEYWORD2 17 | handleClient KEYWORD2 18 | on KEYWORD2 19 | addHandler KEYWORD2 20 | uri KEYWORD2 21 | method KEYWORD2 22 | client KEYWORD2 23 | send KEYWORD2 24 | arg KEYWORD2 25 | argName KEYWORD2 26 | args KEYWORD2 27 | hasArg KEYWORD2 28 | onNotFound KEYWORD2 29 | 30 | ####################################### 31 | # Constants (LITERAL1) 32 | ####################################### 33 | 34 | HTTP_GET LITERAL1 35 | HTTP_POST LITERAL1 36 | HTTP_ANY LITERAL1 37 | -------------------------------------------------------------------------------- /ProDinoWiFiEsp/src/PRODINoESP8266/library.properties: -------------------------------------------------------------------------------- 1 | name=PRODINo_WiFi-ESP_WROOM-02 2 | version=2.2.0 3 | author=KMP Electronics Ltd, Plamen Kovandjiev 4 | maintainer=Plamen Kovandjiev, 5 | sentence=Examples for board PRODINo WiFi-ESP WROOM-02 V1.0. 6 | paragraph=This library implements specific examples for the board. 7 | category=Communication 8 | url=http://kmpelectronics.eu/en-us/products/dinowifiesp.aspx 9 | architectures=esp8266 10 | -------------------------------------------------------------------------------- /ProDinoWiFiEsp/src/PRODINoESP8266/src/KMPDinoWiFiESP.h: -------------------------------------------------------------------------------- 1 | // KMPDinoWiFiESP.h 2 | // Company: KMP Electronics Ltd, Bulgaria 3 | // Web: http://kmpelectronics.eu/ 4 | // Supported boards: 5 | // KMP ProDino WiFi-ESP WROOM-02 (http://www.kmpelectronics.eu/en-us/products/prodinowifi-esp.aspx) 6 | // Description: 7 | // Header for KMP Dino WiFi board. 8 | // Version: 1.0.0 9 | // Date: 30.04.2016 10 | // Authors: Plamen Kovandjiev & Dimitar Antonov 11 | 12 | #ifndef _KMPDINOWIFIESP_H 13 | #define _KMPDINOWIFIESP_H 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | // Inputs and outputs count. 20 | #define RELAY_COUNT 4 21 | #define OPTOIN_COUNT 4 22 | 23 | /** 24 | * @brief External Grove connector, D0 pin GPIO5/SCL. 25 | * @inf The pin 5 is same for EXT_GROVE_D0 and INT_GROVE_D1. 26 | */ 27 | #define EXT_GROVE_D0 5 28 | 29 | /** 30 | * @brief External Grove connector, D1 pin GPIO4/SDA. 31 | */ 32 | #define EXT_GROVE_D1 4 33 | 34 | /** 35 | * @brief Internal Grove connector, A0 pin ADC. 36 | */ 37 | #define INT_GROVE_A0 A0 38 | 39 | /** 40 | * @brief Internal Grove connector, D1 pin GPIO5/SCL. 41 | * @inf The pin 5 is same for EXT_GROVE_D0 and INT_GROVE_D1. 42 | */ 43 | #define INT_GROVE_D1 5 44 | 45 | /** 46 | * @brief Relays. 47 | */ 48 | enum Relay { 49 | Relay1 = 0x00, 50 | Relay2 = 0x01, 51 | Relay3 = 0x02, 52 | Relay4 = 0x03 53 | }; 54 | 55 | /** 56 | * @brief Inputs. 57 | */ 58 | enum OptoIn { 59 | OptoIn1 = 0x00, 60 | OptoIn2 = 0x01, 61 | OptoIn3 = 0x02, 62 | OptoIn4 = 0x03 63 | }; 64 | 65 | const char TEXT_HTML[] = "text/html; charset=utf-8"; 66 | const char PRODINO_WIFI[] = "ProDino WiFi-ESP"; 67 | const char URL_KMPELECTRONICS_EU_DINO_WIFI[] = "https://kmpelectronics.eu/tutorials-examples/prodino-wifi-examples/"; 68 | 69 | class KMPDinoWiFiESPClass 70 | { 71 | protected: 72 | void ExpanderSetPin(uint8_t pinNumber, bool state); 73 | bool ExpanderGetPin(uint8_t pinNumber); 74 | uint8_t ExpanderReadRegister(uint8_t address); 75 | void ExpanderWriteRegister(uint8_t address, uint8_t data); 76 | void ExpanderSetDirection(uint8_t pinNumber, uint8_t mode); 77 | void ExpanderInitGPIO(); 78 | 79 | public: 80 | void init(); 81 | 82 | void SetRelayState(uint8_t relayNumber, bool state); 83 | void SetRelayState(Relay relay, bool state); 84 | void SetAllRelaysState(bool state); 85 | void SetAllRelaysOn(); 86 | void SetAllRelaysOff(); 87 | bool GetRelayState(uint8_t relayNumber); 88 | bool GetRelayState(Relay relay); 89 | 90 | bool GetOptoInState(uint8_t optoInNumber); 91 | bool GetOptoInState(OptoIn optoIn); 92 | 93 | void RS485Begin(unsigned long baud); 94 | void RS485Begin(unsigned long baud, SerialConfig config); 95 | void RS485End(); 96 | size_t RS485Write(uint8_t data); 97 | size_t RS485Write(char data); 98 | size_t RS485Write(const char* data); 99 | size_t RS485Write(String data) { return RS485Write(data.c_str()); } 100 | size_t RS485Write(uint8_t* data, uint8_t dataLen); 101 | int RS485Read(); 102 | int RS485Read(unsigned long delayWait, uint8_t repeatTime); 103 | }; 104 | 105 | extern KMPDinoWiFiESPClass KMPDinoWiFiESP; 106 | 107 | #endif -------------------------------------------------------------------------------- /ProDinoWiFiEsp/src/PRODINoESP8266/src/MqttTopicHelper.h: -------------------------------------------------------------------------------- 1 | // MqttTopicHelper.h 2 | 3 | #ifndef _MQTTTOPICHELPER_h 4 | #define _MQTTTOPICHELPER_h 5 | 6 | #if defined(ARDUINO) && ARDUINO >= 100 7 | #include "Arduino.h" 8 | #else 9 | #include "WProgram.h" 10 | #endif 11 | 12 | const char TOPIC_SEPARATOR = '/'; 13 | const uint16_t MAIN_TOPIC_MAXLEN = 64; 14 | const char ISREADY_TOPIC[] = "isready"; 15 | const char SET_TOPIC[] = "/set"; 16 | 17 | class MqttTopicHelperClass 18 | { 19 | public: 20 | void init(const char* baseTopic, const char* deviceTopic, Print* debugPort = NULL); 21 | void printTopicAndPayload(const char* topic, const byte* payload, unsigned int length); 22 | void printTopicAndPayload(const char* topic, const char* payload); 23 | void addCharToStr(char* str, const char chr); 24 | void addTopicSeparator(char* str); 25 | void appendTopic(char * topic, const char * nextTopic); 26 | const char* getMainTopic(); 27 | const char* getIsReadyTopic(); 28 | bool startsWithMainTopic(const char* str); 29 | void buildTopicWithMT(char * str, int num, ...); 30 | void buildTopic(char* str, int num, ...); 31 | bool isBaseTopic(char* topic); 32 | bool isMainTopic(char* topic); 33 | bool isReadyTopic(char* topic); 34 | bool getNextTopic(const char* topics, char* nextTopic, char** otherTopics, bool skipMainTopic = false); 35 | bool isTopicSet(const char* topics); 36 | protected: 37 | bool isOnlyThisTopic(const char* topic1, const char* topic2); 38 | }; 39 | 40 | extern MqttTopicHelperClass MqttTopicHelper; 41 | 42 | #endif 43 | 44 | --------------------------------------------------------------------------------