Giter Club home page Giter Club logo

Comments (7)

zeroflag avatar zeroflag commented on May 28, 2024

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().

https://github.com/SuperHouse/esp-open-rtos/blob/7c702d7f09f4f810144a17ae3d0ebd110ee77599/tests/cases/04_wifi_basic.c#L124

But currently this is not exposed as a forth word.

from punyforth.

RigTig avatar RigTig commented on May 28, 2024

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.

zeroflag avatar zeroflag commented on May 28, 2024

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.

zeroflag avatar zeroflag commented on May 28, 2024

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.

RigTig avatar RigTig commented on May 28, 2024

Many thanks for timeout. I'd missed reading the internal timeout in read-ungreedy. Time for me to have another go.

from punyforth.

zeroflag avatar zeroflag commented on May 28, 2024

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.

zeroflag avatar zeroflag commented on May 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.