Skip to content

Commit

Permalink
m5atom client fixes
Browse files Browse the repository at this point in the history
Updated WiFI AP to use 3 bytes of mac address
Updated to use 3 bytes of  mac address in device name
Added define to build with or without camber number during pvw and pgm
Updated ReadMe
  • Loading branch information
Jocke4f committed Feb 1, 2024
1 parent 6e4845e commit 7212073
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 21 deletions.
7 changes: 4 additions & 3 deletions listener_clients/M5AtomMatrix-listener/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ Done! Now your board is running the latest listener client firmware version. Go
# Setup your device
1. Plug the device in a power source
2. Wait for the boot animation to finish, if there is no saved AP it will start an Access Point where you can configure one.
3. Connect to the 'm5Atom-1xxxxxxx' access point via phone and go to 192.168.4.1 (or wait a bit, and captive portal page should open).
3. Connect to the 'm5Atom-XXXXXX' Access Point via phone and go to 192.168.4.1 (or wait a bit, a captive portal page should open). NB: The portal times out after 120 sec of inactivity.
4. Set your Tally Arbiter server ip by going to *"Setup"* page.
5. Go back, then go to the "Configure WiFi" page and set your WiFi credentials. The board should reboot.
6. If the connection is successful a WiFi animation and a green tick mark will show. If not a red cross will be shown and you can reboot the device to try again.

* If you need to reset WI-FI credentials. Press Atom button for 5 seconds.

Button (behind screen):
Single click - Toggle between camera number 1 to 16.
Long press 5 seconds - reset WiFi credentials.

# Troubleshooting
### macOS build error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include <Preferences.h>
#define DATA_PIN_LED 27

#define SHOW_CAMERA_NUMBER_DURING_PVW_AND_PGM false

//M5 variables
PinButton btnAction(39); //the "Action" button on the device
Preferences preferences;
Expand All @@ -38,8 +40,8 @@ IPAddress stationMask = IPAddress(255, 255, 255, 0);
//Local Default Camera Number. Used for local display only - does not impact function. Zero results in a single dot displayed.
int camNumber = 0;

// Name of the device - the serial number of the listener hardware will be appended to create a unique identifier for the server.
String listenerDeviceName = "m5Atom-1";
// Name of the device - the 3 last bytes of the mac address will be appended to create a unique identifier for the server.
String listenerDeviceName = "m5Atom-";

//M5atom Access Point Password
//minimum of 8 characters
Expand Down Expand Up @@ -309,8 +311,8 @@ void setDeviceName(){
preferences.putString("deviceid", DeviceId);
preferences.end();
logger("-------------------------------------------------", "info-quiet");
logger("DeviceName:" + String(DeviceName), "info-quiet");
logger("DeviceId:" + String(DeviceId), "info-quiet");
logger("DeviceName: " + String(DeviceName), "info-quiet");
logger("DeviceId: " + String(DeviceId), "info-quiet");
logger("-------------------------------------------------", "info-quiet");
}

Expand Down Expand Up @@ -349,9 +351,12 @@ void evaluateMode() {
int currColor[] = {backgroundColor, numbercolor};
logger("Current color: " + String(backgroundColor), "info");
//logger("Current camNumber: " + String(camNumber), "info");
#if SHOW_CAMERA_NUMBER_DURING_PVW_AND_PGM
// If you want the camera number displayed during Pgm and Pvw, uncomment the following line and comment the line after.
// drawNumber(number[camNumber], currColor);
drawNumber(number[camNumber], currColor);
#else
drawNumber(icons[12], currColor);
#endif
} else {
drawNumber(number[camNumber], offcolor);
}
Expand All @@ -375,6 +380,7 @@ void evaluateMode() {
digitalWrite (led_aux, LOW);
}
#endif

logger("Device is in " + actualType + " (color " + actualColor + " priority " + String(actualPriority) + ")", "info");
// This is a hack to compensate for the Matrix needing GRB.
logger(" r: " + String(g) + " g: " + String(r) + " b: " + String(b), "info");
Expand Down Expand Up @@ -613,6 +619,9 @@ void processTallyData() {
evaluateMode();
}

WiFiManagerParameter* custom_taServer;
WiFiManagerParameter* custom_taPort;

void connectToNetwork() {
// allow for static IP assignment instead of DHCP if stationIP is defined as something other than 0.0.0.0
#if staticIP == 1
Expand All @@ -623,18 +632,17 @@ void connectToNetwork() {
#endif

WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP

logger("Connecting to SSID: " + String(WiFi.SSID()), "info");

//reset settings - wipe credentials for testing
//wm.resetSettings();

//add TA fields
WiFiManagerParameter custom_taServer("taHostIP", "Tally Arbiter Server", tallyarbiter_host, 40);
WiFiManagerParameter custom_taPort("taHostPort", "Port", tallyarbiter_port, 6);
custom_taServer = new WiFiManagerParameter("taHostIP", "Tally Arbiter Server", tallyarbiter_host, 40);
custom_taPort = new WiFiManagerParameter("taHostPort", "Port", tallyarbiter_port, 6);

wm.addParameter(&custom_taServer);
wm.addParameter(&custom_taPort);
wm.addParameter(custom_taServer);
wm.addParameter(custom_taPort);

wm.setSaveParamsCallback(saveParamCallback);

Expand Down Expand Up @@ -738,10 +746,15 @@ void setup() {
//Save battery by turning off BlueTooth
btStop();

uint64_t chipid = ESP.getEfuseMac();
listenerDeviceName = "m5Atom-" + String((uint16_t)(chipid>>32)) + String((uint32_t)chipid);
// Append last three pairs of MAC to listenerDeviceName to make it some what unique
byte mac[6]; // the MAC address of your Wifi shield
WiFi.macAddress(mac);
listenerDeviceName = listenerDeviceName + String(mac[3], HEX) + String(mac[4], HEX) + String(mac[5], HEX);
logger("Listener device name: " + listenerDeviceName, "info");

// Set WiFi hostname
wm.setHostname ((const char *) listenerDeviceName.c_str());

M5.begin(true, false, true);
delay(50);
M5.dis.drawpix(0, 0xf00000);
Expand Down Expand Up @@ -836,25 +849,23 @@ void loop(){
// Switch action below
if (camNumber < 16){
camNumber++;
drawNumber(number[camNumber], offcolor);
} else {
camNumber = 0;
drawNumber(number[camNumber], offcolor);
}

drawNumber(number[camNumber], offcolor);

// Lets get some info sent out the serial connection for debugging
logger("", "info-quiet");
logger("---------------------------------", "info-quiet");
logger("Button Pressed.", "info-quiet");
logger("M5Atom IP Address: " + String(WiFi.localIP()), "info-quiet");
logger("M5Atom IP Address: " + WiFi.localIP().toString(), "info-quiet");
logger("Tally Arbiter Server: " + String(tallyarbiter_host), "info-quiet");
logger("Device ID: " + String(DeviceId), "info-quiet");
logger("Device Name: " + String(DeviceName), "info-quiet");
logger("Cam Number: " + String(camNumber), "info-quiet");
logger("---------------------------------", "info-quiet");
logger("", "info-quiet");
}

// Is WiFi reset triggered?
if (M5.Btn.pressedFor(5000)){
wm.resetSettings();
ESP.restart();
Expand Down

0 comments on commit 7212073

Please sign in to comment.