diff --git a/docs/p2.md b/docs/p2.md index d4a05dcf..4a044445 100644 --- a/docs/p2.md +++ b/docs/p2.md @@ -211,6 +211,7 @@ by Dave Hein ## Recent Activity ##### _Full details [here](https://github.com/parallaxinc/propeller/pulls?q=is%3Aclosed)._ +* Added Mike Calyer's [Cricket ESP32 AT](https://github.com/parallaxinc/propeller/tree/master/libraries/community/p2/All/cricket_esp32_at) objects * Added MagIO2's [Graphics Display Driver Arch](https://github.com/parallaxinc/propeller/tree/master/libraries/community/p2/All/GraphicsDisplayDriverArch) * Added Eric R Smith's object [BinFloat](https://github.com/parallaxinc/propeller/tree/master/libraries/community/p2/All/BinFloat) * Added Greg LaPolla's P2 [MAX7219 Dot Matrix Master](https://github.com/parallaxinc/propeller/tree/master/libraries/community/p2/All/max7219-dot-matrix-master) object diff --git a/libraries/community/p2/All/cricket_esp32_at/.gitattributes b/libraries/community/p2/All/cricket_esp32_at/.gitattributes new file mode 100644 index 00000000..89b7777f --- /dev/null +++ b/libraries/community/p2/All/cricket_esp32_at/.gitattributes @@ -0,0 +1,2 @@ +demo_32_Voltage_Meters.png filter=lfs diff=lfs merge=lfs -text +demo_led_control.png filter=lfs diff=lfs merge=lfs -text diff --git a/libraries/community/p2/All/cricket_esp32_at/README.md b/libraries/community/p2/All/cricket_esp32_at/README.md new file mode 100644 index 00000000..7ba3e9b2 --- /dev/null +++ b/libraries/community/p2/All/cricket_esp32_at/README.md @@ -0,0 +1,19 @@ +# Cricket ESP32 AT + +By: mike calyer + +Language: Spin2 + +Created: 20-JUN-2021 + +Category: protocol + +Description: +Provides P2 to ESP32 AT Interface (esp_drv, esp_wifi, esp_tcp, esp_logon) + +Also : get_info.spin2 : gets esp32 firmware version + webserver : esp_webserver.spin2 + demo webserver : 32 Voltage Monitor with analog meters - demo_meter32.spin2, see picture demo_32 Voltage_Meters.png + demo webserver : Led Control - demo led_control.spin2, see picture demo_led_control.png + +License: MIT (see end of source code) diff --git a/libraries/community/p2/All/cricket_esp32_at/com_dat_fullduplexserial.spin2 b/libraries/community/p2/All/cricket_esp32_at/com_dat_fullduplexserial.spin2 new file mode 100644 index 00000000..78f82b46 --- /dev/null +++ b/libraries/community/p2/All/cricket_esp32_at/com_dat_fullduplexserial.spin2 @@ -0,0 +1,345 @@ +'' ================================================================================================= +'' +'' File....... dat_fullduplexserial.spin2 +'' Purpose.... Buffered serial communications using smart pins +'' -- mostly matches FullDuplexSerial from P1 +'' -- does NOT support half-duplex communications using shared RX/TX pin +'' Authors.... Riley August +'' -- modified version of John MacPhalen's Full Duplex Serial to use DAT blocks for shared mem +'' -- based on work by Chip Gracey +'' -- see below for terms of use +'' E-mail..... riley@robots-everywhere.com +'' Started.... +'' Updated.... 1 SEPT 2020 +'' mcalyer +'' -- Modified version of Riley August(DAT blocks for shared mem) and John MacPhalen's Full Duplex Serial +'' -- Based on work by Chip Gracey +'' -- Removed all but COM interface +'' +'' ================================================================================================= + +{{ + + Note: Buffer size no longer has to be power-of-2 integer. + + Note: The dec(), bin(), and hex() methods will no longer require the digits parameter as + in older versions of FullDuplexSerial. Use fdec(), fbin(), and fhex() for code that + requires a specific field width. + + + The smart pin uarts use a 16-bit value for baud timing which can limit low baud rates for + some system frequencies -- beware of these limits when connecting to older devices. + + Baud 20MHz 40MHz 80MHz 100MHz 200MHz 300MHz + ------ ----- ----- ----- ------ ------ ------ + 300 No No No No No No + 600 Yes No No No No No + 1200 Yes Yes No No No No + 2400 Yes Yes Yes Yes No No + 4800 Yes Yes Yes Yes Yes Yes + +}} + + +con { fixed io pins } + + RX1 = 63 { I } ' programming / debug + TX1 = 62 { O } + + SF_CS = 61 { O } ' serial flash + SF_SCK = 60 { O } + SF_SDO = 59 { O } + SF_SDI = 58 { I } + + +con + + BUF_SIZE = 256 + + +obj + + +dat + + cog long 0 ' cog flag/id + + rxp long 0 ' rx smart pin + txp long 0 ' tx smart pin + rxhub long 0 ' hub address of rxbuf + txhub long 0 ' hub address of txbuf + + rxhead long 0 ' rx head index + rxtail long 0 ' rx tail index + txhead long 0 ' tx head index + txtail long 0 ' tx tail index + + txdelay long 0 ' ticks to transmit one byte + + rxbuf byte 0[BUF_SIZE] ' buffers + txbuf byte 0[BUF_SIZE] + + + + +pub null() + +'' This is not a top level object + + +pub start(rxpin, txpin, mode, baud) : result | baudcfg, spmode + +'' Start simple serial coms on rxpin and txpin at baud +'' -- rxpin... receive pin (-1 if not used) +'' -- txpin... transmit pin (-1 if not used) +'' -- mode.... %0xx1 = invert rx +'' %0x1x = invert tx +'' %01xx = open-drain/open-source tx + + + stop() + + if (rxpin == txpin) ' pin must be unique + return false + + longmove(@rxp, @rxpin, 2) ' save pins + rxhub := @rxbuf ' point to buffers + txhub := @txbuf + + txdelay := clkfreq / baud * 11 ' tix to transmit one byte + + baudcfg := muldiv64(clkfreq, $1_0000, baud) & $FFFFFC00 ' set bit timing + baudcfg |= (8-1) ' set bits (8) + + if (rxp >= 0) ' configure rx pin if used + spmode := P_ASYNC_RX + if (mode.[0]) + spmode |= P_INVERT_IN + pinstart(rxp, spmode, baudcfg, 0) + + if (txp >= 0) ' configure tx pin if used + spmode := P_ASYNC_TX | P_OE + case mode.[2..1] + %01 : spmode |= P_INVERT_OUTPUT + %10 : spmode |= P_HIGH_FLOAT ' requires external pull-up + %11 : spmode |= P_INVERT_OUTPUT | P_LOW_FLOAT ' requires external pull-down + pinstart(txp, spmode, baudcfg, 0) + + cog := coginit(COGEXEC_NEW, @uart_mgr, @rxp) + 1 ' start uart manager cog + + return cog + + +pub stop() + +'' Stop serial driver +'' -- frees a cog if driver was running + + if (cog) ' cog active? + cogstop(cog-1) ' yes, shut it down + cog := 0 ' and mark stopped + + longfill(@rxp, -1, 2) ' reset object globals + longfill(@rxhub, 0, 7) + + +pub rx() : b + +'' Pulls byte from receive buffer if available +'' -- will wait if buffer is empty + + repeat while (rxtail == rxhead) ' hold while buffer empty + + b := rxbuf[rxtail] ' get a byte + if (++rxtail == BUF_SIZE) ' update tail pointer + rxtail := 0 + + +pub rxcheck() : b + +'' Pulls byte from receive buffer if available +'' -- returns -1 if buffer is empty + + if (rxtail <> rxhead) ' something in buffer? + b := rxbuf[rxtail] ' get it + if (++rxtail == BUF_SIZE) ' update tail pointer + rxtail := 0 + else + b := -1 ' mark no byte available + + +pub rxtime(ms) : b | mstix, t + +'' Wait ms milliseconds for a byte to be received +'' -- returns -1 if no byte received, $00..$FF if byte + + mstix := clkfreq / 1000 + + t := getct() + repeat until ((b := rxcheck()) >= 0) || (((getct()-t) / mstix) >= ms) + + +pub rxtix(tix) : b | t + +'' Waits tix clock ticks for a byte to be received +'' -- returns -1 if no byte received + + t := getct() + repeat until ((b := rxcheck()) >= 0) || ((getct()-t) >= tix) + + +pub available() : count + +'' Returns # of bytes waiting in rx buffer + + if (rxtail <> rxhead) ' if byte(s) available + count := rxhead - rxtail ' get count + if (count < 0) + count += BUF_SIZE ' fix for wrap around + + +pub rxflush() + +'' Flush receive buffer + + repeat while (rxcheck() >= 0) + + +pub tx(b) | n + +'' Move byte into transmit buffer if room is available +'' -- will wait if buffer is full + + repeat + n := txhead - txtail ' bytes in buffer + if (n < 0) ' fix for index wrap-around + n += BUF_SIZE + if (n < BUF_SIZE-1) + quit + + txbuf[txhead] := b ' move to buffer + if (++txhead == BUF_SIZE) ' update head pointer + txhead := 0 + + +pub txn(b, n) + +'' Emit byte n times + + repeat n + tx(b) + + +pub str(p_str) + +'' Emit z-string at p_str + repeat (strsize(p_str)) + tx(byte[p_str++]) + + +pub txflush() + +'' Wait for transmit buffer to empty +'' -- will delay one byte period after buffer is empty + + repeat until (txtail == txhead) ' let buffer empty + waitct(getct() + txdelay) ' delay for last byte + + + + +dat { smart pin uart/buffer manager } + + org + +uart_mgr setq #4-1 ' get 4 parameters from hub + rdlong rxd, ptra + +uart_main testb rxd, #31 wc ' rx in use? + + + + if_nc call #rx_serial + + testb txd, #31 wc ' tx in use? + if_nc call #tx_serial + + + + jmp #uart_main + + +rx_serial testp rxd wc ' anything waiting? + if_nc ret + + + + rdpin t3, rxd ' read new byte + shr t3, #24 ' align lsb + mov t1, p_rxbuf ' t1 := @rxbuf + rdlong t2, ptra[4] ' t2 := rxhead + add t1, t2 + wrbyte t3, t1 ' rxbuf[rxhead] := t3 + incmod t2, #(BUF_SIZE-1) ' update head index + + + + _ret_ wrlong t2, ptra[4] ' write head index back to hub + + +tx_serial rdpin t1, txd wc ' check busy flag + if_c ret ' abort if busy + + rdlong t1, ptra[6] ' t1 = txhead + rdlong t2, ptra[7] ' t2 = txtail + cmp t1, t2 wz ' byte(s) to tx? + if_e ret + + mov t1, p_txbuf ' start of tx buffer + add t1, t2 ' add tail index + rdbyte t3, t1 ' t3 := txbuf[txtail] + wypin t3, txd ' load into sp uart + incmod t2, #(BUF_SIZE-1) ' update tail index + _ret_ wrlong t2, ptra[7] ' write tail index back to hub + + +' -------------------------------------------------------------------------------------------------- + +rxd res 1 ' receive pin +txd res 1 ' transmit pin +p_rxbuf res 1 ' pointer to rxbuf +p_txbuf res 1 ' pointer to txbuf + +indi res 1 + +t1 res 1 ' work vars +t2 res 1 +t3 res 1 + + fit 472 + + +con { license } + +{{ + + Terms of Use: MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice shall be included in all copies + or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE + OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +}} \ No newline at end of file diff --git a/libraries/community/p2/All/cricket_esp32_at/demo_32_Voltage_Meters.png b/libraries/community/p2/All/cricket_esp32_at/demo_32_Voltage_Meters.png new file mode 100644 index 00000000..19e6a49e --- /dev/null +++ b/libraries/community/p2/All/cricket_esp32_at/demo_32_Voltage_Meters.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:644f64527d691d1dd563d87d02880c55ff3a893f4f8cf7cdf171ea13e8568f72 +size 160479 diff --git a/libraries/community/p2/All/cricket_esp32_at/demo_led_control.png b/libraries/community/p2/All/cricket_esp32_at/demo_led_control.png new file mode 100644 index 00000000..c915acea --- /dev/null +++ b/libraries/community/p2/All/cricket_esp32_at/demo_led_control.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e0da8b6937f160d50ef066f19f9fb69031bb30b504051b7d9c99620a39f9401d +size 119622 diff --git a/libraries/community/p2/All/cricket_esp32_at/demo_led_control.spin2 b/libraries/community/p2/All/cricket_esp32_at/demo_led_control.spin2 new file mode 100644 index 00000000..e495480c --- /dev/null +++ b/libraries/community/p2/All/cricket_esp32_at/demo_led_control.spin2 @@ -0,0 +1,157 @@ +' Title : Cricket ESP32 AT , LED Control Demo +' Purpose : Webserver , Turn P2 LEDs , P56,P57 on/off +' Date : +' Author : mcalyer +' Requirements : esp_drv,esp_wifi,esp_webserver,esp_logon,debug +' html file "led_ctrl.html" +' Terms of Use : See end +' Verison Date Change log +' 1.0 06/16/21 First release + + +CON + _clkfreq = 200_000_000 + + ' logon app types + ESP_TOUCH = wifi.ESP_TOUCH + AIR_KISS = wifi.AIR_KISS + ESP_TOUCH_AIR_KISS = wifi.ESP_TOUCH_AIR_KISS + + 'logon options + FORCE_LOG_OFF = 1' + NO_FORCE_LOG_OFF = 0 + + ' HTTP request types + HTTP_REQ_PAGE_HTML = ws.HTTP_REQ_PAGE_HTML + HTTP_REQ_PAGE_GZ = ws.HTTP_REQ_PAGE_GZ + HTTP_REQ_GET_TEXT = ws.HTTP_REQ_GET_TEXT + HTTP_REQ_GET_JSON = ws.HTTP_REQ_GET_JSON + + 'Request options + HTTP_REQ_MATCH_PARTIAL = ws.HTTP_REQ_MATCH_PARTIAL + + +VAR + +DAT + 'web page + led_html_size long led_html_end - led_html + led_html file "led_control.html" + led_html_end + +OBJ + wifi : "esp_wifi" + ws : "esp_webserver" + logon : "esp_logon" + esp : "esp_drv" + tcp : "esp_tcp" + +pub demo() | status,connect,error,long info[8] + + '****************** Initalize ***************************** + ' Initialize pin usage : rx,tx uart,esp32 reset,baud rate 1MHZ + esp.init(19,18,24,115200) + + pinlow(56) ' leds off + pinlow(57) + + '****************************** Logon ********************** + ' 1 .log on using android/apple phone app Espressif Esp Touch , you have 120 seconds + status,connect,error := logon.logon(0,0,ESP_TOUCH,120,0,NO_FORCE_LOG_OFF) + ' 2. log on with embedded ssid , password + ' status,connect,error := logon.logon(string("ssid"),string("password"),0,10,0,NO_FORCE_LOG_OF + ' 3. log on with embedded ssid , password and static ip' + 'ip[0] := string("192.168.1.253") static ip + 'ip[1] := string("192.168.1.254") gateway + 'ip[2] := string("255.255.255.0") netmask + 'status,connect,error := logon.logon(string("ssid"),string("password"),0,10,@ip,NO_FORCE_LOG_OFF) + + + if !!connect + debug("Log on Error") + abort + + '***************** Connection Info ************************ + + debug("Log on OK") + if !!status := wifi.get_sta_ap_connect_info(@info) + debug("ip : " , zstr_(info[0])) + debug("mac : " , zstr_(info[1])) + debug("gateway : " , zstr_(info[2])) + debug("netmask : " , zstr_(info[3])) + debug("bssid : " , zstr_(info[4])) + debug("rssi : " , zstr_(info[5])) + debug("channel : " , zstr_(info[6])) + + '******************** Web Server *************************** + ' Server init + ws.server_init() + + ' Register for http requests + ' HTTP_REQ_MATCH_PARTIAL example : match /P56/ with /P56/ON or /P56/OFF , result is calls same function for on/off + ws.http_register_request(HTTP_REQ_PAGE_HTML,string("GET /"),@led_html,led_html_size) + ws.http_register_request(HTTP_REQ_GET_TEXT | HTTP_REQ_MATCH_PARTIAL ,string("GET /P56/"),@P56,0) + ws.http_register_request(HTTP_REQ_GET_TEXT | HTTP_REQ_MATCH_PARTIAL ,string("GET /P57/"),@P57,0) + + ' Start webserver , mDNS local network name "cricket" + ' "C" = run in cog , 0 = no cog + ' Use browser , set address to ip + if status := ws.start_server(string("cricket"),"C") + debug("Web server Error : " , uhex(status)) + abort + + 'Loop + repeat + waitms(1000) + + + '**************** Response to requests *********** + +' Called when "GET /P56/" request occurs +' Turn P56 LEDS on/off , send led state back +pub P56(sptr) : s + 'sptr = request path , "GET /P56/ON" or ""GET /P56/OFF" + sptr := sptr + 9 ' get on/off string + if strcomp(sptr,s := string("ON")) + pinhigh(56) + elseif strcomp(sptr, s := string("OFF")) + pinlow(56) + else + s := string("ERROR") + +' Called when "GET /P57/" request occurs +' Turn P57 LEDS on/off , send led state back +pub P57(sptr) : s + 'sptr = request path , ""GET /P57/ON" or ""GET /P57/OFF" + sptr := sptr + 9 ' get on/off string + if strcomp(sptr,s := string("ON")) + pinhigh(57) + elseif strcomp(sptr, s := string("OFF")) + pinlow(57) + else + s := string("ERROR") + + + + {{ + + Terms of Use: MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice shall be included in all copies + or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE + OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +}} \ No newline at end of file diff --git a/libraries/community/p2/All/cricket_esp32_at/demo_meters32.spin2 b/libraries/community/p2/All/cricket_esp32_at/demo_meters32.spin2 new file mode 100644 index 00000000..884271e9 --- /dev/null +++ b/libraries/community/p2/All/cricket_esp32_at/demo_meters32.spin2 @@ -0,0 +1,168 @@ +' Title : Cricket ESP32 AT , Demo 32 Channel Voltage Monitor +' Purpose : Demo , webserver , monitor 32 voltages , voltages simulated +' Date : +' Author : mcalyer +' Requirements : esp_drv,esp_wifi,esp_tcp,esp_webserver,esp_logon,debug +' html file "meters32.html" +' References : 1. https://developers.google.com/chart/interactive/docs/gallery/gauge ' +' Terms of Use : See end +' Verison Date Change log +' 1.0 06/24/21 First release + + +CON + _clkfreq = 200_000_000 + + ' logon app types + ESP_TOUCH = wifi.ESP_TOUCH + AIR_KISS = wifi.AIR_KISS + ESP_TOUCH_AIR_KISS = wifi.ESP_TOUCH_AIR_KISS + + 'logon options + FORCE_LOG_OFF = 1' + NO_FORCE_LOG_OFF = 0 + + ' HTTP request types + HTTP_REQ_PAGE_HTML = ws.HTTP_REQ_PAGE_HTML + HTTP_REQ_PAGE_GZ = ws.HTTP_REQ_PAGE_GZ + HTTP_REQ_GET_TEXT = ws.HTTP_REQ_GET_TEXT + HTTP_REQ_GET_JSON = ws.HTTP_REQ_GET_JSON + + 'Request options + HTTP_REQ_MATCH_PARTIAL = ws.HTTP_REQ_MATCH_PARTIAL + + 'json buffer + DATA_BUF_SIZE = 256 + +VAR + +DAT + + index_html_size long index_html_end - index_html + index_html file "meters32.html" + index_html_end + data_buf byte 0[DATA_BUF_SIZE] + data_ptr long 0 + + +OBJ + esp : "esp_drv" + wifi : "esp_wifi" + tcp : "esp_tcp" + ws : "esp_webserver" + logon : "esp_logon" + + +pub demo() | status,connect,error,long info[8] + + '****************** Initalize ***************************** + ' Initialize pin usage : rx,tx uart,esp32 enable , baud rate + esp.init(19,18,24,115200) + + '****************************** Logon ********************** + ' 1 .log on using android/apple phone app Espressif Esp Touch , you have 120 seconds + ' Note : Requires 2.4G connection + status,connect,error := logon.logon(0,0,ESP_TOUCH,120,0,NO_FORCE_LOG_OFF) + ' 2. log on with embedded ssid , password + ' status,connect,error := logon.logon(string("ssid"),string("password"),0,10,0,NO_FORCE_LOG_OF + ' 3. log on with embedded ssid , password and static ip' + 'ip[0] := string("192.168.1.253") static ip + 'ip[1] := string("192.168.1.254") gateway + 'ip[2] := string("255.255.255.0") netmask + 'status,connect,error := logon.logon(string("ssid"),string("password"),0,10,@ip,NO_FORCE_LOG_OFF) + + if !!connect + debug("Log on Error") + abort + + '***************** Connection Info ************************ + + debug("Log on OK") + if !!status := wifi.get_sta_ap_connect_info(@info) + debug("ip : " , zstr_(info[0])) + debug("mac : " , zstr_(info[1])) + debug("gateway : " , zstr_(info[2])) + debug("netmask : " , zstr_(info[3])) + debug("bssid : " , zstr_(info[4])) + debug("rssi : " , zstr_(info[5])) + debug("channel : " , zstr_(info[6])) + + '******************** WebServer *************************** + ' Once webserver starts : enter ip in browser or use mDNS local network name cricket.local + + ' Server init + ws.server_init() + + ' Register for http requests + ws.http_register_request(HTTP_REQ_PAGE_HTML,string("GET /"),@index_html,index_html_size) + ws.http_register_request(HTTP_REQ_GET_JSON,string("GET /volts"),@json_A32,0) + + ' Start webserver , mDNS local network name "cricket.local" + ' Enter local network name or ip in browser + ' "C" = cog it , 0 = do not run in cog + + if status := ws.start_server(string("cricket"),"C") + debug("Web server Error : " , uhex(status)) + abort + + 'Loop forever + repeat + waitms(1000) + + '*************** Response to "GET /volts" Request **************** + +' This gets called when "GET /volts" request occurs +pub json_A32(sptr) : r | i + ' make json array {"volts":["v1","v2",...."v32"]} text string + bytefill(@data_buf,0,DATA_BUF_SIZE) + data_ptr := 0 + send := @char_add + send("{",34,string("volts"),34,":","[") + repeat i from 0 to 30 + send(34,sim_volts(),34,44) + send(34,sim_volts(),34,"]","}") + return @data_buf + +pub str_add(s) | sz + sz := strsize(s) + bytemove(@data_buf + data_ptr,s,sz) + data_ptr += sz + +pub char_add(d) + if d > $FF + str_add(d) + return + data_buf[data_ptr] := d + data_ptr += 1 + +pub sim_volts() : s | k + s := string("_._") + k := getct() + k := ??k +// 33 + byte[s] := k+/10 + $30 + byte[s+2] := k+//10 + $30 + + + + {{ + + Terms of Use: MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice shall be included in all copies + or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE + OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +}} \ No newline at end of file diff --git a/libraries/community/p2/All/cricket_esp32_at/esp_at.spin2 b/libraries/community/p2/All/cricket_esp32_at/esp_at.spin2 new file mode 100644 index 00000000..00537d06 --- /dev/null +++ b/libraries/community/p2/All/cricket_esp32_at/esp_at.spin2 @@ -0,0 +1,66 @@ +' Title : Cricket ESP32 AT , Basic AT Commands +' Purpose : Basic AT commands +' Date : +' Author : mcalyer +' Requirements : esp_drv +' References : 1. https://docs.espressif.com/projects/esp-at/en/latest/AT_Command_Set/index.html +' : 2. https://docs.espressif.com/_/downloads/esp-at/en/release-v2.1.0.0_esp32/pdf/ +' Terms of Use : See end +' Verison Date Change log +' 1.0 06/16/21 First release + + +CON + 'Error code + mod = $01 ' obj + f01 = 1 ' get_ver_info() + f02 = 2 + f03 = 3 + +VAR + + +OBJ + esp : "esp_drv" + + +pub null() + + +'******************* AT Basic Commands ************************** + +pub get_ver_info() : status , atver , sdkver , cptime , binver + esp.cmd_str(string("AT+GMR")) + esp.cmd_send() + if status := esp.error(mod,f01,esp.get_resp(50)) + return + atver := esp.get_str_indexed(0) + sdkver := esp.get_str_indexed(1) + cptime := esp.get_str_indexed(2) + binver := esp.get_str_indexed(3) + + + + +{{ + + Terms of Use: MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice shall be included in all copies + or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE + OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +}} \ No newline at end of file diff --git a/libraries/community/p2/All/cricket_esp32_at/esp_drv.spin2 b/libraries/community/p2/All/cricket_esp32_at/esp_drv.spin2 new file mode 100644 index 00000000..085c0134 --- /dev/null +++ b/libraries/community/p2/All/cricket_esp32_at/esp_drv.spin2 @@ -0,0 +1,493 @@ +' Title : Cricket ESP32 AT +' Purpose : P2 ESP32 AT interface , provides command/response interface +' Date : +' Author : mcalyer , mike.calyer@yahoo.com +' Acknowledgements : Chip Gracey - fullduplexserial +' John MacPhalen - jm_fullduplexserial +' Riley August - ESP32,dat_fullduplexserial +' Requirements : com_dat_fullduplexserial/dat_fullduplexserial +' References : 1. https://docs.espressif.com/projects/esp-at/en/latest/AT_Command_Set/index.html +' : 2. https://docs.espressif.com/_/downloads/esp-at/en/release-v2.1.0.0_esp32/pdf/ +' : 3. https://download.mikroe.com/documents/add-on-boards/click/wifi-ble/wifi-ble-click-schematic-v102.pdf +' : 4. https://www.parallax.com/product/p2-to-mikrobus-click-adapter/ +' : 5. https://www.espressif.com/sites/default/files/documentation/esp32-wroom-32_datasheet_en.pdf +' Hardware : 1. wifi/ble click Parallax +' : 2. P2 to MikroBUS Click Adapter , Parallax +' ESP32 FW : Works with : (use get_info.spin2 to find version) +' 1. AT version:2.1.0.0(883f7f2 - Jul 24 2020 11:50:07) +' SDK version:v4.0.1-193-ge7ac221 +' compile time(0ad6331):Jul 28 2020 02:47:21 +' Bin version:2.1.0(WROOM-32) +' Supports AT,WIFI,TCP/UDP,BLE,HTTP Client,MQTT +' 2. AT version:1.1.3.0(5a40576 - Nov 28 2018 12:50:55) +' SDK version:v3.0.7 +' compile time:Dec 21 2018 09:04:56 +' Bin version:1.1.3(WROOM-32) +' Supports AT,WIFI,TCP/UDP,BLE +' Need to know ! : 1. Any string pointers returned by interface only valid until next command +' method called. Use it or save the entire string ' + +' Terms of Use : See end +' Verison Date Change log +' 1.0 06/24/21 First release + + + +CON + + 'Command Buffer + CMD_BUF_SIZE = 256 + + 'Response/Message Buffer + RESP_BUF_SIZE = 1024 + RESP_STR_NUM = 64 + NO_MORE_DATA_TIMEOUT = 10 + + 'Response Types + RESP_OK = 0 + RESP_ERROR = 1 + RESP_OVER = 2 + RESP_SEND_FAIL = 3 + RESP_TIMEOUT = 4 + RESP_NOT_FOUND = 5 + RESP_SEND_OK = 6 + RESP_FOUND_MESSAGE = 7 + RESP_SIZE_MATCH = 8 + + 'Response options flags + INDEX_ZSTR = $01 + FIND_MESS = $10 + FIND_RESP = $20 + FIND_SIZE = $40 + + 'Error + zmod = 0 'this obj' + f01 = 1 'cmd_str(string("ATE0")) + f02 = 2 'esp_uart(baud) + f03 = 3 'p2_esp_uart(baud_rate) + +VAR + + +DAT + 'UART/ESP32 + txpin byte 0 + rxpin byte 0 + penable byte 0 + + 'Command + cmdbuf byte 0[CMD_BUF_SIZE] + cmdptr long 0 + resptime long 0 + hs long 0 + + 'Response + rxbuf byte 0[RESP_BUF_SIZE] + strptrs long 0[RESP_STR_NUM] + strsizes long 0[RESP_STR_NUM] + strcount long 0 + rxbytes long 0 + rxptr long 0 + ok_str byte "OK", 0 + error_str byte "ERROR",0 + send_ok_str byte "SEND OK",0 + send_fail_str byte "SEND FAIL",0 + + 'Error + last_error long 0 + + +OBJ + com : "com_dat_fullduplexserial" + +pub null() + + +'*************** Interface and ESP32 Module Initialization *************** +' ptx = UART TX pin +' rtx = UART RX pin +' pen = module enable pin , note - pulled up on module +' Default esp32 baud rate = 115200 + +pub init(prx,ptx,pen,baud_rate) : status + txpin := ptx + rxpin := prx + penable := pen ' ESP32 enable pin + + str_buf_reset() ' reset string buf , see strings + + esp_disable() ' disable ESP32 module + p2_uart(115200) ' initialize P2 uart , baud_rate = 115200 + waitms(10) + esp_enable() ' enable ESP32 module + + waitms(8000) ' wait for end of esp boot messages and logon + + cmd_str(string("ATE0")) ' Turn echo off , echo on not supported ! + cmd_send() + if status := error(zmod,f01,get_resp(50)) + return + + cmd_str(string("AT+SYSLOG=1")) ' Enable ESP32 error code reporting + cmd_send() ' This can fail , no enable/disable in some FW + waitms(50) + + if status := p2_esp_uart(baud_rate) ' set P2 , ESP32 baud rate + return + + waitms(100) +'********************* Enable/Disable/Reset ************************ + +pub esp_disable() + pinlow(penable) + +pub esp_enable() + pinfloat(penable) + +pub esp_reset(nmsec) + pinlow(penable) + waitms(nmsec) + pinfloat(penable) + +'************************* UARTS *********************************** + +pub p2_uart(baud) + com.start(rxpin, txpin, %0000, baud) + +pub esp_uart(baud): r + cmd_str(string("AT+UART_CUR=")) + send := @cmd_chars_add + send(convert_dec_value_to_str(baud),44,8,44,1,44,0,44,0) + cmd_send() + return error(zmod,f02,get_resp(50)) + +pub p2_esp_uart(baud_rate): status + if status := esp_uart(baud_rate) + return + waitms(100) + p2_uart(baud_rate) + cmd_str(string("AT")) ' test coms + cmd_send() + return error(zmod,f03,get_resp(50)) + +'************************ Error ***************************** +' error code.byte[3] = object +' error code.byte[2] = function +' error code.byte[1] = esp32 error code , see ESP-AT User Guide AT+SYSLOG +' error code.byte[0] = esp drv error code , see CON + +pub error(mod,fc,err) : error_code | s + error_code := err + case err + RESP_OK : + RESP_ERROR : ' get esp32 error code if any + s := find_string_in_rxbuf(string("ERR CODE:")) + if s + s += 13 + byte[s][2] := 0 + s := convert_str_to_hex_value(s) + error_code.byte[3] := mod + error_code.byte[2] := fc + error_code.byte[1] := s + RESP_OVER..RESP_NOT_FOUND : error_code.byte[3] := mod + error_code.byte[2] := fc + RESP_SEND_OK..RESP_SIZE_MATCH : error_code := 0 + last_error := error_code + +pub get_last_error() : r + return last_error + +'***************** AT Command Interface *********************** +' builds/manages command buf , command buf contains command,params +' sends to esp32 in one blast +' you can see whats being sent out by enabling debug line in cmd_send_ex() + +pub cmd_str(s): r + cmd_reset() + cmd_str_add(s) + return get_resp_header_size(s) + +pub cmd_str_add(s) | sz + if 0 == s + return + sz := strsize(s) + bytemove(@cmdbuf + cmdptr,s,sz) + cmdptr += sz + +pub cmd_chars_add(d) + if d == -1 + return + if d > $FF + cmd_str_add(d) + return + if d >= 0 && d <= 9 + d := d + $30 + cmdbuf[cmdptr] := d + cmdptr += 1 + +pub cmd_send() + com.rxflush() + flush_rxbuf(0) + str_buf_reset() + cmd_send_ex() + +pub cmd_send_ex() + cmdbuf[cmdptr++] := 13 + cmdbuf[cmdptr++] := 10 + cmdbuf[cmdptr] := 0 + 'debug("CMD : " , zstr_(@cmdbuf)) + com.str(@cmdbuf) + +pub cmd_reset() + bytefill(@cmdbuf,0,cmdptr) + cmdptr := 0 + +'***************** AT Response Interface ************** +' Gets esp32 response which is a number of crlf strings +' Converts crlf strs to zstrs , counts strs, makes table of str ptrs +' Data can be extracted from strs based on command (see references)' +' Example esp32 command "AT+GMR" , returns 5 crlf strings (if no error) +' "AT version" , "SDK Version" , "compile time" , "bin version " , "OK" +' get_str_indexed(0) , gets ptr to "AT version" string + +pub get_rxbuf(nmsec,flags): status | endptr, inbyte,nobytes,t0 + endptr := nobytes := 0 + t0 := getms() + repeat + if getms() - t0 > nmsec + status := RESP_TIMEOUT + return + if com.available() + quit + repeat + if getms() - t0 > nmsec + status := RESP_TIMEOUT + quit + if nobytes > NO_MORE_DATA_TIMEOUT + quit + inbyte := com.rxtime(1) + if(inbyte > -1) + nobytes := 0 + rxbuf[endptr] := inbyte + if ++endptr >= RESP_BUF_SIZE + status := RESP_OVER + quit + else + nobytes++ + resptime := getms() - t0 + rxbytes := endptr + if flags & INDEX_ZSTR + index_strs(endptr) + +pub get_resp(timeout): status + if status := get_rxbuf(timeout,INDEX_ZSTR) + return + if find_string_in_rxbuf(@ok_str) + status := RESP_OK + elseif find_string_in_rxbuf(@error_str) + status := RESP_ERROR + elseif find_string_in_rxbuf(@send_fail_str) + status := RESP_SEND_FAIL + else + status := RESP_NOT_FOUND + return + +pub get_resp_find_str(message,timeout): status,sptr + if status := get_rxbuf(timeout,INDEX_ZSTR) + return + return status, find_string_in_rxbuf(message) + +pub get_rxbuf_ptr() : r + return @rxbuf + +pub get_rxbytes() : b + return rxbytes + +pub get_response_time() : t + return resptime + +pub flush_rxbuf(n) + if 0 == n + longfill(@rxbuf,0, RESP_BUF_SIZE/4) + if -1 == n + bytefill(@rxbuf,0,rxbytes) + +pub get_resp_header_size(s) : hz | sz + sz := strsize(s) + hz := sz - 1 + if "?" == byte[s][sz-1] || "=" == byte[s][sz-1] + hz := hz - 1 + +'************************ COM ********************************* + +pub com_available(): nbytes + return com.available() + +pub com_rx_flush() + com.rxflush() + +pub com_send_byte(b) + com.tx(b) + +pub com_send_str(s) + com.str(s) + +pub com_send_data(buf,buf_sz) | i + repeat i from 0 to buf_sz - 1 + com.tx(byte[buf][i]) + +'*********************** Strings ****************************** + +CON + STR_BUF_SIZE = 128 + +DAT + str_buf byte 0[STR_BUF_SIZE] ' used for convert to string methods + str_buf_ptr long 0 + +' convert rxbuf crlf strs to zstrs , ignore null strs , count strs, +' make table of str ptrs , str sizes +pub index_strs(sz) | i , j , k , char + longfill(@strptrs,0, (2 * RESP_STR_NUM) + 1) + k := char := 0 + repeat i from 0 to sz - 1 + if rxbuf[i] > $1F && rxbuf[i] < $7F + if 0 == char + j := i + char := 1 + next + if $0A == rxbuf[i] && char + rxbuf[i] := 0 + rxbuf[i - 1] := 0 + strptrs[k] := @rxbuf + j + strsizes[k] := i - j - 1 + if k + 1 == RESP_STR_NUM + quit + k++ + char := 0 + strcount := k + +pub get_str_index_count() : n + return strcount + +pub get_str_indexed(n) : ptr + return strptrs[n] + +pub get_str_indexed_ex(n) : ptr , s + return strptrs[n] , strsizes[n] + +pub find_string_in_rxbuf(mptr) : result + return find_string(mptr,@rxbuf,rxbytes) + +pub find_string(mptr,b,bs): result | i , j , s , sz + sz := strsize(mptr) + if sz > bs + return + s := 0 + i := j := 0 + repeat + if byte[mptr][i] == byte[b][j + i] + s++ + i++ + if s == sz + return b + j + else + j := j + 1 + i + s := i := 0 + if j >= bs + return + +pub get_str_from_list_ex(offset,str_index,item_index): iptr | p , sz + p , sz := get_str_indexed_ex(str_index) + p := p + offset + sz := sz - offset + return get_str_from_list(p,sz,item_index) + +pub get_str_from_list(str,sz,index) : p | i , j , k + J := k := 0 + repeat i from 0 to sz + if 0 == byte[str][i] + quit + if "," == byte[str][i] + byte[str][i] := 0 + repeat i from 0 to sz + if byte[str][i] == 0 + if k == index + return str + j + k++ + j := i + 1 + return + +pub get_str_split_colon(str) : ptr | i , s + return get_str_split(str,":") + +pub get_str_split(str,char) : ptr | i , s + s := strsize(str) - 1 + repeat i from 0 to s + if 0 == byte[str][i] + return + if char == byte[str][i] + return str + i + 1 + +pub str_buf_reset() + str_buf_ptr := @str_buf + STR_BUF_SIZE - 1 + +' convert value to string methods only for use by this interface +pub convert_dec_value_to_str(v) : p | s + s := 0 + if v < 0 + s := 1 + v := abs(v) + byte[str_buf_ptr] := 0 + str_buf_ptr-- + repeat + byte[str_buf_ptr--] := v +// 10 + $30 + v +/= 10 + if v == 0 + if s + byte[str_buf_ptr--] := "-" + return str_buf_ptr + 1 + +'range 0 - 4294967296 +pub convert_str_to_dec_value(s) : d | i , sz , x + sz := strsize(s) + x := 1 + repeat i from 1 to sz + d := d + (byte[s][sz - i] - $30) * x + x := x * 10 + +'range 0 - 100000000 +pub convert_str_to_hex_value(s) : h | i, sz, x, y + sz := strsize(s) + x := 1 + repeat i from 1 to sz + y := byte[s][sz - i] - $30 + y := y > 9 ? (y - 7) & $DF : y + h := h + (y * x) + x := x * 16 + + + + +{{ + + Terms of Use: MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice shall be included in all copies + or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE + OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +}} \ No newline at end of file diff --git a/libraries/community/p2/All/cricket_esp32_at/esp_logon.spin2 b/libraries/community/p2/All/cricket_esp32_at/esp_logon.spin2 new file mode 100644 index 00000000..7b677453 --- /dev/null +++ b/libraries/community/p2/All/cricket_esp32_at/esp_logon.spin2 @@ -0,0 +1,102 @@ +' Title : Cricket ESP32 AT , Log on +' Purpose : logon to AP +' Date : +' Author : mcalyer +' Requirements : esp_wifi +' References : 1. https://docs.espressif.com/projects/esp-at/en/latest/AT_Command_Set/index.html +' : 2. https://docs.espressif.com/_/downloads/esp-at/en/release-v2.1.0.0_esp32/pdf/ +' Terms of Use : See end +' Verison Date Change log +' 1.0 06/24/21 First release + + + + +CON + + ENABLE = 1 + DISABLE = 0 + + 'Options + FORCE_LOG_OFF = 1 + NO_FORCE_LOG_OFF = 0 + +VAR + + +DAT + + +OBJ + wifi : "esp_wifi" + tcp : "esp_tcp" + +pub logon(ssid,pwd,app,timeout,sip,options) : status,connect,error + + 'Check connection status + status , connect := tcp.get_connect_status() + if status + return + + ' Force log off + if options & FORCE_LOG_OFF + if connect + if status := wifi.disconnect_ap() + return + else + if connect + return + + ' wifi mode + if status := wifi.set_wifi_mode(wifi.WIFI_STATION) + return + + ' dynamic/static ip + if 0 == sip + ' dynamic ip ,enable dhcp + if status := wifi.set_dhcp(ENABLE) + return + else + ' static ip , disable dhcp + if status := wifi.set_dhcp(DISABLE) + return + ' static ip , set ip,gatway,netmask + if status := wifi.set_sta_ip(long[sip][0],long[sip][1],long[sip][2]) + return + 'log on + if app + ' android/apple phone use ESP Touch app to put in ssid and password ' + ' The app shows you ip when connected + status := wifi.auto_smart_conf(app,timeout) + else + status , error := wifi.log_on_ap(ssid,pwd,timeout) + if status + return + + 'Check connection status + status , connect := tcp.get_connect_status() + + + + {{ + + Terms of Use: MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice shall be included in all copies + or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE + OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +}} \ No newline at end of file diff --git a/libraries/community/p2/All/cricket_esp32_at/esp_tcp.spin2 b/libraries/community/p2/All/cricket_esp32_at/esp_tcp.spin2 new file mode 100644 index 00000000..443252c7 --- /dev/null +++ b/libraries/community/p2/All/cricket_esp32_at/esp_tcp.spin2 @@ -0,0 +1,200 @@ +' Title : Cricket ESP32 AT TCP/IP Object +' Purpose : TCP/UDP +' Date : 04/16/2021 +' Author : mcalyer +' Requirements : esp_drv +' References : 1. https://docs.espressif.com/projects/esp-at/en/latest/AT_Command_Set/index.html +' : 2. https://docs.espressif.com/_/downloads/esp-at/en/release-v2.1.0.0_esp32/pdf/ +' Terms of Use : See end +' Verison Date Change log +' 1.0 06/24/21 First release + + + +CON + 'Connect options + SINGLE_CONNECT = 0 + MULTIPLE_CONNECT = 1 + + 'Error Codes + mod = $03 'obj + f01 = 1 'set_mode(mode) + f02 = 2 'close_client(link_id) + f03 = 3 'server_max_conn(num) + f04 = 4 'create_server(port,type,ca_enable) + f05 = 5 'delete_server(close_connections) + f06 = 6 'set_server_timeout(sec) + f07 = 7 'send_data_cmd(link_id,length) + f08 = 8 'send_data_block(link_id,buf,size) + f09 = 9 'send_data_blocks(link_id,buf,size,start_block,end_block) + f10 = 10 + f11 = 11 'get_connect_status() + f12 = 12 + f13 = 13 + +VAR + +DAT + mux_connect_mode long 0 + +OBJ + esp : "esp_drv" + + +pub null() + +'*************************** Mode *************************** + +pub set_mux_connect_mode(mode) : status + mux_connect_mode := -1 + esp.cmd_str(string("AT+CIPMUX=")) + esp.cmd_chars_add(mode) + esp.cmd_send() + if status := esp.error(mod,f01,esp.get_resp(50)) + return + mux_connect_mode := mode + +'************************** Status ************************** + +' connect to AP and got IP connect = true , else false +pub get_connect_status() : status , connect + esp.cmd_str(string("AT+CIPSTATUS")) + esp.cmd_send() + if status := esp.error(mod,f11,esp.get_resp(50)) + return + connect := esp.get_str_split_colon(esp.get_str_indexed(0)) + connect := ("2" == byte[connect]) ? true : false + +'*************************** Server ************************** + +pub close_client(link_id) : status + esp.cmd_str(string("AT+CIPCLOSE=")) + if MULTIPLE_CONNECT == mux_connect_mode + esp.cmd_chars_add(link_id) + esp.cmd_send() + return esp.error(mod,f02,esp.get_resp(50)) + +pub server_max_connect(num): status + esp.cmd_str(string("AT+CIPSERVERMAXCONN=")) + esp.cmd_chars_add(num) + esp.cmd_send() + return esp.error(mod,f03,esp.get_resp(50)) + +pub create_server(port,type,ca_enable): status + esp.cmd_str(string("AT+CIPSERVER=")) + send := @esp.cmd_chars_add + send(1,44,esp.convert_dec_value_to_str(port),44,34,type,34) + if ca_enable > -1 + send(44,ca_enable) + esp.cmd_send() + return esp.error(mod,f04,esp.get_resp(50)) + +pub delete_server(close_connections): status + esp.cmd_str(string("AT+CIPSERVER=")) + send := @esp.cmd_chars_add + send(0,44,close_connections) + esp.cmd_send() + return esp.error(mod,f05,esp.get_resp(50)) + +pub set_server_timeout(sec) : status + esp.cmd_str(string("AT+CIPSTO=")) + esp.cmd_str_add(esp.convert_dec_value_to_str(sec)) + esp.cmd_send() + return esp.error(mod,f06,esp.get_resp(50)) + +'********************** Send ****************************** + +pub send_data_cmd(link_id,length) : status + esp.cmd_str(string("AT+CIPSEND=")) + length := esp.convert_dec_value_to_str(length) + send := @esp.cmd_chars_add + if MULTIPLE_CONNECT == mux_connect_mode + send(link_id,44,length) + else + send(length) + esp.cmd_send_ex() + status := esp.error(mod,f07,esp.get_resp(200)) + +pub send_data_block(link_id,buf,size): status + if status := send_data_cmd(link_id,size) + return + esp.flush_rxbuf(-1) + esp.com_send_data(buf,size) + return esp.error(mod,f08,esp.get_resp(200)) + +pub send_data_blocks(link_id,buf,size,start_block,end_block) : status | i + if status := send_data_cmd(link_id,size) + return + esp.flush_rxbuf(-1) + repeat i from start_block to end_block step 2 + esp.com_send_data(long[buf][i],long[buf][i+1]) + return esp.error(mod,f09,esp.get_resp(200)) + +' ESP32 maximum block size is 2048 bytes +' Reduces blocks larger than 2048 bytes into smaller blocks , gathers small blocks +' Sends block(s) to ESP32 +pub send_data_ex(link_id,buf,blocks): status | i,j,z,sz,d,zd + i := j := sz := 0 + repeat + z := long[buf][i+1] + sz += z + if sz >= 2048 + sz := sz - z + d := (2048 - sz) + long[buf][i+1] := d + if status := send_data_blocks(link_id,buf,2048,j,i) + return + zd := z - d + long[buf][i] += d + long[buf][i+1] := zd + if 0 == zd + sz := 0 + j := i + 2 + elseif zd < 2048 + sz := zd + j := i + else + sz := 0 + next + i += 2 + while i < 2 * blocks + if sz + status := send_data_blocks(link_id,buf,sz,j,i-2) + +pub ping(url_ip_str) : status , time | hs + hs := esp.cmd_str(string("AT+ping=")) + send := @esp.cmd_chars_add + send(34,url_ip_str,34) + esp.cmd_send() + if status := esp.error(mod,f11,esp.get_resp(1000)) + return + time := esp.get_str_indexed(0) + hs + + + + + + + +{{ + + Terms of Use: MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice shall be included in all copies + or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE + OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +}} \ No newline at end of file diff --git a/libraries/community/p2/All/cricket_esp32_at/esp_webserver.spin2 b/libraries/community/p2/All/cricket_esp32_at/esp_webserver.spin2 new file mode 100644 index 00000000..2a430a62 --- /dev/null +++ b/libraries/community/p2/All/cricket_esp32_at/esp_webserver.spin2 @@ -0,0 +1,186 @@ +' Title : Cricket ESP32 AT , http server +' Purpose : http server +' Date : +' Author : mcalyer +' Requirements : esp_drv , esp_wifi , esp_tcp : : +' References : 1. https://www.w3.org/Protocols/rfc2616/rfc2616.html +' : 2. https://developer.mozilla.org/en-US/docs/Web/HTTP/Overview +' : 3. https://en.wikipedia.org/wiki/Gzip +' Terms of Use : See end +' Verison Date Change log +' 1.0 06/24/21 First release + + +CON + + ' Buffer sizes + HTTP_REQ_SIZE = 8 + + ' Request types + HTTP_REQ_PAGE_HTML = 1 + HTTP_REQ_PAGE_GZ = 2 + HTTP_REQ_GET_TEXT = 3 + HTTP_REQ_GET_JSON = 4 + + 'Request options + HTTP_REQ_MATCH_PARTIAL = $100 + + ' Cog option , stack + COG_STACK_SIZE = 128 + + +VAR + + + +DAT + 'Header types + H404_SZ long H404_END - H404 + H404 byte "HTTP/1.1 404 Not Found",$0D,$0A,"Content-type: text/html;charset=UTF-8",$0D,$0A,"Content-length: 0" + H404_END + + TEXT_HTML_SZ long TEXT_HTML_END - TEXT_HTML + TEXT_HTML byte "HTTP/1.1 200 OK",$0D,$0A,"Content-Type: text/html; charset=UTF-8",$0D,$0A,$0D,$0A + TEXT_HTML_END + + TEXT_HTML_GZ_SZ long TEXT_HTML_GZ_END - TEXT_HTML_GZ + TEXT_HTML_GZ byte "HTTP/1.1 200 OK",$0D,$0A,"Content-Type: text/html; charset=UTF-8",$0D,$0A + byte "Content-Encoding: gzip",$0D,$0A,$0D,$0A + TEXT_HTML_GZ_END + + TEXT_PLAIN_SZ long TEXT_PLAIN_END - TEXT_PLAIN + TEXT_PLAIN byte "HTTP/1.1 200 OK",$0D,$0A,"Content-Type: text/plain; charset=UTF-8",$0D,$0A,$0D,$0A + TEXT_PLAIN_END + + JSON_SZ long JSON_END - JSON + JSON byte "HTTP/1.1 200 OK",$0D,$0A,"Content-Type: application/json",$0D,$0A,$0D,$0A + JSON_END + + req_buf long 0[HTTP_REQ_SIZE * 4] + req_ptr long 0 + resp_buf long 0[4] + resp_blks long 0 + + cog long -1 + stack long 0[COG_STACK_SIZE] + client_req long 0 + client_id long 0 + +OBJ + esp : "esp_drv" + tcp : "esp_tcp" + wifi : "esp_wifi" + +pub http_register_request (type,sptr,ptr,sz) : r | i + ' example : type = HTTP_REQ_PAGE_HTML + ' request = string("GET /") + ' payload = ptr to index_html + ' payload size = index_html_size + if req_ptr > (HTTP_REQ_SIZE - 1) * 4 + return -1 + req_buf[req_ptr++] := type + req_buf[req_ptr++] := sptr + req_buf[req_ptr++] := ptr + req_buf[req_ptr++] := sz + +pub load_resp_buf(hptr,hsz,pptr,psz,blks) + resp_buf[0],resp_buf[1],resp_buf[2],resp_buf[3],resp_blks := hptr,hsz,pptr,psz,blks + +pub http_find_req(sptr) : t,ptr,sz | i,x + ' find request string , if found , return response type , ptr payload buf/callback func and size + repeat i from 0 to req_ptr - 1 step 4 + if req_buf[i] & HTTP_REQ_MATCH_PARTIAL ' example match /P56/ with /P56/ON or /P56/OFF + x := esp.find_string(req_buf[i + 1],sptr,strsize(sptr)) + else + x := strcomp(sptr,req_buf[i + 1]) + if x + return req_buf[i] , req_buf[i + 2] , req_buf[i + 3] + +pub http_resp() | s,t,ptr,sz,d + ' determine response based on request + t,ptr,sz := http_find_req(client_req) + if 0 == ptr + load_resp_buf(@H404,H404_SZ,0,0,1) + else + case t.byte[0] + HTTP_REQ_PAGE_HTML : load_resp_buf(@TEXT_HTML,TEXT_HTML_SZ,ptr,sz,2) + + HTTP_REQ_PAGE_GZ : load_resp_buf(@TEXT_HTML_GZ,TEXT_HTML_GZ_SZ,ptr,sz,2) + + HTTP_REQ_GET_TEXT : d := ptr(client_req) : 1 + load_resp_buf(@TEXT_PLAIN,TEXT_PLAIN_SZ,d,strsize(d),2) + + HTTP_REQ_GET_JSON : d := ptr(client_req) : 1 + load_resp_buf(@JSON,JSON_SZ,d,strsize(d),2) + + tcp.send_data_ex(client_id,@resp_buf,resp_blks) + tcp.close_client(client_id) + +pub http_req_loop(id,req_str) | status,s,p,ph + ' get request header string , example "+IPD,0,333:GET / HTTP/1.1" + ' get just this string "GET /" + ' get link id , example "+IPD,0" , 0 = link id + repeat + long[id] := long[req_str] := 0 + repeat until (esp.com_available() > 0) + status , s := esp.get_resp_find_str(string("+IPD"),100) + if s + p := esp.find_string(string("GET"),s,strsize(s)) + ph := esp.find_string(string(" HTTP"),s,strsize(s)) + if 0 == p || ph == 0 + next + byte[ph] := 0 + long[req_str] := p ' save request string + long[id] := byte[s+5] - $30 ' save link id + http_resp() ' determine response + +pub server_init() + req_ptr := 0 + longmove(@req_buf,0,HTTP_REQ_SIZE * 4) + +pub start_server(host_name,f) : status | i + if host_name + if status := wifi.mDNS(1,host_name,string("_http"),80) + return + if status := tcp.server_max_connect(1) + return + if status := tcp.set_mux_connect_mode(tcp.MULTIPLE_CONNECT) + return + if status := tcp.create_server(80,string("TCP"),-1) + return + if status := tcp.set_server_timeout(10) + return + if "C" == f + cog := cogspin(newcog, http_req_loop(@client_id,@client_req),@stack) + else + http_req_loop(@client_id,@client_req) + +pub stop_cog_server() + if cog > -1 + cogstop(cog) + cog := -1 + return + + + {{ + + Terms of Use: MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice shall be included in all copies + or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE + OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +}} \ No newline at end of file diff --git a/libraries/community/p2/All/cricket_esp32_at/esp_wifi.spin2 b/libraries/community/p2/All/cricket_esp32_at/esp_wifi.spin2 new file mode 100644 index 00000000..80e4963c --- /dev/null +++ b/libraries/community/p2/All/cricket_esp32_at/esp_wifi.spin2 @@ -0,0 +1,253 @@ +' Title : Cricket ESP32 AT , wifi +' Purpose : Wifi interface +' Date : +' Author : mcalyer +' Requirements : esp_drv , esp_strings spin2 objects +' References : 1. https://docs.espressif.com/projects/esp-at/en/latest/AT_Command_Set/index.html +' : 2. https://docs.espressif.com/_/downloads/esp-at/en/release-v2.1.0.0_esp32/pdf/ +' Terms of Use : See end +' Verison Date Change log +' 1.0 06/24/21 First release + + + + +CON + + 'WIFI Modes + WIFI_DISABLE = "0" + WIFI_STATION = "1" + WIFI_SOFTAP = "2" + WIFI_SOFTAP_STATION = "3" + WIFI_CONNECTED_AP = "4" + + 'Smart Config Modes + ESP_TOUCH = "1" + AIR_KISS = "2" + ESP_TOUCH_AIR_KISS = "3" + + 'local store for key info + NET_INFO_STORE_SZ = 18 + + 'Errror codes + mod = $02 'obj + f01 = 1 'set_host_name(host_name) + f02 = 2 'set_dhcp(enable) + f03 = 3 'set_sta_ip(ip,gateway,netmask) + f04 = 4 'set_wifi_mode(mode) + f05 = 5 'get_wifi_mode() + f06 = 6 'log_on_ap(ssid,pwd,nsec) + f07 = 7 'disconnect_ap() + f08 = 8 'get_ap_connect_info() + f09 = 9 'get_sta_ip() + f10 = 10 'get_sta_mac() + f11 = 11 + f12 = 12 'mDNS(enable,host_name,service_name,port) + f13 = 13 'start_smart_conf(type) + f14 = 14 'stop_smart_conf() + f15 = 15 'autoconnect(enable) + f16 = 16 'auto_smart_conf(type,nsec) + f17 = 17 + +VAR + + + +DAT + wifi_mode byte 0 + ssta_ip byte 0[NET_INFO_STORE_SZ] + smac byte 0[NET_INFO_STORE_SZ] + sgateway byte 0[NET_INFO_STORE_SZ] + snetmask byte 0[NET_INFO_STORE_SZ] + sbssid byte 0[NET_INFO_STORE_SZ] + srssi byte 0[NET_INFO_STORE_SZ] + schannel byte 0[NET_INFO_STORE_SZ] + +OBJ + esp : "esp_drv" + + +pub null() + +'******************* AT WiFi STA Commands *************************** + +pub set_host_name(host_name) : status + esp.cmd_str(string("AT+CWHOSTNAME=")) + send := @esp.cmd_chars_add + send(34,host_name,34) + esp.cmd_send() + return esp.error(mod,f01,esp.get_resp(50)) + +pub set_dhcp(enable): status + esp.cmd_str(string("AT+CWDHCP=")) + send := @esp.cmd_chars_add + send(enable,44,wifi_mode) + esp.cmd_send() + return esp.error(mod,f02,esp.get_resp(50)) + +pub set_sta_ip(ip,gateway,netmask) : status + esp.cmd_str(string("AT+CIPSTA=")) + send := @esp.cmd_chars_add + send(34,ip,34) + if gateway && netmask + send(44,34,gateway,34,44,34,netmask,34) + esp.cmd_send() + return esp.error(mod,f03,esp.get_resp(50)) + +pub set_wifi_mode(mode) : status + esp.cmd_str(string("AT+CWMODE=")) + esp.cmd_chars_add(mode) + esp.cmd_send() + if status := esp.error(mod,f04,esp.get_resp(50)) + return + wifi_mode := mode + +pub get_wifi_mode() : status , mode | hs + hs := esp.cmd_str(string("AT+CWMODE?")) + esp.cmd_send() + if status := esp.error(mod,f05,esp.get_resp(100)) + return + mode := esp.get_str_indexed(0) + hs - $30 + +pub log_on_ap(ssid,pwd,nsec) : status , error | hs + hs := esp.cmd_str(string("AT+CWJAP=")) + send := @esp.cmd_chars_add + send(34,ssid,34,",",34,pwd,34) + esp.cmd_send() + status := esp.error(mod,f06,esp.get_resp(nsec * 1000)) + if status.byte[0] == esp.RESP_ERROR + error := esp.get_str_indexed(0)+ hs + error := byte[error] - $30 + +pub disconnect_ap() : status + esp.cmd_str(string("AT+CWQAP")) + esp.cmd_send() + return esp.error(mod,f07,esp.get_resp(200)) + +pub get_ap_connect_info() : status , ssid , bssid , channel , rssi | hs + hs := esp.cmd_str(string("AT+CWJAP?")) + esp.cmd_send() + if status := esp.error(mod,f08,esp.get_resp(2000)) + return + ssid := esp.get_str_from_list_ex(hs,0,0) + bssid := esp.get_str_from_list_ex(hs,0,1) + channel := esp.get_str_from_list_ex(hs,0,2) + rssi := esp.get_str_from_list_ex(hs,0,3) + rssi := net_info_store(@srssi,rssi,0) + channel := net_info_store(@schannel,channel,0) + bssid := net_info_store(@sbssid,bssid,1) + +pub get_sta_ip() : status,ip,gateway,netmask | hs + hs := esp.cmd_str(string("AT+CIPSTA?")) + esp.cmd_send() + if status := esp.error(mod,f09,esp.get_resp(200)) + return + ip := esp.get_str_split_colon(esp.get_str_indexed(0)+ hs) + gateway := esp.get_str_split_colon(esp.get_str_indexed(1)+ hs) + netmask := esp.get_str_split_colon(esp.get_str_indexed(2)+ hs) + ip := net_info_store(@ssta_ip,ip,1) + gateway := net_info_store(@sgateway,gateway,1) + netmask := net_info_store(@snetmask,netmask,1) + +pub get_sta_mac(): status , mac | hs + hs := esp.cmd_str(string("AT+CIPSTAMAC?")) + esp.cmd_send() + if status := esp.error(mod,f10,esp.get_resp(100)) + return + mac := esp.get_str_indexed(0) + hs + mac := net_info_store(@smac,mac,1) + +pub mDNS(enable,host_name,service_name,port): status + esp.cmd_str(string("AT+MDNS=")) + send := @esp.cmd_chars_add + if 0 == enable + send(0) + else + port := esp.convert_dec_value_to_str(port) + send(enable,44,34,host_name,34,44,34,service_name,34,44,port) + esp.cmd_send() + return esp.error(mod,f12,esp.get_resp(100)) + +pub autoconnect(enable): status + esp.cmd_str(string("AT+CWAUTOCONN=")) + esp.cmd_chars_add(enable) + esp.cmd_send() + return esp.error(mod,f15,esp.get_resp(50)) + +'***************************** Smart Config *********************** + +pub start_smart_conf(type) : status + esp.cmd_str(string("AT+CWSTARTSMART=")) + esp.cmd_chars_add(type) + esp.cmd_send() + return esp.error(mod,f13,esp.get_resp(200)) + +pub stop_smart_conf() : status + esp.cmd_str(string("AT+CWSTOPSMART")) + esp.cmd_send() + return esp.error(mod,f14,esp.get_resp(50)) + +pub auto_smart_conf(type,nsec) : status | sptr + if status := start_smart_conf(type) + return + repeat nsec + status , sptr := esp.get_resp_find_str(string("WIFI GOT IP"),100) + if sptr + quit + waitms(1000) + status := esp.error(mod,f16,status) + waitms(1000) + stop_smart_conf() + waitms(1000) + +'*************************** utility ********************************** + +pub get_sta_ap_connect_info(bptr) : status + status,_,_,_ := get_sta_ip() + if status + return + status,_,_,_,_ := get_ap_connect_info() + if status + return + status,_ := get_sta_mac() + if status + return + long[bptr][0],long[bptr][1],long[bptr][2],long[bptr][3] := @ssta_ip,@smac,@sgateway,@snetmask + long[bptr][4],long[bptr][5],long[bptr][6] := @sbssid,@srssi,@schannel + +pub net_info_str(s) : p + p := s+1 + byte[p][strsize(s) - 2] := 0 + +pub net_info_store(ds,s,f) : r + bytefill(ds,0,NET_INFO_STORE_SZ) + if 1 == f + s := net_info_str(s) + bytemove(ds,s,strsize(s)) + return ds + + + + +{{ + + Terms of Use: MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice shall be included in all copies + or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE + OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +}} \ No newline at end of file diff --git a/libraries/community/p2/All/cricket_esp32_at/get_info.spin2 b/libraries/community/p2/All/cricket_esp32_at/get_info.spin2 new file mode 100644 index 00000000..cf2c503e --- /dev/null +++ b/libraries/community/p2/All/cricket_esp32_at/get_info.spin2 @@ -0,0 +1,86 @@ +' Title : Cricket ESP32 AT , Demo get info +' Purpose : Gets Firmware version , determines if BT,BLE,MQTT is supported +' Date : +' Author : mcalyer +' Requirements : esp_drv , esp_at , debug +' Terms of Use : See end +' Verison Date Change log +' 1.0 06/16/21 First release + +CON + _clkfreq = 200_000_000 + + +VAR + + +DAT + + +OBJ + + esp : "esp_drv" + at : "esp_at" + tcp : "esp_tcp" + +pub demo() | status, r1 , r2 , r3 , r4 + + ' Initialize pin usage , rx,tx,en , baud rate 115200 + status := esp.init(19,18,24,115200) + debug(if(status) , "Initilaization failed : " , uhex(status)) + + ' FW Version Info + status , r1 , r2 , r3 , r4 := at.get_ver_info() + debug(if(status) , "Get Version Info Failed : " , uhex(status)) + debug("AT version : " , zstr_(r1)) + debug("SDK version : " , zstr_(r2)) + debug("Compile time : " , zstr_(r3)) + debug("Bin version : " , zstr_(r4)) + + 'BLE Support + esp.cmd_str(string("AT+BLEINIT?")) + esp.cmd_send() + debug("BLE ", zstr_(func_check())) + + 'BT Support + esp.cmd_str(string("AT+BTINIT?")) + esp.cmd_send() + debug("BT ", zstr_(func_check())) + + 'MQTT Support + esp.cmd_str(string("AT+MQTTUSERCFG?")) + esp.cmd_send() + debug("MQTT ", zstr_(func_check())) + + +pub func_check() : s | x + x := esp.error(0,0,esp.get_resp(50)) + if x.byte[0] == 0 + s := string("supported") + elseif x.byte[1] == $09 + s := string("not supported") + else + s := string("query error") + +{{ + + Terms of Use: MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice shall be included in all copies + or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE + OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +}} \ No newline at end of file diff --git a/libraries/community/p2/All/cricket_esp32_at/led_control.html b/libraries/community/p2/All/cricket_esp32_at/led_control.html new file mode 100644 index 00000000..ef98691f --- /dev/null +++ b/libraries/community/p2/All/cricket_esp32_at/led_control.html @@ -0,0 +1,56 @@ + + + + + + +

P2 LED Control Demo

+
 
+    
+    	
+	
+
+
\ No newline at end of file
diff --git a/libraries/community/p2/All/cricket_esp32_at/meters32.html b/libraries/community/p2/All/cricket_esp32_at/meters32.html
new file mode 100644
index 00000000..4b27932d
--- /dev/null
+++ b/libraries/community/p2/All/cricket_esp32_at/meters32.html
@@ -0,0 +1,108 @@
+
+  
+     
+  
+   
+   
+   
+  
+  
+    

P2 32 Channel Voltage Monitor Demo

+
+
+
+
+ + + diff --git a/libraries/community/p2/Protocol/README.md b/libraries/community/p2/Protocol/README.md index 81af158b..4b80eb79 100644 --- a/libraries/community/p2/Protocol/README.md +++ b/libraries/community/p2/Protocol/README.md @@ -1,3 +1,5 @@ +[Cricket ESP32 AT](../All/cricket_esp32_at) + [DS1302 Full](../All/DS1302_full) [ESP 32](../All/esp32) diff --git a/libraries/community/p2/readme.md b/libraries/community/p2/readme.md index ff7332a6..b6dfc859 100644 --- a/libraries/community/p2/readme.md +++ b/libraries/community/p2/readme.md @@ -2,7 +2,7 @@ Community generated Propeller libraries for Propeller 2 microcontroller. ## Download Archive -Download an [archive of the Propeller 2 libraries](https://github.com/parallaxinc/propeller/releases/download/OBEX-210512/P2_OBEX.ZIP). +Download an [archive of the Propeller 2 libraries](https://github.com/parallaxinc/propeller/releases/download/OBEX-210622/P2_OBEX.ZIP). ## Contribute Please [contribute your objects](https://github.com/parallaxinc/propeller/wiki/Contributing) to this community archive for the benefit of all!