-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow decoupling of hardware transport and LocoNet protocol #31
base: master
Are you sure you want to change the base?
Conversation
- LOCONET_NO_SW_UART allows complete decoupling of hardware transport and LocoNet protocol - LOCONET_NO_EEPROM turns off access of EERPOM
Great change, I have immediately tested, works fine |
|
@kiwi64ajs: would be nice to integrate this code change. Thank you! |
@@ -55,6 +55,21 @@ | |||
// figure out what board we are building | |||
|
|||
// Common defines | |||
|
|||
// turn off EEPROM for platforms not currenty implemented |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you doing a #define LOCONET_NO_EEPROM by default for each of these platforms when they have a EEPROM emulation in FLASH already?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because EEPROM support is only implemented for STM32F1, ESP8266 and AVR.
EEPROM is by default off for all other platforms, and may additionally turned off for ESP8266, STM and AVR
#endif | ||
#endif | ||
|
||
// turn off Software UART for platforms not currenty implemented |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also seems wrong to #define LOCONET_NO_SW_UART by default when there clearly is a Bit-Bashed Software UART for these platforms. I don't understand why you want to do this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above, as software UART is only implemented for STM32F1, ESP8266 and AVR.
Why I want to do this: e.g. when using the library on an ESP32 or Raspberry PICO you may implement the transport channel on your own.
I'm using it on an ESP32 with LOCONET via a bluetooth serial port (works great) and also via TCP/IP socket (virtual serial port on PC forwarding communication to a socket).
I'll do a refinement of the pre-processor defaults with another suggestion |
By setting the new define LOCONET_NO_SW_UART the library internal serial communication is turned off.
Instead an integrator may now use a communication channel of his choice.
A new method addToBuffer(uint8_t newByte) allows the integrator so forward data from the transport channel to LocoNet instance, and an external callback function bool sendRawLocoNet(uint8_t val) is called by the library to output data to the transport channel.
I also added an example called LocoNetMonitorESP32TCP which runs on an ESP32. Its a clone of the Monitor example. It turns on Wifi and creates a TCP server socket at LocoNetServer.local:1001. Application like Rocrail can directly connect to the device via network. In Rocrail configure Interface "LocoNet", Device "LocoNetServer.local:1001", Typ LocoBuffer, Uncheck CTS Flow.
With an ESP32 also a Bluetooth serial could be a communication channel, or more easy just the usage of e.g. Serial2 for LocoNet communication.
How could Serial2 be used?
Your done.
Another change in this commit is the possibility to disable EEPROM support.
This is done by setting the preprocessor definiton LOCONET_NO_EEPROM