You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to periodically power the cellular module and then shut it down again to save energy. But when I detach it after sending data via a UDP socket, the device becomes unresponsive When it turns on for the second time (when detaching asynchronously) it returns at the AT+CPIN? command. I then get the response Not connected, retying from the function connectToNetwork(). It then indefinetly tries again to open a connection but it doesn't work.
Edit: Removed everything from the code not necessary to replicate this behaviour. Also I added a generous 1 mF of capacitors which greatly improved stability.
It now takes an unknown amount of time to disconnect from the network using gprs.detachGPRS(true); (in synchronous mode). As soon as I have sent the first bytes.
#include<MKRNB.h>
#include<RTCZero.h>// initialize the library instance
NBClient client;
GPRS gprs;
NB nbAccess(true);
NBUDP udp;
RTCZero rtcZero;
voidconnectToNetwork(){
auto connected = false;
Serial.println(F("init..."));
while (!connected)
{
if ((nbAccess.begin("", "hologram", true, true) == NB_READY) &&
(gprs.attachGPRS() == GPRS_READY))
{
connected = true;
}
else
{
Serial.println(F("Not connected, retying"));
delay(200);
}
}
}
voiddisconnectFromNetwork(){
Serial.println(F("Disconnecting from network"));
//////////////////////////////////////////////////////////////////////
gprs.detachGPRS(true); // here the module stops responding indefinetly
nbAccess.secureShutdown();
}
voidsetup()
{
Serial.begin(9600);
// set timeconnectToNetwork();
rtcZero.setEpoch(nbAccess.getTime());
disconnectFromNetwork();
// endless event loopwhile (true)
{
Serial.println(F("New interation"));
// do some measurements here every couple hours// every day connect to the network and upload themconnectToNetwork();
if (udp.begin(80))
{
Serial.println("udp socket opened");
// make a udp request (i know this wouldn't work but for this example it is sufficient)
udp.beginPacket("example.com", 80);
// todo send multiple packets if one packet exceeds 300bytes
udp.write("17 bytes of data", 17);
udp.endPacket();
udp.stop();
}
else
{
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
disconnectFromNetwork();
}
}
voidloop() { }
The response of the device when debug is enabled (and detatching is async) on the second connection is:
init...
AT
OK
AT
OK
AT+CMEE=0
OK
AT+CFUN=0
OK
AT+CPIN?
+CPIN: READY
OK
and after that it just stops.
The text was updated successfully, but these errors were encountered:
I want to periodically power the cellular module and then shut it down again to save energy. But when I detach it after sending data via a UDP socket, the device becomes unresponsive When it turns on for the second time (when detaching asynchronously) it returns at the
AT+CPIN?
command. I then get the responseNot connected, retying
from the functionconnectToNetwork()
. It then indefinetly tries again to open a connection but it doesn't work.Edit: Removed everything from the code not necessary to replicate this behaviour. Also I added a generous 1 mF of capacitors which greatly improved stability.
It now takes an unknown amount of time to disconnect from the network using gprs.detachGPRS(true); (in synchronous mode). As soon as I have sent the first bytes.
The response of the device when debug is enabled (and detatching is async) on the second connection is:
and after that it just stops.
The text was updated successfully, but these errors were encountered: