Skip to content

Commit 8b09e9c

Browse files
committed
Merge branch 'develop' into provision/force-ca-validation
2 parents 9473884 + b133d9f commit 8b09e9c

File tree

7 files changed

+38
-31
lines changed

7 files changed

+38
-31
lines changed

Jenkinsfilek8s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545
stage('install-libraries') {
4646
steps {
47+
sh 'arduino-cli core update-index --additional-urls "http://drazzy.com/package_drazzy.com_index.json"'
4748
sh 'arduino-cli core install --additional-urls "http://drazzy.com/package_drazzy.com_index.json" DxCore:megaavr'
4849
sh 'arduino-cli lib install ArduinoJson'
4950
sh 'arduino-cli lib install "Adafruit GPS Library"'

examples/http_get_time/http_get_time.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void setup() {
4747
HttpResponse response;
4848
response = HttpClient.get(TIMEZONE_URI);
4949
if (response.status_code != HttpClient.STATUS_OK) {
50-
Log.errorf("Error when performing a GET request on %s/%s. Got status "
50+
Log.errorf("Error when performing a GET request on %s%s. Got status "
5151
"code = %d. Exiting...\r\n",
5252
TIMEZONE_URL,
5353
TIMEZONE_URI,

examples/mqtt_with_connection_loss_handling/mqtt_with_connection_loss_handling.ino

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,9 @@ void setup() {
9999
}
100100

101101
Lte.onDisconnect(disconnectedFromNetwork);
102+
102103
MqttClient.onConnectionStatusChange(connectedToBroker,
103104
disconnectedFromBroker);
104-
105-
SequansController.begin();
106-
107-
SequansController.writeCommand("at+cmee=2");
108105
}
109106

110107
/**

src/log.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ void LogClass::infof(const char* format, ...) {
9090

9191
va_start(ap, nFormat);
9292
vfprintf(&f, nFormat, ap);
93+
va_end(ap);
9394
}
9495
}
9596

@@ -116,6 +117,7 @@ void LogClass::debugf(const char* format, ...) {
116117
fdev_set_udata(&f, this->uart);
117118
va_start(ap, nFormat);
118119
vfprintf(&f, nFormat, ap);
120+
va_end(ap);
119121
}
120122
}
121123

@@ -131,6 +133,7 @@ void LogClass::rawf(const char* format, ...) {
131133
fdev_set_udata(&f, this->uart);
132134
va_start(ap, format);
133135
vfprintf(&f, format, ap);
136+
va_end(ap);
134137
}
135138

136139
void LogClass::error(const char str[]) {
@@ -155,6 +158,7 @@ void LogClass::errorf(const char* format, ...) {
155158
fdev_set_udata(&f, this->uart);
156159
va_start(ap, nFormat);
157160
vfprintf(&f, nFormat, ap);
161+
va_end(ap);
158162
}
159163
}
160164

@@ -180,6 +184,7 @@ void LogClass::warnf(const char* format, ...) {
180184
fdev_set_udata(&f, this->uart);
181185
va_start(ap, nFormat);
182186
vfprintf(&f, nFormat, ap);
187+
va_end(ap);
183188
}
184189
}
185190

src/log.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,42 @@ enum class LogLevel { NONE = 0, ERROR, WARN, INFO, DEBUG };
77

88
class LogClass {
99
private:
10-
UartClass *uart;
10+
UartClass* uart;
1111
LogLevel log_level;
1212

13-
void print(const char *str, const char level[]);
13+
void print(const char* str, const char level[]);
1414

1515
public:
16-
LogClass(UartClass *uart);
16+
LogClass(UartClass* uart);
1717

18-
void setOutputUart(UartClass *uart);
18+
void setOutputUart(UartClass* uart);
1919

2020
void setLogLevel(const LogLevel log_level);
21-
bool setLogLevelStr(const char *log_level);
21+
bool setLogLevelStr(const char* log_level);
2222
LogLevel getLogLevel();
2323

2424
void begin(const uint32_t baud_rate);
2525
void end();
2626

2727
void error(const char str[]);
2828
void error(const String str);
29-
void errorf(const char *format, ...);
29+
void errorf(const char* format, ...);
3030

3131
void warn(const char str[]);
3232
void warn(const String str);
33-
void warnf(const char *format, ...);
33+
void warnf(const char* format, ...);
3434

3535
void info(const char str[]);
3636
void info(const String str);
37-
void infof(const char *format, ...);
37+
void infof(const char* format, ...);
3838

3939
void debug(const char str[]);
4040
void debug(const String str);
41-
void debugf(const char *format, ...);
41+
void debugf(const char* format, ...);
4242

4343
void raw(const char str[]);
4444
void raw(const String str);
45-
void rawf(const char *format, ...);
45+
void rawf(const char* format, ...);
4646
};
4747

4848
extern LogClass Log;

src/low_power.cpp

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,9 @@ static void enablePIT(void) {
302302
temp = CLKCTRL.XOSC32KCTRLA;
303303
temp &= ~CLKCTRL_ENABLE_bm;
304304
_PROTECTED_WRITE(CLKCTRL.XOSC32KCTRLA, temp);
305-
while (CLKCTRL.MCLKSTATUS & CLKCTRL_XOSC32KS_bm) {}
305+
while (CLKCTRL.MCLKSTATUS & CLKCTRL_XOSC32KS_bm) {
306+
__asm__ __volatile__("nop\n\t");
307+
}
306308

307309
// We want the external crystal to run in standby and in low power mode
308310
temp = CLKCTRL.XOSC32KCTRLA;
@@ -317,7 +319,7 @@ static void enablePIT(void) {
317319
_PROTECTED_WRITE(CLKCTRL.XOSC32KCTRLA, temp);
318320

319321
// Wait for registers to synchronize
320-
while (RTC.PITSTATUS) { delay(1); }
322+
while (RTC.PITSTATUS) { __asm__ __volatile__("nop\n\t"); }
321323

322324
RTC.CLKSEL |= RTC_CLKSEL_XOSC32K_gc;
323325
RTC.PITINTCTRL |= RTC_PI_bm;
@@ -326,7 +328,7 @@ static void enablePIT(void) {
326328
// The first PIT intterupt will not necessarily be at the period specified,
327329
// so we just wait until it has triggered and track the reminaing time from
328330
// there
329-
while (!pit_triggered) { delay(1); }
331+
while (!pit_triggered) { __asm__ __volatile__("nop\n\t"); }
330332
pit_triggered = false;
331333
}
332334

@@ -442,9 +444,6 @@ static void powerDownPeripherals(const bool keep_modem_active) {
442444

443445
savePinState();
444446

445-
// Disable millis() timer
446-
stop_millis();
447-
448447
// For low power, the following configuration should be used.
449448
// If no comment is specified, the pin is set to input with input buffer
450449
// disabled and pull-up on
@@ -604,8 +603,6 @@ static void powerUpPeripherals() {
604603

605604
restorePinState();
606605

607-
restart_millis();
608-
609606
// ADC for analogRead
610607
init_ADC0();
611608
}
@@ -723,11 +720,8 @@ void LowPowerClass::powerSave(void) {
723720

724721
retrieved_period = true;
725722
}
726-
727-
// Retrieving the operator sleep time will call CEREG, which will
728-
// trigger led ctrl, so we just disable it again.
729-
// LedCtrl.off(Led::CELL, true);
730723
}
724+
731725
if (!attemptToEnterPowerSaveModeForModem(30000)) {
732726
Log.error(
733727
"Failed to put cellular modem in sleep. Power save functionality "
@@ -739,8 +733,15 @@ void LowPowerClass::powerSave(void) {
739733
SLPCTRL.CTRLA |= SLPCTRL_SMODE_PDOWN_gc | SLPCTRL_SEN_bm;
740734

741735
enableLDO();
736+
737+
// It's important that we stop the millis after enabling the LDO, as it
738+
// uses delay() to wait for the LDO mode to settle
739+
stop_millis();
740+
742741
sleep_cpu();
743742

743+
restart_millis();
744+
744745
// Will sleep here until we get the RING line activity and wake up
745746
disableLDO();
746747

@@ -750,8 +751,6 @@ void LowPowerClass::powerSave(void) {
750751
modem_is_in_power_save = false;
751752
}
752753

753-
// LedCtrl.on(Led::CELL, true);
754-
755754
SequansController.setPowerSaveMode(0, NULL);
756755
}
757756

@@ -761,12 +760,15 @@ void LowPowerClass::powerDown(const uint32_t power_down_time_seconds) {
761760

762761
Lte.end();
763762

764-
// TODO: somehow this prevents the modem to sleep...
765763
powerDownPeripherals(false);
766764

767765
enablePIT();
768766
enableLDO();
769767

768+
// It's important that we stop the millis after enabling the LDO, as it uses
769+
// delay() to wait for the LDO mode to settle
770+
stop_millis();
771+
770772
uint32_t remaining_time_seconds = power_down_time_seconds;
771773

772774
while (remaining_time_seconds > 0) {
@@ -782,6 +784,8 @@ void LowPowerClass::powerDown(const uint32_t power_down_time_seconds) {
782784
}
783785
}
784786

787+
restart_millis();
788+
785789
disableLDO();
786790
disablePIT();
787791
SLPCTRL.CTRLA &= ~SLPCTRL_SEN_bm;

src/lte.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ bool LteClass::begin(const uint32_t timeout_ms, const bool print_messages) {
121121
SequansController.writeCommand(AT_ENABLE_CEREG_URC);
122122
SequansController.writeCommand(AT_CONNECT);
123123

124-
char response_buffer[48] = "";
124+
char response_buffer[64] = "";
125125
char value_buffer[32] = "";
126126

127127
// Wait for CEREG URC before checking SIM

0 commit comments

Comments
 (0)