Plug & Sense DevStatusAns

Post Reply
nzagorec
Posts: 19
Joined: Tue Feb 20, 2018 9:06 am
Company: Verso Altima Group

Plug & Sense DevStatusAns

Post by nzagorec » Thu Oct 11, 2018 10:33 am

Hello,

Does Plug & Sense device have ability to send MAC answers?

Plug & Sense device I'm using is working for few months now. It sends uplinks regularly as programmed but it does not answer on any kind of MAC commands that requires some kind of MAC answer.

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Plug & Sense DevStatusAns

Post by libelium-dev » Mon Oct 15, 2018 1:22 pm

Hi,

Could you explain more in deep the problem? The LoRaWAN module should respond to mac commands automatically. If you are referring to the mac command to get battery level, you have to use setBatteryLevel() function.

Regards

nzagorec
Posts: 19
Joined: Tue Feb 20, 2018 9:06 am
Company: Verso Altima Group

Re: Plug & Sense DevStatusAns

Post by nzagorec » Wed Oct 24, 2018 2:54 pm

To be more specific device get downlink mac command like this:

Code: Select all

Mtype: UnconfirmedDataDown

RX1/RX2Delay: 1000

Flags: ADR : 0, ADRAckReq : 0, ACK : 1, FPending : 0

Mac (hex): 0301ff0001

MAC.Command.LinkADRReq
MAC.LinkADRReq.DataRate_TXPower : 0x01
MAC.LinkADRReq.DataRate_TXPower.DataRate : 0
MAC.LinkADRReq.DataRate_TXPower.TXPower : 1
MAC.LinkADRReq.ChMask : 0x00ff
MAC.LinkADRReq.Redundancy : 0x01
MAC.LinkADRReq.Redundancy.ChMaskCntl : 0
MAC.LinkADRReq.Redundancy.NbTrans : 1


Device should answer with LinkADRAns mac command. But i don't see it on actillity's wireless logger.

As for battery status I'm using this part of code to set battery status:

Code: Select all

error = LoRaWAN.setBatteryLevel(PWR.getBatteryLevel());
USB.printf("Battery status send command %d", error);
Set battery level function returns value 0 which corresponds LORAWAN_ANSWER_OK but no mac answer on DevStatusReq command is sent.

Regards

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Plug & Sense DevStatusAns

Post by libelium-dev » Thu Oct 25, 2018 9:24 am

Hi,

The answer with the battery level status is send in the following packet after receive the request. Please try to send two consecutive pakets in a loop without turn off the module.

Regards

nzagorec
Posts: 19
Joined: Tue Feb 20, 2018 9:06 am
Company: Verso Altima Group

Re: Plug & Sense DevStatusAns

Post by nzagorec » Mon Nov 19, 2018 11:20 am

Just a follow up on this:

We're talking about Smart Environment PRO sensors (14 of them). This is a snippet of our code that handles battery level:

Code: Select all

void setup() {
  USB.ON();
  RTC.ON();

  pinMode(GP_I2C_MAIN_EN, OUTPUT);

  USB.print("Setting LoRaWAN settings... ");
  LoRaWAN.OFF(loraSocket);
  delay(50);
  LoRaWAN.ON(loraSocket);
  LoRaWAN.factoryReset();
  LoRaWAN.setDeviceEUI(DEVICE_EUI);
  LoRaWAN.setDeviceAddr(DEVICE_ADDR);
  LoRaWAN.setNwkSessionKey(NWK_SESSION_KEY);
  LoRaWAN.setAppSessionKey(APP_SESSION_KEY);
  LoRaWAN.setRetries(7);
  LoRaWAN.setADR("on");
  LoRaWAN.saveConfig();
  USB.println("DONE");
}

void loop() {
  LoRaWAN.setBatteryLevel(PWR.getBatteryLevel());
  LoRaWAN.saveConfig();

  //form a packet

  error = LoRaWAN.joinABP();
  if (error == 0) {
    error = LoRaWAN.sendUnconfirmed(1, packet);
  }
    
  //sleep for 10min
}
We've been sending packets every 10 minutes for the past 3 days and battery level never got reported via DevStatus MAC command (ThingPark Wireless Logger shows "-" for battery in Device Manager).

Regarding the original question (module (not) answering to MAC commands), here's a screenshot of ThingPark Wireless Logger showing UnconfirmedDataDown packets with MAC commands being sent to a device after every uplink. You can see that there's no MAC answer in the upcoming message.

Image

Image

Image

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Plug & Sense DevStatusAns

Post by libelium-dev » Wed Nov 21, 2018 1:09 pm

Hi,

Did you try to send two packets consecutively without turn OFF the module?

Also please try to enable the automatic reply

Code: Select all

LoRaWAN.setAR("on")
Regards

nzagorec
Posts: 19
Joined: Tue Feb 20, 2018 9:06 am
Company: Verso Altima Group

Re: Plug & Sense DevStatusAns

Post by nzagorec » Thu Nov 22, 2018 1:43 pm

I figured out where the problem was. It was entering one part of the code that was there as a failsafe if LoRa module doesn't wake up properly.

Now, new problem:

Code: Select all

  // put mcu to sleep
  RTC.breakTimeAbsolute(RTC.getEpochTime() + readSleepInterval(), &time);
  RTC.setAlarm1(time.date, time.hour, time.minute, time.second, RTC_ABSOLUTE, RTC_ALM1_MODE2);
  LoRaWAN.sleep();
  PWR.sleep(SOCKET0_ON);

  // we continue here after interrupt
  LoRaWAN.wakeUp();
After interrupt LoRaWAN module should be waken up but it isn't, I can't join the network. LoRaWAN.wakeUp() returns 1. If I add LoRaWAN.check() or any getSomething method it would return 2 (no reply).

If I replace LoRaWAN.sleep() with simple delay function it works fine (module wakes up). I tried using different sleep states (ALL_ON, SOCKET0_ON, SENS_OFF) but it doesn't work with neither.

Any ideas?

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Plug & Sense DevStatusAns

Post by libelium-dev » Fri Nov 23, 2018 1:27 pm

Hi,

What API version are you using? We have just tried and it works.

Code: Select all

  LoRaWAN.ON(socket);
  RTC.setAlarm1("00:00:00:10", RTC_OFFSET, RTC_ALM1_MODE1);
  LoRaWAN.sleep();
  PWR.sleep(SOCKET0_ON);

  // we continue here after interrupt
  LoRaWAN.wakeUp();

  //////////////////////////////////////////////
  // 2. Join network
  //////////////////////////////////////////////

  error = LoRaWAN.joinABP();

  // Check status
  if ( error == 0 )
  {
    USB.println(F("2. Join network OK"));

    //////////////////////////////////////////////
    // 3. Send confirmed packet
    //////////////////////////////////////////////

    error = LoRaWAN.sendConfirmed( PORT, data);
Regards

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest