Server status JSON
- Pep
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 33
- Thank you received: 8
7 years 6 months ago #10707
by Pep
Replied by Pep on topic Server status JSON
Thanks for the tip UTurista! And thanks for the other suggestions notabear and lespyd!
I've managed to get it working with UDP on gamespy port.
Now just need some time (might have some tomorrow) to parse the variables I want and connect a OLED display (And maybe one day some nixie tubes) and I'll manage to make my HOG server status checker!
Sorry to ask again, but is 1000ms between requests not really a big load on the server? last thing I want is to in any way mess with server performance (Is the only one where I play).
Here is the code as it is at the moment:
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
const char* ssid = "yourwifissid";
const char* password = "yourpassword";
const byte ip[]={64,237,49,109}; //HOG IP
WiFiUDP Udp;
unsigned int localUdpPort = 50377; // local port to listen on
unsigned int RemoteUdpPort = 29901; //gamespy port for HOG
char incomingPacket[255]; // buffer for incoming packets
byte protC[] = {0xFE, 0xFD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x08, 0x05, 0x00, 0x00}; // Just requesting number of players and map name
void setup()
{
Serial.begin(115200);
Serial.println();
Serial.printf("Connecting to %s ", ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println(" connected");
Udp.begin(localUdpPort);
Serial.printf("Now listening at IP %s, UDP port %d\n", WiFi.localIP().toString().c_str(), localUdpPort);
}
void loop()
{
Serial.println("Sending packet");
Udp.beginPacket(ip, RemoteUdpPort);
Udp.write(protC,12); // change 12 to the number of bytes sent (if requesting more data)
Udp.endPacket();
Serial.println("Packet sent");
delay(500); //waiting for a reply
int packetSize = Udp.parsePacket();
if (packetSize)
{
// receive incoming UDP packets
Serial.printf("Received %d bytes from %s, port %d\n", packetSize, Udp.remoteIP().toString().c_str(), Udp.remotePort());
int len = Udp.read(incomingPacket, 255);
if (len > 0)
{
incomingPacket[len] = 0;
String myData = "";
for(int i = 0; i < 22; i++) {
myData += (char)incomingPacket;
}
Serial.println(myData);
}
}
delay(5000); //waiting 5 secs for a new request
}
I've managed to get it working with UDP on gamespy port.
Now just need some time (might have some tomorrow) to parse the variables I want and connect a OLED display (And maybe one day some nixie tubes) and I'll manage to make my HOG server status checker!
Sorry to ask again, but is 1000ms between requests not really a big load on the server? last thing I want is to in any way mess with server performance (Is the only one where I play).
Here is the code as it is at the moment:
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
const char* ssid = "yourwifissid";
const char* password = "yourpassword";
const byte ip[]={64,237,49,109}; //HOG IP
WiFiUDP Udp;
unsigned int localUdpPort = 50377; // local port to listen on
unsigned int RemoteUdpPort = 29901; //gamespy port for HOG
char incomingPacket[255]; // buffer for incoming packets
byte protC[] = {0xFE, 0xFD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x08, 0x05, 0x00, 0x00}; // Just requesting number of players and map name
void setup()
{
Serial.begin(115200);
Serial.println();
Serial.printf("Connecting to %s ", ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println(" connected");
Udp.begin(localUdpPort);
Serial.printf("Now listening at IP %s, UDP port %d\n", WiFi.localIP().toString().c_str(), localUdpPort);
}
void loop()
{
Serial.println("Sending packet");
Udp.beginPacket(ip, RemoteUdpPort);
Udp.write(protC,12); // change 12 to the number of bytes sent (if requesting more data)
Udp.endPacket();
Serial.println("Packet sent");
delay(500); //waiting for a reply
int packetSize = Udp.parsePacket();
if (packetSize)
{
// receive incoming UDP packets
Serial.printf("Received %d bytes from %s, port %d\n", packetSize, Udp.remoteIP().toString().c_str(), Udp.remotePort());
int len = Udp.read(incomingPacket, 255);
if (len > 0)
{
incomingPacket[len] = 0;
String myData = "";
for(int i = 0; i < 22; i++) {
myData += (char)incomingPacket;
}
Serial.println(myData);
}
}
delay(5000); //waiting 5 secs for a new request
}
- Pep
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 33
- Thank you received: 8
7 years 6 months ago - 7 years 6 months ago #10717
by Pep
Replied by Pep on topic Server status JSON
It works!
Here are some photos:
Booting and connecting to local wifi (+-2 secs)
Running (Yes, was just me on the server at that time, changed from 0 to 1 when map was loading at 5%)
Display is really small (.91 inches 128x32) but enough to read.
To do:
This is exactly what I wanted, simple, cheap (5-10$) and easy server status check but I guess one could add other features.
- Maybe a rotary switch to show different data from the server: (Team score, (My) player K/D, etc)
- Warning message or red led on if Jevsky is online - "WARNING! Follow the rules" - My honest thanks to him (and other admins) for keeping this server playable.
- Would love to make a clock+HOG server checker with some nixie tubes and a retro look. Not for now...maybe on my summer vacations.
If anyone wants to make a similar project , I can share the current code.
Thanks for the help! I'll keep it to 5 secs but if this loads the sever tell me and I won't use it or increase the time.
Here are some photos:
Booting and connecting to local wifi (+-2 secs)
Running (Yes, was just me on the server at that time, changed from 0 to 1 when map was loading at 5%)
Display is really small (.91 inches 128x32) but enough to read.
To do:
This is exactly what I wanted, simple, cheap (5-10$) and easy server status check but I guess one could add other features.
- Maybe a rotary switch to show different data from the server: (Team score, (My) player K/D, etc)
- Warning message or red led on if Jevsky is online - "WARNING! Follow the rules" - My honest thanks to him (and other admins) for keeping this server playable.
- Would love to make a clock+HOG server checker with some nixie tubes and a retro look. Not for now...maybe on my summer vacations.
If anyone wants to make a similar project , I can share the current code.
Thanks for the help! I'll keep it to 5 secs but if this loads the sever tell me and I won't use it or increase the time.
Last edit: 7 years 6 months ago by Pep. Reason: just changed the photo
The following user(s) said Thank You: =HOG=Ruiz321
- Deleted
- Offline
- Administrator
Less
More
- Posts: 2421
- Thank you received: 723
7 years 6 months ago #10721
by Deleted
Replied by Deleted on topic Server status JSON
Nifty! Makes me want to go create something like a button that orders pizza to my house now.
- Pep
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 33
- Thank you received: 8
7 years 6 months ago #10733
by Pep
Replied by Pep on topic Server status JSON
It can be done! (I bet someone already did it)
As long your usual pizza "provider" has a web ordering page it can be done.
Maybe you are joking but in fact not much different of Amazon Dash Buttons .
Make it simple with just one button (A big red one) or with switches to select toppings, pizza type and drinks and a display to show how many you ordered last month.
Pizza+PR sounds like a good combination!
As long your usual pizza "provider" has a web ordering page it can be done.
Maybe you are joking but in fact not much different of Amazon Dash Buttons .
Make it simple with just one button (A big red one) or with switches to select toppings, pizza type and drinks and a display to show how many you ordered last month.
Pizza+PR sounds like a good combination!
- Arphis
- Offline
- New Member
Less
More
- Posts: 5
- Thank you received: 1
7 years 6 months ago #10740
by Arphis
Replied by Arphis on topic Server status JSON
Off Topic: Everquest 2 used to have /pizza as a console command, which was connected to Domino's ( !?!? ) i think.
Pep, this is awesome. At first i thought of it to be a bit "over-the-top" then all the stuff people made with Arduinos came to my mind, so it's relatively sane :: )
It needs changing colors for "30 ppl, heavy assets allowed" and "70 players online its actually playable, oh wait 40 of them are from that other server, DONT JOIN"
Pep, this is awesome. At first i thought of it to be a bit "over-the-top" then all the stuff people made with Arduinos came to my mind, so it's relatively sane :: )
It needs changing colors for "30 ppl, heavy assets allowed" and "70 players online its actually playable, oh wait 40 of them are from that other server, DONT JOIN"
Time to create page: 0.128 seconds