Skip to content

Commit

Permalink
Sync LoRa example
Browse files Browse the repository at this point in the history
  • Loading branch information
valeros committed Jul 1, 2021
1 parent 213ccad commit 3baa0d0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 24 deletions.
17 changes: 4 additions & 13 deletions examples/arduino-lowpower/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,28 @@
; Please visit documentation for the other options and examples
; http://docs.platformio.org/page/projectconf.html

[env:cubecell_board]
[env]
platform = asrmicro650x
framework = arduino
lib_ldf_mode = deep

[env:cubecell_board]
board = cubecell_board

[env:cubecell_board_plus]
platform = asrmicro650x
framework = arduino
board = cubecell_board_plus

[env:cubecell_capsule]
platform = asrmicro650x
framework = arduino
board = cubecell_capsule

[env:cubecell_gps]
platform = asrmicro650x
framework = arduino
board = cubecell_gps

[env:cubecell_module]
platform = asrmicro650x
framework = arduino
board = cubecell_module

[env:cubecell_module_plus]
platform = asrmicro650x
framework = arduino
board = cubecell_module_plus

[env:cubecell_node]
platform = asrmicro650x
framework = arduino
board = cubecell_node
20 changes: 9 additions & 11 deletions examples/arduino-lowpower/src/LowPower_WakeUpByTimer.ino
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
#include "Arduino.h"
#include "LoRa_APP.h"


#define timetosleep 5000
#define timetowake 5000
#define timetillsleep 5000
#define timetillwakeup 5000
static TimerEvent_t sleep;
static TimerEvent_t wakeUp;
uint8_t lowpower=1;

void onSleep()
{
Serial.printf("into lowpower mode, %d ms later wake up.\r\n",timetowake);
Serial.printf("Going into lowpower mode, %d ms later wake up.\r\n",timetillwakeup);
lowpower=1;
//timetosleep ms later wake up;
TimerSetValue( &wakeUp, timetowake );
//timetillwakeup ms later wake up;
TimerSetValue( &wakeUp, timetillwakeup );
TimerStart( &wakeUp );
}
void onWakeUp()
{
Serial.printf("wake up, %d ms later into lowpower mode.\r\n",timetosleep);
Serial.printf("Woke up, %d ms later into lowpower mode.\r\n",timetillsleep);
lowpower=0;
//timetosleep ms later into lowpower mode;
TimerSetValue( &sleep, timetosleep );
//timetillsleep ms later into lowpower mode;
TimerSetValue( &sleep, timetillsleep );
TimerStart( &sleep );
}

void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
boardInitMcu();
Radio.Sleep( );
TimerInit( &sleep, onSleep );
TimerInit( &wakeUp, onWakeUp );
Expand All @@ -36,7 +35,6 @@ void setup() {

void loop() {
if(lowpower){
//note that lowPowerHandler() run six times the mcu into lowpower mode;
lowPowerHandler();
}
// put your main code here, to run repeatedly:
Expand Down

0 comments on commit 3baa0d0

Please sign in to comment.