Photon unable to connect to cloud and continuously restarting

Hello!

So just recently I started having issues connecting to the cloud with two of my photons. I’m working on code using TCP and I don’t rely on the cloud for anything during operation, so I’m running in SEMI-AUTOMATIC mode and just going into safe mode to reflash the photons from particle dev. Now when I put the photons into safe mode they spend a while blinking cyan and occasionally restart. It’s the slower blinking pattern like the photon is looking for the cloud, not the faster flashing that occurs during the handshake as I understand it. I might be completely wrong about what those two patterns mean :stuck_out_tongue:

This bug appeared after flashing and running the code I’ve included below. To try and fix this, so far I’ve set up CLI and reflashed the boards with tinker using particle flash --usb tinker and I’ve also tried particle setup and particle setup wifi with no luck at all. I tried updating the keys on the board, but I’m actually struggling with a weird bug on my PC and OpenSSL so I can’t seem to get those commands to run. Any help would be greatly appreciated!

Edit: I figured out my issue with OpenSSL and I have the key commands working. I tried running particle keys doctor deviceID, but I’m still getting the same issue and I can’t ever connect to the cloud.

#define ENCODER_TAG 'E'
#define TOGGLE_TAG  'T'
#define END_BYTE    '!'
#define ASK         '?'

SYSTEM_MODE(SEMI_AUTOMATIC)
//Declare our server and client objects
TCPServer server(79);
TCPClient client;

//Here we have the IP address for the other photon we're communication with and
//it's port number.
byte console_IP[4] = {192,168,11,100};
byte pod_IP[4]  = {192,168,11,102};
int console_Port = 78;
int pod_Port  = 80;

char incomingParam = 0x00;

uint8_t consoleBuff[2] = {TOGGLE_TAG, 0x00};
uint8_t domeBuff[4]    = {ENCODER_TAG, 0x00, TOGGLE_TAG, 0x00};
uint8_t podBuff[2]     = {ENCODER_TAG, 0x00};

void setup() {
//This is here to set a static IP which needs to only happen once

//Static IP's should only be configured once, and then I can just use them
//as I understand it, however I needed to set up the IP address on the
//new photon after the current one stopped connecting to the cloud
WiFi.off();
IPAddress myAddress(192,168,11,101);
IPAddress netmask(255,255,255,0);
IPAddress gateway(192,168,1,1);
IPAddress dns(192,168,1,1);
WiFi.setStaticIP(myAddress, netmask, gateway, dns);
WiFi.useStaticIP();

WiFi.on();
WiFi.connect();

//We need to wait for wifi before we can start the TCP server
waitUntil(WiFi.ready);

//Start listening for clients
server.begin();

//Start up serial so we can communicate various commands
Serial.begin(9600);
Serial1.begin(115200);
//Hold still and check wifi until we're connected over serial
while(!Serial.available()) Particle.process();
Serial.print("Sup guys! I'm the DOME");

//Print out wifi credentials, just to make sure everything is ok
Serial.print("Local IP: ");
Serial.println(WiFi.localIP());
Serial.print("Subnet Mask: ");
Serial.println(WiFi.subnetMask());
Serial.print("gateway IP: ");
Serial.println(WiFi.gatewayIP());
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
}

void loop() {

//If we're not connected
if(!client.connected())
{
    //Listen for a client
    client = server.available();
    //If we found one, tell it our IP and then run our coms functions
    if (client.connected())
    {
        client.remoteIP().printTo(Serial);  // prints the IP of the remote client
        consoleComs();
        teensyComs()
    }
}
}

void consoleComs()
{
    if(client.available())
    {
        incomingParam = client.read();
        while(incomingParam != END_BYTE)
        {
            switch(incomingParam)
            {
                case ENCODER_TAG:
                    domeBuff[1] = client.read();
                    break;

            case TOGGLE_TAG:
                domeBuff[3] = client.read();
                break;

            case ASK:
                client.write(consoleBuff, 2);
                client.write(podBuff, 2);
                client.write(END_BYTE);
                break;
        }
        incomingParam = client.read();
    }
}
client.stop();
}

void teensyComs()
{
    Serial1.write(domeBuff, 4);
    delay(5);
    Serial1.write(ASK);
    Serial1.write(END_BYTE);
if(Serial1.available())
{
    incomingParam = Serial1.read();
    while(incomingParam != END_BYTE)
    {
        switch(incomingParam)
        {
            case ENCODER_TAG:
                podBuff[1] = client.read();
                break;

            case TOGGLE_TAG:
                consoleBuff[1] = client.read();
                break;
        }
        incomingParam = Serial1.read();
    }
}
}