Please, advise how can I resume the Lora P2P, peer-to-peer, transmission after the LowPower_Handler(); function? If I comment-out this one line - //LowPower_Handler(); the transmission works fine (see the code below).
If I un-comment it, the Lora transmission stops after 6 successful messages. And I cannot figure out how I can wake it up.
With the GPIO7 pin and RST pins I can stop and resume transmission all right. But I could not do it yet with the timer. The example LowPower_WakeUpByTimer works fine by itself, and it works fine with my BME680 sensor. The CubeCell board goes to sleep after 6 LowPower_Handler(); runs, than it wakes up, and the sensor works OK.
I guess I should, probably, add some code which re-initializes Lora.
#include "Arduino.h"
#include "LoRaWan_APP.h"
#define timetosleep 5000
#define timetowake 15000
static TimerEvent_t sleep;
static TimerEvent_t wakeup;
boolean lowpower = true;
#ifndef LoraWan_RGB
#define LoraWan_RGB 0
#endif
#define RF_FREQUENCY 868000000 // Hz
#define TX_OUTPUT_POWER 14 // dBm
#define LORA_BANDWIDTH 0 // [0: 125 kHz,
// 1: 250 kHz,
// 2: 500 kHz,
// 3: Reserved]
#define LORA_SPREADING_FACTOR 7 // [SF7…SF12]
#define LORA_CODINGRATE 1 // [1: 4/5,
// 2: 4/6,
// 3: 4/7,
// 4: 4/8]
#define LORA_PREAMBLE_LENGTH 8 // Same for Tx and Rx
#define LORA_SYMBOL_TIMEOUT 0 // Symbols
#define LORA_FIX_LENGTH_PAYLOAD_ON false
#define LORA_IQ_INVERSION_ON false
#define RX_TIMEOUT_VALUE 1000
#define BUFFER_SIZE 30 // Define the payload size here
char txpacket[BUFFER_SIZE];
char rxpacket[BUFFER_SIZE];
unsigned long time_now = 0;
unsigned long next_millis = 0;
static RadioEvents_t RadioEvents;
int16_t txnumber;
int16_t RSSI, rxSize;
void OnSleep()
{
  Serial.printf("into lowpower mode, %d ms later wake up.\r\n", timetowake);
  lowpower = true;
  //timetosleep ms later wake up;
  TimerSetValue( &wakeup, timetowake );
  TimerStart( &wakeup );
}
void OnWakeup()
{
  Serial.printf("wake up, %d ms later into lowpower mode.\r\n", timetosleep);
  lowpower = false;
  //timetosleep ms later into lowpower mode;
  TimerSetValue( &sleep, timetosleep );
  TimerStart( &sleep );
}
void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  BoardInitMcu();
  Radio.Sleep( );
  pinMode(Vext, OUTPUT);
  digitalWrite(Vext, LOW);
  time_now = millis();
  while (millis() < time_now + 500) { // equivalent of delay(...);
  }
  Radio.Init( &RadioEvents );
  Radio.SetChannel( RF_FREQUENCY );
  Radio.SetTxConfig( MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH,
                     LORA_SPREADING_FACTOR, LORA_CODINGRATE,
                     LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON,
                     true, 0, 0, LORA_IQ_INVERSION_ON, 3000 );
  time_now = millis();
  while (millis() < time_now + 500) { // equivalent of delay(...);
  }
  TimerInit( &sleep, OnSleep );
  TimerInit( &wakeup, OnWakeup );
  OnSleep();
}
void loop() {
  // put your main code here, to run repeatedly:
  time_now = millis();
  while (millis() < time_now + 500) { // equivalent of delay(...);
  }
  char *str_temp;
  String msgT = "";
  msgT = "A test message.";
  memset(txpacket, 0, BUFFER_SIZE);
  // converting strig to a char?
  str_temp =  (char*)(msgT).c_str();
  sprintf(txpacket, "%s", str_temp);
  RGB_ON(COLOR_SEND, 0);
  Serial.printf("\r\nsending packet \"%s\" , length %d\r\n", txpacket, strlen(txpacket));
  Radio.Send( (uint8_t *)txpacket, strlen(txpacket) );
  RGB_ON(0, 0);
  time_now = millis();
  while (millis() < time_now + 500) { // equivalent of delay(...);
  }
  if (lowpower) {
    //note that LowPower_Handler() run six times the mcu into lowpower mode;
    LowPower_Handler();
  }
}