Upcoming Games

No games to display

Full list
Add a game

Upcoming Events

No events to display

Who's Online

1960gjh, Statto, waucott, RailwayFan8, Stephen Fulcher (5 users seen recently)

Using ESP8266 / ESP32 with the Interface Gateway?

You are here: Home > Forum > Customising SimSig > Interface Gateway > Using ESP8266 / ESP32 with the Interface Gateway?

Page 1 of 1

Using ESP8266 / ESP32 with the Interface Gateway? 15/01/2023 at 21:32 #150164
DonRiver
Avatar
151 posts
Wondering if anyone's had success using an ESP8266 or ESP32 to connect to the interface gateway?

I've been using an ESP8266 and ukmaker/StompClient and making very little progress...
https://github.com/ukmaker/StompClient

Got a theory that this library relies on a websocket connection, but it needs to be a plain TCP connection…

(named for the one in Tasmania, not in Russia)
Last edited: 15/01/2023 at 22:38 by DonRiver
Reason: None given

Log in to reply
Using ESP8266 / ESP32 with the Interface Gateway? 16/01/2023 at 16:28 #150167
GeoffM
Avatar
6282 posts
DonRiver in post 150164 said:
Got a theory that this library relies on a websocket connection, but it needs to be a plain TCP connection…
I had a quick look at the source code and believe you're correct.

SimSig Boss
Log in to reply
Using ESP8266 / ESP32 with the Interface Gateway? 16/01/2023 at 17:12 #150168
DonRiver
Avatar
151 posts
I'm going to go ahead with making my own STOMP client code, probably just enough to speak to SimSig, not a full STOMP protocol implementation, and see how far I get!
(named for the one in Tasmania, not in Russia)
Log in to reply
Using ESP8266 / ESP32 with the Interface Gateway? 16/01/2023 at 20:58 #150169
DonRiver
Avatar
151 posts
ahaha

A little bit of Wireshark spelunking, comparing with known-good STOMP messages sent using stomp.py and I can now _send_ commands. The hard part was manipulating the Arduino/ESPx WiFiClient library to send a message with \0 as the final byte and there's probably a better way.

Here's the relevant snippet, somewhat elided from what's actually running on my workbench:

```
#include <ESP8266WiFi.h>

WiFiClient client = WiFiClient();
WiFi.begin("my_wifi_ssid", "my_wifi_password");
client.connect("192.168.178.36", 51515);
while (client.availableForWrite() == 0) {
delay(1);
}

String msg = String("STOMP\naccept-version:1.1\n\n");
msg += '\0';
client.write(msg.c_str(), msg.length());

msg = String("SEND\ncontent_length:43\ndestination:/topic/TD_ALL_SIG_AREA\n\n");
msg += String("{\"cc_msg\": {\"to\": \"A161\", \"descr\": \"0Z42\"}}");
msg += '\0';
client.write(msg.c_str(), msg.length());
```

Obviously this is extremely brittle, but creating functions to do this more nicely is trivial from here... the harder part will be receiving and filtering messages...

edit: I've now got nice functions for sending STOMP frames generally, sending route request and bpull messages, and connecting to SimSig with or without username+password for the payware sims. I am somewhat chuffed.

(named for the one in Tasmania, not in Russia)
Last edited: 17/01/2023 at 00:20 by DonRiver
Reason: None given

Log in to reply
Using ESP8266 / ESP32 with the Interface Gateway? 17/01/2023 at 13:50 #150172
DonRiver
Avatar
151 posts
Noticed an issue - if I update the sim via one gateway client, the sim doesn't always update other subscribed gateway clients:

Here, I update the TD berths from the ESP8266 on my tabletop, but the console client on my PC doesn't see the changes - whereas it does if I update the same berths via the SimSig UI.

I'd have put this into "Various minor issues" but it's locked...

https://youtu.be/VUun7stvWa4

(named for the one in Tasmania, not in Russia)
Log in to reply
Using ESP8266 / ESP32 with the Interface Gateway? 18/01/2023 at 02:03 #150179
DonRiver
Avatar
151 posts
I've made approximately half of a level crossing controller...
https://www.youtube.com/watch?v=1Q1Az1axdts

Edit: and another half... just two or three more halves to go :D
https://www.youtube.com/watch?v=Be1VnlWRP98

(named for the one in Tasmania, not in Russia)
Last edited: 19/01/2023 at 02:03 by DonRiver
Reason: None given

Log in to reply