Particle.connect() not connecting to cloud on electron

I’m running with a persistent issue on my electrons (I have 4). All of them has to be offline unless there is a throwed alarm. When the alarm is fired, the electron has to connect to particle cloud, but all of them keeps breathing cyan indefinitelly.

Courious thing is that if I put the electrons in DFU mode, the connection to the particle cloud is done with no problems.

I tried to run particle doctor to regenerate the keys but the issue persist.

Any one of you guys are experimenting something like this ? Would be something with my particle account ?

Can you post some code? If not, what system mode are you running? and do you have system threading enabled or not?

When you say it connects to cloud OK in DFU mode (yellow), do you actually mean safe mode (magenta)?

2 Likes

I’m sorry for the missing details. Currently I’m using the blink app, which connects automatically to the cloud. Also, when I put the device in DFU mode (yellow), the device connects to the cloud with no problems.

That's highly unlikely since in DFU Mode the device is not supposed to connect to WiFi at all - let alone to the cloud.
How did you establish the fact that the device connects to the cloud in DFU Mode?

BTW, it's not clear what your issue actually is.

You expect the device to connect to the cloud, but then you are puzzled when the device keeps breathing cyan. But that breathing cyan is exactly the singal that the device has connected to the cloud and still is, so where is the problem?
So clearly Particle.connect() works, otherwise the LED would not be breathing cyan.

1 Like

Oh, I see the misunderstanding … the led blinks fast (not breathing as I wrote). The DFU mode connects to the cloud (breathing magenta) due I can see the connection event on the particle console.

When I run the blink sketch, the electron flashes fast cyan and never get connected. If I change the blink sketch to:


SYSTEM_MODE(SEMI_AUTOMATIC);
SYSTEM_THREAD(ENABLED);

int led1 = D0; // Instead of writing D0 over and over again, we'll write led1
int led2 = D7; // Instead of writing D7 over and over again, we'll write led2

void setup() {

    Cellular.on();
    Particle.connect();
    
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);

}

void loop() {
  digitalWrite(led1, HIGH);
  digitalWrite(led2, HIGH);

  delay(1000);

  digitalWrite(led1, LOW);
  digitalWrite(led2, LOW);

  delay(1000);
}


Also the behavior is the same … never connects to the cloud.

Now you have me confused again :confused:

@ninjatill already pointed out that breathing magenta is not DFU Mode but Safe Mode, but then you doubled down on the DFU Mode assertion here

and now you admit it's actually breathing magenta

With this kind of inconsitent info it's virtually impossible to advise.

However just to clarify some things

  • Are you using the original Particle SIM?
  • What Device OS version have you got on your device and are you targeting?
  • Can you post the output of particle serial inspect (in Listening Mode - blinking blue)?
  • How does the device behave with the blink sketch in SYSTEM_MODE(AUTOMATIC) withouth Cellular.on() and Particle.connect()?
  • Are there any other colors (e.g. short red/orange bursts) mixed in during the cyan blinking phase?
  • Try this
void setup() {
  Cellular.on();
  Cellular.connect();
  waitUntil(Cellular.ready);
  Particle.connect();
  waitUntil(Particle.connected);
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
}
1 Like

I’m sorry for the confusing redaction, I’m trying a bunch of things.

  • I’m not using particle SIM, I’m using virgin sim, which in MX is the same infra that particle SIM uses (telefonica).
  • The version I’m using is 0.8.0-rc.8 and also 0.7.0
  • This is the output of inspect:
Platform: 10 - Electron
Modules
  Bootloader module #0 - version 201, main location, 16384 bytes max size
    Integrity: PASS
    Address Range: PASS
    Platform: PASS
    Dependencies: PASS
  System module #1 - version 309, main location, 131072 bytes max size
    Integrity: PASS
    Address Range: PASS
    Platform: PASS
    Dependencies: PASS
      System module #3 - version 309
  System module #2 - version 309, main location, 131072 bytes max size
    Integrity: PASS
    Address Range: PASS
    Platform: PASS
    Dependencies: PASS
      System module #1 - version 309
      Bootloader module #0 - version 201
  System module #3 - version 309, main location, 131072 bytes max size
    Integrity: PASS
    Address Range: PASS
    Platform: PASS
    Dependencies: PASS
      System module #2 - version 110
  User module #1 - version 3, main location, 131072 bytes max size
    UUID: 6B38BF10BE92BA40717E91F2F0B68BA1310A96CA8E61F89F68753B4D06BA84F8
    Integrity: PASS
    Address Range: PASS
    Platform: PASS
    Dependencies: PASS
      System module #2 - version 10
  empty - factory location, 131072 bytes max size

This is a video running the tests to avoid more confusion.

With a 3rd party sim you need to set Particle.keepAlive() to fit the contract. The default 23 minutes keep alive time is a setting that was specifically negotiated for Particle with all the cell providers. So even if you are using the same infrastructure not all contracts feature the same backend settings.
And even if the connection works at time of development it’s not wise to rely on the current status that you can connect to the network without setting the correct credentials - that might change some time from now and break your product.

With 0.7.0 you need to re-set the keep alive after each and every reconnect. With 0.8.0-rc.4 onwards it should only be required once in STARTUP().

I did it as well with the same results:

SYSTEM_MODE(SEMI_AUTOMATIC);
SYSTEM_THREAD(ENABLED);

int led1 = D0; // Instead of writing D0 over and over again, we'll write led1

int led2 = D7; // Instead of writing D7 over and over again, we'll write led2

void setup() {

  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);

    Particle.keepAlive(1 * 60);

    Cellular.on();
    Cellular.connect();
    Particle.connect();

}

void loop() {

  digitalWrite(led1, HIGH);
  digitalWrite(led2, HIGH);


  delay(1000);


  digitalWrite(led1, LOW);
  digitalWrite(led2, LOW);


  delay(1000);

}

I reduced the ping from 23 to 1 in my tests with no good results.

If this red blink is a signal for a keys issue, you can try this in DFU Mode (yellow blinking)

particle keys server
particle keys doctor <youDeviceID>

Try flashing this cloud-debug code and see what the output is or post it here.

Thanks for the respones. I had flashed the firmware with these results:

0000077568 [system] TRACE: sparkSocket Now =-1
0000077571 [system] INFO: Read Server Address = type:1,domain:$id.udp.particle.io
0000077571 [system] INFO: Read Server Address = type:1,domain:$id.udp.particle.io
    77.571 AT send      56 "AT+UDNSRN=0,\"2c004b000351373330393736.udp.particle.io\"\r\n"
    77.583 AT read  +   28 "\r\n+UDNSRN: \"52.87.113.144\"\r\n"
    77.594 AT read OK    6 "\r\nOK\r\n"
0000077596 [system] INFO: Resolved host 2c004b000351373330393736.udp.particle.io to 52.87.113.144
0000077596 [system] INFO: Resolved host 2c004b000351373330393736.udp.particle.io to 52.87.113.144
socketSocket(UDP)
    77.596 AT send      18 "AT+USOCR=17,5684\r\n"
    77.607 AT read  +   13 "\r\n+USOCR: 0\r\n"
    77.617 AT read OK    6 "\r\nOK\r\n"
Socket 0: handle 0 was created
0000077618 [system] TRACE: socketed udp=1, sparkSocket=0, 1
0000077618 [system] TRACE: connection attempt to 52.87.113.144:5684
0000077619 [system] INFO: Cloud socket connected
0000077619 [system] INFO: Cloud socket connected
0000077620 [system] INFO: Starting handshake: presense_announce=0
0000077620 [system] INFO: Starting handshake: presense_announce=0
0000077621 [comm.protocol.handshake] INFO: Establish secure connection
0000077621 [comm.protocol.handshake] INFO: Establish secure connection
0000077631 [comm.dtls] TRACE: restore size mismatch 1: 0/220
0000077632 [comm.dtls] INFO: (CMPL,RENEG,NO_SESS,ERR) restoreStatus=2
0000077632 [comm.dtls] INFO: (CMPL,RENEG,NO_SESS,ERR) restoreStatus=2
0000077634 [system] TRACE: send 115
socketSendTo(0,52.87.113.144,5684,,115)
    77.633 AT send      37 "AT+USOST=0,\"52.87.113.144\",5684,115\r\n"
    77.645 AT read  >    3 "\r\n@"
    77.695 AT send     115 "\x16\xfe\xfd\x00\x00\x00\x00\x00\x00\x00\x00\x00f\x01\x00\x00Z\x00\x00\x00\x00\x00\x00\x00Z\xfe\xfd\xd1\xdf\x80{\\\xfd\xe0\f\x86\"k_\x15/A\xdb;)\xd6\r\xe5\xef\xbb\xc4B\x90\x9b\xf8\x17\x98k\xf7\x00\x00\x00\x04\xc0\xae\x00\xff\x01\x00\x00,\x00\r\x00\x0e\x00\f\x04\x03\x04\x01\x03\x03\x03\x01\x02\x03\x02\x01\x00\n\x00\x04\x00\x02\x00\x17\x00\v\x00\x02\x01\x00\x00\x13\x00\x02\x01\x02\x00\x14\x00\x02\x01\x02"
    77.840 AT read  +   17 "\r\n+USOST: 0,115\r\n"
    77.850 AT read OK    6 "\r\nOK\r\n"
    77.850 AT send      14 "AT+USORF=0,0\r\n"
    77.861 AT read  +   15 "\r\n+USORF: 0,0\r\n"
Socket 0: handle 0 has 0 bytes pending
    77.871 AT read OK    6 "\r\nOK\r\n"
0000080642 [system] TRACE: send 115
socketSendTo(0,52.87.113.144,5684,,115)
    80.641 AT send      37 "AT+USOST=0,\"52.87.113.144\",5684,115\r\n"
    80.652 AT read  >    3 "\r\n@"
    80.702 AT send     115 "\x16\xfe\xfd\x00\x00\x00\x00\x00\x00\x00\x01\x00f\x01\x00\x00Z\x00\x00\x00\x00\x00\x00\x00Z\xfe\xfd\xd1\xdf\x80{\\\xfd\xe0\f\x86\"k_\x15/A\xdb;)\xd6\r\xe5\xef\xbb\xc4B\x90\x9b\xf8\x17\x98k\xf7\x00\x00\x00\x04\xc0\xae\x00\xff\x01\x00\x00,\x00\r\x00\x0e\x00\f\x04\x03\x04\x01\x03\x03\x03\x01\x02\x03\x02\x01\x00\n\x00\x04\x00\x02\x00\x17\x00\v\x00\x02\x01\x00\x00\x13\x00\x02\x01\x02\x00\x14\x00\x02\x01\x02"
    80.857 AT read  +   17 "\r\n+USOST: 0,115\r\n"
    80.867 AT read OK    6 "\r\nOK\r\n"
    80.867 AT send      14 "AT+USORF=0,0\r\n"
    80.877 AT read  +   15 "\r\n+USORF: 0,0\r\n"
Socket 0: handle 0 has 0 bytes pending
    80.887 AT read OK    6 "\r\nOK\r\n"
mbedtls/library/ssl_tls.c:2330: handshake timeout
mbedtls/library/ssl_tls.c:3986: mbedtls_ssl_fetch_input() returned -26624 (-0x6800)
mbedtls/library/ssl_tls.c:3901: mbedtls_ssl_read_record_layer() returned -26624 (-0x6800)
mbedtls/library/ssl_cli.c:1540: mbedtls_ssl_read_record() returned -26624 (-0x6800)
0000086889 [comm.dtls] ERROR: handshake failed -6800
0000086889 [comm.dtls] ERROR: handshake failed -6800
0000086890 [comm.protocol.handshake] ERROR: handshake failed with code 17
0000086890 [comm.protocol.handshake] ERROR: handshake failed with code 17
0000086891 [system] WARN: Cloud handshake failed, code=17
0000086891 [system] WARN: Cloud handshake failed, code=17
0000087142 [system] INFO: Cloud: disconnecting
0000087142 [system] INFO: Cloud: disconnecting
0000087142 [system] TRACE: Close Attempt
socketClose(0)
    87.141 AT send      12 "AT+USOCL=0\r\n"
    87.412 AT read OK    6 "\r\nOK\r\n"
socketFree(0)
0000087413 [system] TRACE: socket_close()=success
0000087413 [system] INFO: Cloud: disconnected
0000087413 [system] INFO: Cloud: disconnected

Indeed, the handshake couldn’t be done, but I ran particle keys as you suggest :

New Key Created!
Saved!
Saved!
attempting to add a new public key for device XXX
submitting public key succeeded!
Okay!  New keys in place, your device should restart.

and the results are the same :

0000088595 [system] INFO: Cloud: connecting
0000088595 [system] INFO: Cloud: connecting
0000088595 [system] TRACE: sparkSocket Now =-1
0000088598 [system] INFO: Read Server Address = type:1,domain:$id.udp.particle.io
0000088598 [system] INFO: Read Server Address = type:1,domain:$id.udp.particle.io
    88.598 AT send      56 "AT+UDNSRN=0,\"2c004b000351373330393736.udp.particle.io\"\r\n"
    88.620 AT read  +   28 "\r\n+UDNSRN: \"52.87.113.144\"\r\n"
    88.631 AT read OK    6 "\r\nOK\r\n"
0000088633 [system] INFO: Resolved host 2c004b000351373330393736.udp.particle.io to 52.87.113.144
0000088633 [system] INFO: Resolved host 2c004b000351373330393736.udp.particle.io to 52.87.113.144
socketSocket(UDP)
    88.633 AT send      18 "AT+USOCR=17,5684\r\n"
    88.643 AT read  +   13 "\r\n+USOCR: 0\r\n"
    88.653 AT read OK    6 "\r\nOK\r\n"
Socket 0: handle 0 was created
0000088654 [system] TRACE: socketed udp=1, sparkSocket=0, 1
0000088654 [system] TRACE: connection attempt to 52.87.113.144:5684
0000088655 [system] INFO: Cloud socket connected
0000088655 [system] INFO: Cloud socket connected
0000088656 [system] INFO: Starting handshake: presense_announce=0
0000088656 [system] INFO: Starting handshake: presense_announce=0
0000088657 [comm.protocol.handshake] INFO: Establish secure connection
0000088657 [comm.protocol.handshake] INFO: Establish secure connection
0000088667 [comm.dtls] TRACE: restore size mismatch 1: 0/220
0000088668 [comm.dtls] INFO: (CMPL,RENEG,NO_SESS,ERR) restoreStatus=2
0000088668 [comm.dtls] INFO: (CMPL,RENEG,NO_SESS,ERR) restoreStatus=2
0000088670 [system] TRACE: send 115
socketSendTo(0,52.87.113.144,5684,,115)
    88.670 AT send      37 "AT+USOST=0,\"52.87.113.144\",5684,115\r\n"
    88.681 AT read  >    3 "\r\n@"
    88.731 AT send     115 "\x16\xfe\xfd\x00\x00\x00\x00\x00\x00\x00\x00\x00f\x01\x00\x00Z\x00\x00\x00\x00\x00\x00\x00Z\xfe\xfd\xbf\x9a\xe9\xabO\x17\xe0O:\x01\xd0\xcdq\x1fA\xb4\x91\xd6\xe6\xdb\xa0\xd2G\xbcJ\xaf\xb9;\x83\xd5\x97\r\x00\x00\x00\x04\xc0\xae\x00\xff\x01\x00\x00,\x00\r\x00\x0e\x00\f\x04\x03\x04\x01\x03\x03\x03\x01\x02\x03\x02\x01\x00\n\x00\x04\x00\x02\x00\x17\x00\v\x00\x02\x01\x00\x00\x13\x00\x02\x01\x02\x00\x14\x00\x02\x01\x02"
    88.886 AT read  +   17 "\r\n+USOST: 0,115\r\n"
    88.896 AT read OK    6 "\r\nOK\r\n"
    88.896 AT send      14 "AT+USORF=0,0\r\n"
    88.907 AT read  +   15 "\r\n+USORF: 0,0\r\n"
Socket 0: handle 0 has 0 bytes pending
    88.917 AT read OK    6 "\r\nOK\r\n"
0000091678 [system] TRACE: send 115
socketSendTo(0,52.87.113.144,5684,,115)
    91.677 AT send      37 "AT+USOST=0,\"52.87.113.144\",5684,115\r\n"
    91.688 AT read  >    3 "\r\n@"
    91.738 AT send     115 "\x16\xfe\xfd\x00\x00\x00\x00\x00\x00\x00\x01\x00f\x01\x00\x00Z\x00\x00\x00\x00\x00\x00\x00Z\xfe\xfd\xbf\x9a\xe9\xabO\x17\xe0O:\x01\xd0\xcdq\x1fA\xb4\x91\xd6\xe6\xdb\xa0\xd2G\xbcJ\xaf\xb9;\x83\xd5\x97\r\x00\x00\x00\x04\xc0\xae\x00\xff\x01\x00\x00,\x00\r\x00\x0e\x00\f\x04\x03\x04\x01\x03\x03\x03\x01\x02\x03\x02\x01\x00\n\x00\x04\x00\x02\x00\x17\x00\v\x00\x02\x01\x00\x00\x13\x00\x02\x01\x02\x00\x14\x00\x02\x01\x02"
    91.892 AT read  +   17 "\r\n+USOST: 0,115\r\n"
    91.902 AT read OK    6 "\r\nOK\r\n"
    91.902 AT send      14 "AT+USORF=0,0\r\n"
    91.912 AT read  +   15 "\r\n+USORF: 0,0\r\n"
Socket 0: handle 0 has 0 bytes pending
    91.922 AT read OK    6 "\r\nOK\r\n"

mbedtls/library/ssl_tls.c:2330: handshake timeout
mbedtls/library/ssl_tls.c:3986: mbedtls_ssl_fetch_input() returned -26624 (-0x6800)
mbedtls/library/ssl_tls.c:3901: mbedtls_ssl_read_record_layer() returned -26624 (-0x6800)
mbedtls/library/ssl_cli.c:1540: mbedtls_ssl_read_record() returned -26624 (-0x6800)
0000097925 [comm.dtls] ERROR: handshake failed -6800
0000097925 [comm.dtls] ERROR: handshake failed -6800
0000097926 [comm.protocol.handshake] ERROR: handshake failed with code 17
0000097926 [comm.protocol.handshake] ERROR: handshake failed with code 17
0000097926 [system] WARN: Cloud handshake failed, code=17
0000097926 [system] WARN: Cloud handshake failed, code=17
0000098177 [system] INFO: Cloud: disconnecting
0000098177 [system] INFO: Cloud: disconnecting
0000098177 [system] TRACE: Close Attempt
socketClose(0)
    98.176 AT send      12 "AT+USOCL=0\r\n"
    98.447 AT read OK    6 "\r\nOK\r\n"
socketFree(0)
0000098448 [system] TRACE: socket_close()=success
0000098448 [system] INFO: Cloud: disconnected
0000098448 [system] INFO: Cloud: disconnected