Hello Beegee,
I want to add the sensor time since I want to implement a message queue. Since if I lose communication with the gateway I want to resend saved messages with exact time and data.
checking there is a way to get the time to keep the sensor updated and with the ltime api we can use the time.
when I try to use service_lora_set_timereq(1); In the void setud I don’t see that it executes the function so that when the computer restarts it updates the time and date and in this way always has the correct time.
I think I’m wrong about something, could you please guide me?
void setup()
{
Serial.begin(9600);
// Setup for LoRaWAN
if (api.lorawan.nwm.get() == 1)
{
g_confirmed_mode = api.lorawan.cfm.get();
g_confirmed_retry = api.lorawan.rety.get();
g_data_rate = api.lorawan.dr.get();
// Setup the callbacks for joined and send finished
api.lorawan.registerRecvCallback(receiveCallback);
api.lorawan.registerSendCallback(sendCallback);
api.lorawan.registerJoinCallback(joinCallback);
api.lorawan.registerLinkCheckCallback(linkcheckCallback);
}
else // Setup for LoRa P2P
{
api.lora.registerPRecvCallback(recv_cb);
api.lora.registerPSendCallback(send_cb);
api.lora.registerPSendCADCallback(cad_cb);
}
pinMode(LED_GREEN, OUTPUT);
digitalWrite(LED_GREEN, HIGH);
pinMode(LED_BLUE, OUTPUT);
digitalWrite(LED_BLUE, HIGH);
pinMode(WB_IO1, OUTPUT);
digitalWrite(WB_IO1, LOW);
pinMode(WB_IO2, OUTPUT);
digitalWrite(WB_IO2, HIGH);
service_lora_set_timereq(1);
// Start Serial
Serial.begin(115200);
// Delay for 5 seconds to give the chance for AT+BOOT
delay(5000);
api.system.firmwareVersion.set("HW_Firmware_V1.0.1");
Serial.println("HardaweSignals Sensor calidad de aire");
Serial.println("------------------------------------------------------");
Serial.println("Setup the device with WisToolBox or AT commands before using it");
Serial.printf("Version %s\n", api.system.firmwareVersion.get().c_str());
Serial.println("------------------------------------------------------");
// Initialize module
Wire.begin();
// Register the custom AT command to get device status
if (!init_status_at())
{
MYLOG("SETUP", "Add custom AT command STATUS fail");
}
// Register the custom AT command to set the send interval
if (!init_interval_at())
{
MYLOG("SETUP", "Add custom AT command Send Interval fail");
}
// Get saved sending interval from flash
get_at_setting();
digitalWrite(LED_GREEN, LOW);
// Create a timer.
api.system.timer.create(RAK_TIMER_0, sensor_handler, RAK_TIMER_PERIODIC);
if (custom_parameters.send_interval != 0)
{
// Start a timer.
api.system.timer.start(RAK_TIMER_0, custom_parameters.send_interval, NULL);
}
// Check if it is LoRa P2P
if (api.lorawan.nwm.get() == 0)
{
digitalWrite(LED_BLUE, LOW);
sensor_handler(NULL);
}
if (api.lorawan.nwm.get() == 1)
{
if (g_confirmed_mode)
{
MYLOG("SETUP", "Confirmed enabled");
}
else
{
MYLOG("SETUP", "Confirmed disabled");
}
MYLOG("SETUP", "Retry = %d", g_confirmed_retry);
MYLOG("SETUP", "DR = %d", g_data_rate);
}
// Enable low power mode
api.system.lpm.set(1);
// If available, enable BLE advertising for 30 seconds and open the BLE UART channel
#if defined(_VARIANT_RAK3172_) || defined(_VARIANT_RAK3172_SIP_)
// No BLE
#else
Serial6.begin(115200, RAK_AT_MODE);
api.ble.advertise.start(30);
#endif
// Check if sensors are connected and initialize them
has_rak12037 = init_rak12037();
if (has_rak12037)
{
Serial.println("+EVT:RAK12037");
}
digitalWrite(LED_BLUE, LOW);
// Power down the sensors
digitalWrite(WB_IO2, LOW);
}
If I perform the AT command manually it works for me but for a production environment this should be executed every time the team performs a join.
Manual mode:
Best Regards