Attached is my slightly modified code from the Ethernet configuration page
// SAMPLE APPLICATION
#include "Particle.h"
SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(SEMI_AUTOMATIC);
Serial1LogHandler log1Handler(115200, LOG_LEVEL_ALL);
SerialLogHandler LogHandler(LOG_LEVEL_ALL);
uint8_t resetRetry = 0;
void setup() {
waitFor(Serial.isConnected, 10000);
#if HAL_PLATFORM_WIFI && !HAL_PLATFORM_WIFI_SCAN_ONLY
// To force Ethernet only, clear Wi-Fi credentials
Log.info("Clear Wi-Fi credentionals...");
WiFi.clearCredentials();
#endif // HAL_PLATFORM_WIFI && !HAL_PLATFORM_WIFI_SCAN_ONLY
// Disable Listening Mode if not required
if (System.featureEnabled(FEATURE_DISABLE_LISTENING_MODE)) {
Log.info("FEATURE_DISABLE_LISTENING_MODE enabled");
} else {
Log.info("Disabling Listening Mode...");
System.enableFeature(FEATURE_DISABLE_LISTENING_MODE);
}
Log.info("Checking if Ethernet is on...");
uint8_t macAddrBuf[8] = {};
uint8_t* macAddr = Ethernet.macAddress(macAddrBuf);
if (macAddr != nullptr) {
Log.info("Ethernet MAC: %02x %02x %02x %02x %02x %02x",
macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4], macAddr[5]);
}
else {
Log.info("Ethernet MAC is null");
}
if (Ethernet.isOn()) {
Log.info("Ethernet is on");
Ethernet.connect();
waitFor(Ethernet.ready, 30000);
Log.info("Ethernet.ready: %d", Ethernet.ready());
resetRetry = 0;
} else if (++resetRetry <= 3) {
Log.info("Ethernet is off or not detected, attmpting to remap pins: %d/3", resetRetry);
if_wiznet_pin_remap remap = {};
remap.base.type = IF_WIZNET_DRIVER_SPECIFIC_PIN_REMAP;
remap.cs_pin = PIN_INVALID; // default
remap.reset_pin = PIN_INVALID; // default
remap.int_pin = PIN_INVALID; // default
auto ret = if_request(nullptr, IF_REQ_DRIVER_SPECIFIC, &remap, sizeof(remap), nullptr);
if (ret != SYSTEM_ERROR_NONE) {
Log.error("Ethernet GPIO config error: %d", ret);
} else {
if (System.featureEnabled(FEATURE_ETHERNET_DETECTION)) {
Log.info("FEATURE_ETHERNET_DETECTION enabled");
} else {
Log.info("Enabling Ethernet...");
System.enableFeature(FEATURE_ETHERNET_DETECTION);
}
delay(500);
System.reset();
}
}
Particle.connect();
}
void loop() {
static system_tick_t lastPublish = millis();
static int count = 0;
static bool reconnect = false;
if (Particle.connected()) {
reconnect = false;
if (millis() - lastPublish >= 10000UL) {
Particle.publish("mytest", String(++count), PRIVATE, WITH_ACK);
lastPublish = millis();
}
}
// Detect a network dropout and reconnect quickly
if (!reconnect && !Ethernet.ready()) {
Log.info("Particle disconnect...");
Particle.disconnect();
waitFor(Particle.disconnected, 5000);
Log.info("Network disconnect...");
Network.disconnect();
Particle.connect();
reconnect = true;
}
}
I have modified it slightly to add the waitFor the USB serial, and also to test for the MAC address every boot. Since I'm using the default pins, I set the pin-remap to PIN_INVALID as noted in the docs. I also removed the retained memory bit since it ties 3 times, fails to remap, then never tries again.
Heres the extent of the output:
---- Opened the serial port COM36 ----
0000005504 [app] INFO: Clear Wi-Fi credentionals...
0000005521 [app] INFO: FEATURE_DISABLE_LISTENING_MODE enabled
0000005538 [app] INFO: Checking if Ethernet is on...
0000005553 [app] INFO: Ethernet MAC is null
0000005565 [app] INFO: Ethernet is off or not detected, attmpting to remap pins: 1/3
0000005591 [app] INFO: FEATURE_ETHERNET_DETECTION enabled
---- Closed serial port COM36 due to disconnection from the machine ----
---- Opened the serial port COM36 ----
0000002153 [app] INFO: Clear Wi-Fi credentionals...
0000002170 [app] INFO: FEATURE_DISABLE_LISTENING_MODE enabled
0000002188 [app] INFO: Checking if Ethernet is on...
0000002203 [app] INFO: Ethernet MAC is null
0000002215 [app] INFO: Ethernet is off or not detected, attmpting to remap pins: 1/3
0000002241 [app] INFO: FEATURE_ETHERNET_DETECTION enabled
---- Closed serial port COM36 due to disconnection from the machine ---
Can I expect the Photon 2 to get the MAC address from the module without being connected to a network? I am connected to a switch and activity lights are flashing on the Adafruit device, but unsure what conclusions can be drawn from that.
Here's the breadboard setup to show that it's pretty bare bones.
Appreciate any sanity check on this!
Going to try to use the adafruit lib that only uses bare SPI. If I can get that talking then it must be something with the RST/IRQ pins.