Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : PicoMiteWeb alphas - It had to be done
Page 2 of 5 | |||||
Author | Message | ||||
TrevorC Newbie Joined: 15/07/2020 Location: United KingdomPosts: 14 |
Anyone else getting a Error : Not enough memory message when trying to edit a program after running it. Trying to load another program after the above error also gives the same message. I am also getting multiple ssids as above with wifi scan. PicoMite MMBasic Version 5.07.07a1 OPTION SYSTEM SPI GP18,GP19,GP16 OPTION SYSTEM I2C GP0,GP1 OPTION COLOURCODE ON OPTION LCDPANEL ILI9341, RLANDSCAPE,GP15,GP14,GP13 OPTION TOUCH GP12,GP11 GUI CALIBRATE 0, 376, 297, 888, 663 OPTION WIFI (details removed) OPTION SDCARD GP22 > memory Program: 4K ( 4%) Program (144 lines) 78K (96%) Free RAM: 0K ( 0%) 0 Variables 2K ( 1%) General 112K (99%) Free The program is a analogue clock. Setting the date and time from the internet is useful. Trevor |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 9139 |
That's an easy one to fix but I'm making no progress at all on TCP and UDP socket support so it may be some time before I post the next alpha |
||||
TrevorC Newbie Joined: 15/07/2020 Location: United KingdomPosts: 14 |
Thanks for the reply. Trevor |
||||
lizby Guru Joined: 17/05/2016 Location: United StatesPosts: 3152 |
I have to say that the prospect of TCP and UDP socket support for the Pico W is very exciting. For me, it would change the Pico from something which has been loads of fun to play with to a device that I will actually use in my household monitoring and control designs. For 15 years or more I have cobbled things together using PICAXE plus various tiny routers running OpenWrt, Raspberry Pi ZWs with Lua, and ESP8266 and ESP32 running Annex. I'd much rather use MMBasic on a Pico W. Looking forward to coming announcements. PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
homa Guru Joined: 05/11/2021 Location: GermanyPosts: 351 |
matherp i hate and love you, what great news! Because of your earlier statements I got myself an ESP-12E module. Now this runs since today and I think great, check thebackshed forum, maybe someone is interested. And now this! Thank you! And keep going ... ;-) I will test this on the weekend **joy** Edited 2023-02-02 06:52 by homa |
||||
homa Guru Joined: 05/11/2021 Location: GermanyPosts: 351 |
okay I could not wait until the weekend :) > Connecting to WiFi... Connected. PicoMiteWeb MMBasic Version 5.07.07a1 Copyright 2011-2023 Geoff Graham Copyright 2016-2023 Peter Mather > web http server open Starting server at 192.168.1.109 on port 80 > when I start the webserver and then access with ncat comes weird stuff? C:\Users\homa>ncat -n 192.168.1.109 80 ¢/í¸┘h¶┘<¿5ÕÅ*═┬@┴¤Rqjr)#░[*éêD↓0‗kú«ä═IÍâB↨þú9ôsãµ±è■!↓õuÄãçàX¦$µØ]D@ïZ#^®´ý?æ£zA↨↑rÙ♠‗毩l¥┘4¸4#♠z3pùÎR↕§~Êöòf♠#Y‗o·þý®µ½¬9┐║_Ñ▒«$üaèxEõ<Gx9GÃØ┘J»a↨;¢j§ðD[æ═_u_A©ı8■ÏZ▒/F╝Ä5*8╠*»»båuUt∟pú Ò_¥│¶z'X'k►Ï▒►Ü«8äÍ çUzúu5┐>qlä'w┴Ð┬Óûe dmt ]ç`ÌÀ]ïä6Ó╗┐ùàó ┴ZH∟╔┼ëiʬ2¤q╚ζQó♠ì↔═Ý╔·╔↑W♣g²ëöÛS¢ D▄Ñ ıúLÄöôí$t═→♦úA ↕OBÿ╦s÷¨T│ÈýÁ▲éVc{`º¬¼ßõ8Mf:▲ÀP¬g8Ó¯ÂfîGâ├d├ )╚o▀x♠©ä◄îü→È-4¬h¼vrüçï+Z/&¥Ìý┐8¡░▀ú ró*L«wÃè┐}┼▼Ã↑D↑ý_f±£j└Ï0MO:►└Í{ax,Ô♣Î,ä╔¬Ï--▒áÔTú═♠☺c‼o►ëDûM´┬d‗┤G×Ç]wâB→↓×↓¨¡NÒ→►U┐êSÅê³►:ŹéSå↕^ 2╝♠È° └¤►È↔5·╬N-↨☺xÃ÷♣î(®ì;¾[¬¾W♦ä¿~s~ÁÐ!]5Ù)P┴X♠´.DÆz↑╗BÂUtÁ è╦ZHè┘c»¶ Iç╗├çëEIÇþ▒ÃY╔Q ëÐ¥Íû‼ÿ_³■Ú!╬¢YoB@┼FHI$qÝs"×↨Û@säû►»á┤àH«Ñj♠↕L§@│ÚWQïsÀã½│╠╗■Î9Qhm╬]áZ÷ð«▓?o╬ o>kï+!▀*a╚;×gçƯ→Ê é¶1ø÷'A5¡Úà▬ÙE´cÐÑáÔ2& Qåêï¾→B«£Àu┼§H┐ÆìY‗sBÁÿ▲îëoYò$├└rq█Q@dXN¥¶▀ÀóåØK┤☻ìÂÊÐ♥ÌW¶┴☻õÃ6rıuºïKM ù╠ä0½▄×ä»;◄a╔èÝ´ôñ╠↔*¢Ò Y→{ÀéÃ♣¹→ÉOéé╩Ö2m┤i#q▬ñ8´1jbï┌¶Ô²♣ú▓║ñ"+ÿf6│Ò¶ñ¬♥^JtË┤░jï♣↨→Ƶ┘ÖªrM£R³YA∟▲äS=BíÛ¸♣↨ƒ╚ß²B½+íÅã×╦(Ý-╠▲°‼┌þ3■qü¹├nòKæj∟æ‼Ñâ?¹│1ý╝ެú®┴ÒH↕C→{P/LuÅ3.²±J) Ë┌I╗Þ´F¢Ú7V&=↓ÀoëNÉ┐¶U[│Û▬NåSn(Õ↓=jö↑┘╣(│i{█ "!õÏ∟A│_³Ó6fBÝ╗÷â>Yè→P¨Ia‼░¬OJ│]╣§k6¥d6èÂâ╝x☺VÁB²ƒÔB¡ðØD^Äd7Àç]*Ê┬╔^┌Þû^┬▒b*°úÚè;─RI?`< ñ▒]×)ñKð ┬²e)z¦N¥n¬ÂÂbÚ»♦7£¬├▬`Z┬'¯┬¤4♥{P±©│▼´¶çX▄ ÐN╬üaWuﶴÈ~ò─ѧkaBc¡Ýª▼▒╔▓pt[ BP*<\þ┼♥6bw├6╝UB↨MQ¨uÜ´¨|Õ→BntX£hE↔»ú}ò¬ ù¯59N╔`xÇ┼±.E│g↕$£^♦©çÖbÐ═↑Ï└ !}m▲K©!U;ZW³×i‼iòWÂ█f‗Ûdw┌┤kKA2↕o│ª¨ò¯☺4╗Ì►ì►▓Áæ■┤gæþ°♦êpè─♦LÙÖ‼I¶b░¨ÈÆÄéÄ3g▒;Aúÿ↕÷↓fIàI■¤o¶╩ô↕╗£ôÑÆöKÀùxpá┘i.→ ¾Ó│☺ÕÔ§s╚ÍïC¦qõ3=║X>qá↔┘┴[ÝÿAîλzÛQ± ☺.΃¤▒┴G¦·¼é╚U«µ─7|╔K¸)ò▄}¿ı♠3¿SéyòºÆ©HOu☺{BamD░,Èk±ýg"►GÙÔZ↓ú╠■õ]©mò% X┼¨╠ÀaÚ█m↔N┴í┐↑Ëd@5↔J ÞíúJ─î▲=fj☻ryb♠╦%¯²½§'ö¢Ôp&Û↓U│Ú╔·¾8á|µQı╠B3W if I call the ip in the browser opens the save as dialog?! in this file is also only grit. do you have any ideas, matherp, about which commands to implement and how? it would be helpful to query the ip assigned via dhcp with a command and or on startup after Connected: <ipadr>. Edited 2023-02-02 07:32 by homa |
||||
led-bloon Senior Member Joined: 21/12/2014 Location: AustraliaPosts: 205 |
@matherp - Peter Does this code/site help at all? benevpi or picow-http led Edited 2023-02-02 09:33 by led-bloon Miss you George |
||||
TrevorC Newbie Joined: 15/07/2020 Location: United KingdomPosts: 14 |
Just noticed that Web ntp response prints date and time correctly but the month is not being being updated in date$. Trevor |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 9139 |
Finally some progress - note the Pi icon at the top left responding to the favicon request Dim buff%(512) Dim ls%(64) Dim s$=Space$(255) LongString append ls%(),"<!doctype html>" LongString append ls%(),"<HTML>" LongString append ls%(),"<BODY>" LongString append ls%(),"<H1>Hello World!</H1>" LongString append ls%(),"</BODY>" LongString append ls%(),"</HTML>" LongString append ls%(),Chr$(10)+Chr$(13) WEB open tcp server 80 WEB tcp interrupt myint WEB ntp Do 'background processing Loop Sub myint WEB tcp read buff%() If LLen(buff%())=0 Then Exit Sub Local p%=LInStr(buff%(),"GET") Local t%=LInStr(buff%(),"HTTP") If (p%<>0) And (t%<>0) And (t%>p%) Then s$=LGetStr$(buff%(),p%,t%-p%+4) Print "String is ",s$ EndIf If Instr(s$,"favicon") Then Print "sending icon" WEB Transmit FILE "pi.ico","image/vnd.microsoft.icon" Else Print "sending page" WEB tcp send ls%() WEB TCP close EndIf End Sub I'll post a new release when I've got the code that reads an html file in and automatically populates screen fields with the values of MMbasic variables. This is code from the original PiCromite which can finally make a re-appearance Edited 2023-02-03 01:59 by matherp |
||||
Plasmamac Guru Joined: 31/01/2019 Location: GermanyPosts: 554 |
Great Plasma |
||||
lizby Guru Joined: 17/05/2016 Location: United StatesPosts: 3152 |
Fabulous. PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
Pluto Guru Joined: 09/06/2017 Location: FinlandPosts: 359 |
Dont know what I am going to use it for, but after understanding that Matherp is developing something for Pico W, I immediately ordered a few. No hurry with the development Peter, I have still to wait a couple of weeks for arrival of the W |
||||
homa Guru Joined: 05/11/2021 Location: GermanyPosts: 351 |
hello Peter, i tried running your code with version 5.07.07a1 on my original pi pico w. Unfortunately the setup as in your screenshot does not work for me! Do you have another version? I also have a pi.ico file on the flash drive. Will there also be a way to manage tcp connections yourself? As with the ESP-12E module? There you can manage up to 5 connections. How does that actually look with the pico w? According to Internet data, it can manage up to 4 clients as a SoftAP. Does that mean that up to 4 client accesses to the pico w are feasible? Would it make sense to use the AT commands of the ESP-12E module as a basis for the WEB command? In any case the testing is fun. And I can help you here with pleasure. The attempts 1-6 are actually self-explanatory ... Greetings from rainy Germany Matthias |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6102 |
To quote Peter: You have to wait for the new alpha release for the new example code to run. Jim VK7JH MMedit MMBasic Help |
||||
homa Guru Joined: 05/11/2021 Location: GermanyPosts: 351 |
The EDGE web browser also has this behavior of wanting to download a file ... but the program behaves differently! |
||||
homa Guru Joined: 05/11/2021 Location: GermanyPosts: 351 |
Thanks Jim, I had understood this sentence differently. Matthias |
||||
homa Guru Joined: 05/11/2021 Location: GermanyPosts: 351 |
Hello Peter, now you've made my mouth water. The wait is getting me down. Is there any news? Or can you say something about my questions? Greetings Matthias |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 9139 |
Here is a version to play with - what a bu..er this was getting working. Even now it is less than robust - it may never be completely robust. PicoMiteWeb.zip New command: OPTION TCP SERVER PORT n This is a permanent option and launches a TCP server on the defined port (Use 80 for the example) during every restart of the PicoMiteWeb USE "OPTION TCP SERVER PORT 0" to disable When the server is running it can respond to up to MM.INFO(MAX CONNECTIONS) connections at the same time - currently set to 4. This was the difficult bit to get working as browsers all seem to be different in the way they use connections and do or do-not expect them to be open. Here is a simple example HTTP host Dim buff%(512) Dim myfloat!=16.123 Dim myint%=999 Dim mystring$="The PicoMite Web is GO!!!" WEB ntp Do poll Loop ' Sub poll Local p%, t% For a%=1 To mm.info(max connections) LongString clear buff%() WEB tcp read a%,buff%() p%=LInStr(buff%(),"GET") t%=LInStr(buff%(),"HTTP") If LLen(buff%()) Then Print "_________________________________________________" s$="" If (p%<>0) And (t%<>0) And (t%>p%) Then s$=LGetStr$(buff%(),p%,t%-p%+4) Print "String is ",s$ EndIf If Instr(s$,"small") Then Print "sending picture" WEB Transmit FILE a%,"small.jpg","image/jpeg" ElseIf Instr(s$,"favicon") Then Print "sending icon" WEB Transmit FILE a%,"favicon.ico","image/vnd.microsoft.icon" ElseIf Instr(s$,"HTTP") Then Print "sending page" WEB transmit page a%,"test4.html" EndIf Next a% End Sub and here is the HTML file. NB: the base64 string must be converted to a single line and then xmodemed to the PicoMiteWeb. This string is the PicoMiteWeb icon. <html> <head> <title>PicoMiteWeb Test</title> <link rel="icon" type="image/x-icon" sizes="16x16" href="data:image/png;base64,AAA BAAEAEBAQAAEABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAA AAAAP//ADMA/wD/AAQAFf8AAAIACABZAP8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAFAAUAVQBVAAUABQUABQBQBVAFBQAFAFAFBQAAVQBVAAUFBQAAAAAABVAAAAAAAAAAAAAAA AAAACREMzERAAAAJkRDMxEQAAAmZEQzMREAAAZmREMzERAAAGZkRDMxEQAABmZEQzMREAAAZmREMzERAAA GZkRDMxH//wAAuzMAALrtAACa7QAArzMAAKv/AACf/wAA//8AAAA/AAAAHwAAAA8AAIAHAADAAwAA4AEAA PAAAAD4AAAA" /> </head> <body> <h1>{mystring$}</h1> This is a paragraph. Test of a float: myfloat is {myfloat!} Test of an integer: myint is {myint%} Test of a string: mystring is {DateTime$(now)} Test of a missing variable: missing is {missing} </body> </html> Here are the supporting images small.zip I'll now try and explain the new functionality WEB TRANSMIT CODE cb%,nnn% Constructs and sends a numerical response to the open connection cb% and on completion closes the connection. Typical use would be “TRANSMIT CODE cb%, 404” to indicate page not found. WEB TRANSMIT FILE cb%, filename$, content-type$ This constructs an HTTP 1.1 header with the ’content-type$’ specified, sends it and then sends the contents of the file to the open connection cb% and on completion closes the connection WEB TRANSMIT PAGE cb%, filename$ This constructs an HTTP 1.1 header sends it and then sends the contents of the file to the open connection cb% and on completion closes the connection MMBasic will substitute current values for any MMBasic variables or expressions defined in the file inside curly brackets e.g. {myvar%} Variables can be simple, array elements or expressions as in the example. An opening curly bracket can be included in the output by using {{. When you run a program with the TCP server enabled the firmware will automatically create a receive buffer of 2048 bytes for each of the 4 possible connections. Your Basic program should poll these receive buffers using the command WEB TCP READ cb%, buff%() cb% is the open connection and buff%() is an array to receive any data from that connection as a longstring If there is nothing received on that connection this will return an empty string LLEN(buff%())=0 If there is, then the Basic program must respond with one of the TRANSMIT commands in order to close the connection There is more functionality that I need to test further that enables the TCP server to be used as one end of an open link. I will then look at the commands for a TCP client - should be easier. Getting this working to the extent that it is has cost me three full days of my life so don't expect a further update too soon ISSUES: I believe it is possible for a browser to send connection requests and the associated data faster than the TCP stack on the Pico can respond. In this case you are left with a dangling connection as the Basic program doesn't know about it. This needs further work. Various error conditions are not handled so be prepared for lockups and have the reset button handy Sequencing is important - don't connect a client before you have a handler running. Below is a Basic subroutine for parsing GET requests - came from a Pi-Cromite example but not retested - use or abuse as you wish Const maxargs = 32 Dim arg$(1,maxargs-1) 'Function to parse an HTML GET request' ' Assumes that the request starts with "GET /" ' and ends with "HTTP" ' Function parserequest$(req$, paramcount As integer) Local a$,b$ Local integer inpos,startparam,processargs For inpos=0 To maxargs-1 arg$(0,inpos)="" arg$(1,inpos)="" Next inpos paramcount=0 a$=Mid$(req$,6,Len(req$)-10) inpos=Instr(a$,"?") If inpos<>0 Then 'parameters found processargs=1 parserequest$=Left$(a$,inpos-1) a$=Mid$(a$,inpos+1) Do arg$(0,paramcount)="" arg$(1,paramcount)="" inpos=Instr(a$,"=") startparam=1 arg$(0,paramcount)=Mid$(a$,startparam,inpos-startparam) startparam=inpos+1 inpos=Instr(a$,"&") If inpos<>0 Then arg$(1,paramcount)=Mid$(a$,startparam,inpos-startparam) a$=Mid$(a$,inpos+1) paramcount=paramcount+1 Else arg$(1,paramcount)=Mid$(a$,startparam) paramcount=paramcount+1 processargs=0 EndIf Loop While processargs Else parserequest$=a$ EndIf If a$="" Then parserequest$="index" EndIf If Instr(parserequest$,".html")=0 And Instr(parserequest$,".HTML")=0 Then parserequest$=parserequest$+".html" End Function Edited 2023-02-05 23:22 by matherp |
||||
homa Guru Joined: 05/11/2021 Location: GermanyPosts: 351 |
Thanks a lot Peter! @all: Attention- the new version also deletes the flash disk! I just lost the test file from me because of my impatience. Not too bad, but if someone has more on it ... just as a hint! |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 9139 |
Just noticed the BB has corrupted the html even though it is in a code block test4.zip |
||||
Page 2 of 5 |
Print this page |