Can't find UDP socket callbacks

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
User avatar
dbalnaves
Posts: 7
Joined: Thu Jan 05, 2017 12:53 pm

Can't find UDP socket callbacks

Post by dbalnaves » Thu Jan 05, 2017 1:34 pm

Hi Everyone,

I'm using prebuilt esp8266-20161110-v1.8.6.bin

I'd like to use the callbacks on a UDP socket as those described here:
http://docs.micropython.org/en/latest/p ... ocket.html

Unfortunately, I don't seem to be able to find callbacks in 1.8 for esp8266.

I've tried building my own firmware from github ('v1.4.5-2716-gffe807f on 2017-01-05'). I found this version does appear to support callbacks (as part of socket). In this version, I see other modules (such as umqtt) appears to be missing. I'm assuming that v1.4.5 is development, but it's equally possible I don't really understand how git/versioning works properly.

Could somebody please help me to understand the state of support for callbacks on the esp8266? Is this in development, deprecated or am I simply looking in the wrong place?

Any help with understanding the significance of the versioning (ie: 1.4 vs 1.8) or the current state of socket callbacks would be much appreciated.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Can't find UDP socket callbacks

Post by Roberthh » Sat Jan 07, 2017 7:51 am

Unfortunately, I don't seem to be able to find callbacks in 1.8 for esp8266.
Tho one's you cite are for PyBoard only. For ESP, there is a not-yet-documented callback mechanism, which I use for sockets. It might work for UDP too. A code fragment would look like:

Code: Select all

import socket
_SO_REGISTER_HANDLER = const(20)

mysocket = socket.socket(.....) # whatever you set it up
mysocket.setsockopt(socket.SOL_SOCKET, _SO_REGISTER_HANDLER, callback_function) # register callback

def callback_function(mysocket):
    .....
    .....
I hope this method will persist. It looks a little bit provisional.

User avatar
dbalnaves
Posts: 7
Joined: Thu Jan 05, 2017 12:53 pm

Re: Can't find UDP socket callbacks

Post by dbalnaves » Thu Jan 26, 2017 4:27 am

Hi Roberthh,

Thanks for the excellent reply - since reading it appears I have been retracing your steps.

I found your posts here:
viewtopic.php?t=2496

I'm equally curious why the literal value '20' has been used, one of the first hits I found when following your lead was webrepl.

I tried to go through esp-open-sdk and in particular lwip to understand if a similar option exists for UDP. I'm ashamed to say that I had a lot of trouble following the code once lwip_setsockopt_internal started setting options via sock->conn and then gave up. Did you ever find an answer to your question?

Post Reply