Comments (7)
Maybe you could check if an ip address is associated (using wifi-ip, softap-ip) to the esp or not. But keep in mind that these words create and return a newly allocated string each time. So it's not a good idea to use them in a loop unless doing some extra memory housekeeping.
In the esp-open-rtos there is a function called sdk_wifi_station_get_connect_status().
But currently this is not exposed as a forth word.
from punyforth.
Thanks for info, zeroflag. I wondered if I had just not seen something. I think just doing a loop around the netcon-connect until it works is good enough for my purpose.
A related issue I am chasing right now is that netcon reads do not seem to time out. I can see a value being set in netcon-new, as follows:
: netcon-new ( type -- netcon | throws:ENETCON ) override netcon-new dup 0= if ENETCON throw then RECV_TIMEOUT_MSEC over netcon-set-recvtimeout ;
but I've had netcon-readln wait for hours - at least I think so. I am still struggling with keeping track of multiple tasks on 2 ESP8266s attempting to co-operate. My brain gets very full sometimes (most times?). Well, the co-operation part was not too hard, but handling comms failures is doing my head in. Sometimes just figuring out which end of the comms screwed up is hard and I spend hours poking around the wrong code before I get a clue. I keep learning, but sometimes there's a few steps back before I get to go forward again.
Many thanks again for your help.
from punyforth.
A related issue I am chasing right now is that netcon reads do not seem to time out.
This is quite possible and looks like a bug (or a missing feature). The purpose of RECV_TIMEOUT_MSEC is not to block the running tasks (threads) by the one that waits for the data. The word read-ungreedy executes a pause (which yields control to an other task) when timeout occurs then retries forever. So RECV_TIMEOUT_MSEC is an internal timeout, but there should be an other timeout to be able to exit this loop. This is missing right now, thanks for letting me know.
I'm going to try to fix this in the weekends.
from punyforth.
I added option to specify global read timeots on netcon sockets.
10 read_timeout_sec ! \ set read timeout to 10 seconds
or
-1 read_timeout_sec ! \ -1 indicates no timeout
The netcon-read and netcon-readln throws ERTIMEOUT exception when a timeout occurs.
from punyforth.
Many thanks for timeout. I'd missed reading the internal timeout in read-ungreedy. Time for me to have another go.
from punyforth.
Probably it would be better to be able to set the read timeout on individual connections instead of globally. So this may change in the future.
from punyforth.
Please note that I replaced the global timeout with an individual timeout per netcon.
\ words for setting and getting the socket level timeout
netcon-read-timeout! ( read-timeout-in-seconds netconn -- )
netcon-read-timeout@ ( netconn -- read-timeout-in-seconds )
\ example
variable: socket
PORT HOST TCP netcon-connect socket !
60 socket @ netcon-read-timeout! ( set the timeout of this socket to 60 seconds )
socket @ netcon-read-timeout@ . cr ( print out the timeout )
from punyforth.
Related Issues (20)
- Complete word list with usage HOT 2
- Just for fun
- Mistype in README.md HOT 1
- A new fast flash utility HOT 1
- An interesting bug in the example dht22-data-loger or in netcon?
- highbit HOT 6
- Seriously? Python?
- Contributions HOT 2
- Convert flash.py to python3 HOT 1
- Flash starts but doesn't finish properly HOT 5
- Different speeds for multiple motors
- Word Glossary I have written HOT 3
- TASKS - when restarting a task, the data and return stack are not empty HOT 1
- Connected but no sending from the terminal HOT 1
- port on ESP-01 ? HOT 1
- Can TCP REPL eval be replicated using just strings? HOT 2
- TCP-REPL triggers ESP8266 Restart? HOT 3
- Receiving binary data via UDP
- This line should be.... .int xt_drop2
- Feature request: forth repl on tcp/ip or i2c HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from punyforth.