That code is not designed to run on the esp32. Running serial on an esp32 chip does not really make sense in terms of driving a focuser.
You do understand that the myFocuserPro2 has already been updated to the next generation using an ESP8266 or ESP32 chip, giving all the features of Bluetooth (ESP32), WiFi, ASCOM REMOTE and a host of other features, options.
myFP2ESP WiFi was not designed to work as a serial usb controller (though that is possible).
The firmware for it was designed from scratch, and now has been ported over to myFocuserPro2
myFP2ESP controllers use the same protocol commands and responses as a myFocuserPro2
So if a myFP2ESP controller is running in LOCALSERIAL mode it will talk happily over USB with the myFocuserPro2 Windows app, myFocuserPro2 ASCOM driver andpresumably the INDI driver (as I do not have a LINUX system running INDI that I cannot verify but it should).
myFocuserPro2Linux is just a Linux version of the myFocuserPro2 Windows app designed to work over a serial port connection. It does not use TCPIP
Actually, taking the existing INDI driver for myFocuserPro2, it should be able to be modified (clone and then rename to myFocuserPro2ESP?) to use TCPIP instead of serial to communicate with the myFP2ESP controller - most of the INDI code is already done, just change the serial code to use TCPIP instead. Happy to provide source code examples of Linkux TCPIP socket code talking to an myFP2ESP controller to anyone interested in coding a driver,
If the command set is the same for the TCP connection, then it might be easy by changing
setSupportedConnections(CONNECTION_SERIAL) to setSupportedConnections(CONNECTION_SERIAL | CONNECTION_TCP)
That should make it possible to choose in control panel between serial / tcp connection.
And probably a few changes to the sendcommand. (If the driver has been implemented from the skeleton)
Should be easy to emulate by just opening a listener on on the tcp port tho see how the driver sends the command. )
some update: changed that setSupportedConnections(CONNECTION_SERIAL | CONNECTION_TCP) and recompiled
then on linux used nc to do some tcp traffic on port 1026
nc -l -v 1026
from kstars configured myfocuser2 to ip adress and port 1026
Could see the the driver sending the first command (#03) but then got stuck in sending the answer.