Author Topic: Sigfox functionality works under debug but not always under finial build  (Read 155 times)

Bartw

  • Newbie
  • *
  • Posts: 29
    • View Profile
Hello.
We have one project where the 205 should send a message at power up under Shared Event Boot()
when i debug the code the unit works as expected however when i run it flashed to the unit it refuses to send.
is there a timing or lock event going on that i am not aware of or is there some documentation on when i can Lplan.
and yes the radio should is initialized by this point.
I have tried inserting some large delays with Thread.Sleep() with no joy.
Any Ideas?

Social Buttons


mc-T2

  • Administrator
  • Sr. Member
  • *****
  • Posts: 252
  • mc-Things! The opportunities are endless!
  • Location: Canada
    • View Profile
Hi Bart,
That does sounds odd. Can you post your code so we can check it out and see if there is anything that is causing this?

In the title you say
Quote
works under debug but not always under final build
- Does this mean that sometimes it works for you with the same code and sometimes it does not?
Need more mc-Modules, mc-Gateways or other mc-Things? Check out our product page: www.mcthings.com/products. mc-Development kits are available too!
Check out a live Dashboard using mcThings and Losant! Click here: https://goo.gl/ST43hB

Bartw

  • Newbie
  • *
  • Posts: 29
    • View Profile
Hello,

I am missing events from my 205 and am having a closer look to see whats going on.

It looks like the 205 is not sending occasionally and I suspect I have seen this before.

Our office is covered by 3 sigfox base stations and even though our RSSI is somewhat low ~15-20dB SNR the packets are usually seen 2-3 times per station.

However I have just logged two missing packets that never made it even though i manually stepped through the code..

This is really messing up our demo projects and budgets.

Any one have any ideas?

Bartw

  • Newbie
  • *
  • Posts: 29
    • View Profile
Unfortunately i have been allocated to another project for now but will try and post up once back to that particular job

Bartw

  • Newbie
  • *
  • Posts: 29
    • View Profile
I spoke too soon. now my current project is 100% dead also...

Sigfox works mostly fine under debug but as soon as i build and "load and save"
power cycle and run from battery or usb for that matter...

I the code blinks an led after Lplan.Sigfox(msg) fine but nothing ends up at the sigfox backend,

The thread is called every 5 seconds to poll sensors and do so calcs there is only the odd message sent based on filtered events.

Code snippets / flow concept below please let me know a support email address that i can email the full project to..

Is there something i have missed???

I have tried the build release and debug neither seem to work for me.

As soon as i connect in mcstudio build and run in debug works first go...

regards
Bart

    Shared Event Boot()
        Lplan.SigfoxRadioZone(SigfoxRadioZone.Australia)
    End Event


    Shared Event mainloop() RaiseEvent Every 5 Seconds

        While (10 times)
            reading = read_sensor()
 //           do some filtering and add reading to a list

            Thread.Sleep(150000)
        End While
   
'do some list searching and list operations

     
        If  Then
        'do some more calculations and debug           
            If   Then
                'pack data and go!
                Dim msg As ListOfByte = New ListOfByte()
                msg.AddByte( around 7 bytes)

                Lplan.Sigfox(msg)

                Led2 = True ' this led toggles but no data ends up at sigfox
                Thread.Sleep(1000)
                Led2 = False
               
            End If
        End If
       
    End Event
 
« Last Edit: February 15, 2017, 06:13:05 am by Bartw »

mc-Abe

  • Full Member
  • ***
  • Posts: 167
    • View Profile
    • mc-Things
This is missed in our documentation, I will make sure we update this and add an example but here is an explanation of what I think is happening with your code:

Due to FCC regulation, there are time limits on how often sigfox messages can be sent. Effectively, you can only send 2 messages within a 20-second window. The underlying sigfox stack on our device will take care of this timing. However what you need to ensure is that your sigfox message was accepted by the device to be queued for transmission. We have limited memory so this queue size is small. the Lplan.Sigfox() function actually returns whether the message was successfully accepted for transmission or not. I would suggest you change your call to this:

Code: [Select]
While Not Lplan.Sigfox(msg)
    Thread.Sleep(10000000)
End While

Note that this will cause your thread to sleep for 10 seconds if the message is not accepted and continue to do so until the message is accepted (Should never be more than 20s). Not sure if this will be alright in your application but you need to implement a mechanism like this to avoid losing your messages.

Bartw

  • Newbie
  • *
  • Posts: 29
    • View Profile
Hi Abe,
Thanks for the reply

Yes this will likely explain the missing packets as i was hammering it from the ide to see what was going on.

However with the debug vs stand alone code there seems to be still an issue.

True we are in a 5 second thread but under normal condition we only send on sensed events.
In the test setup I have it the unit will power up and send one message and then wait for an event.
this is what i see under debug with no breakpoints but stand alone nothing happens.

Is there a power on wait period required before trying to send?

Regards
Bart

mc-Abe

  • Full Member
  • ***
  • Posts: 167
    • View Profile
    • mc-Things
The 20s delay also applies on power up to ensure that a device reset does not cause FCC violation. If the message is queued successfully, it will be sent after the 20s window has passed. If you wait long enough do you see the message?

Bartw

  • Newbie
  • *
  • Posts: 29
    • View Profile
Hi Abe,

Thank you for your reply.
It does not appear to come through even thought it should be queued
I set my thread to 20s with no change and then bumped it up to 30s and everything kicked into life.  :)
What really got me was the difference running in debug (no breakpoints) vs standalone.
Many thanks

Regards
Bart

kbrooking

  • Full Member
  • ***
  • Posts: 104
    • View Profile
I'm seeing this same odd behavior. So was there a final solution to resolve this issue?

mc-T2

  • Administrator
  • Sr. Member
  • *****
  • Posts: 252
  • mc-Things! The opportunities are endless!
  • Location: Canada
    • View Profile
Hey Kbrooking,

It could be that the device is still connected as a device within mcStudio which could negate its ability to send out SIGFOX messages.

Can you try:
-   Load your programming either wirelessly or via USB serial connection
-   Remove the USB from the mcDemo205 and close mcStudio
-   You can then plug the device back in via USB to provide power or power the device from batteries

This should allow you to get SIGFOX messages back as the device would then be in a state of running independently. Does that make sense? Let us know how that goes


Need more mc-Modules, mc-Gateways or other mc-Things? Check out our product page: www.mcthings.com/products. mc-Development kits are available too!
Check out a live Dashboard using mcThings and Losant! Click here: https://goo.gl/ST43hB

kbrooking

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Thanks. Following the above instruction resolved the problem.