Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sigfox module stuck when calling "sigfox.available()" #6

Open
ghynes opened this issue Jun 17, 2016 · 15 comments
Open

Sigfox module stuck when calling "sigfox.available()" #6

ghynes opened this issue Jun 17, 2016 · 15 comments

Comments

@ghynes
Copy link

ghynes commented Jun 17, 2016

Hi,
I have a smarteverything board and I've been creating an asset tracking application.
All was going well with callbacks until I tried to create a downlink ... since then the Sigfox module has been unusable ... in particular it gets stuck when calling sigfox.available(). No amount of resetting, powering off etc. will fix it.

Below is the problem function.
I was passing the following 12 byte data frame to the function "00 01 00 1d 43 35 00 00 42 b6 00 00"

bool sendSigfox(const void* data, uint8_t len){
  String frame = getSigfoxFrame(data, len);
  String status = "";
  char output;
  SigFox.print("AT$SF=");
  SigFox.print(frame+",1");
  SigFox.print("\r");
  while (!SigFox.available());

  while(SigFox.available()){
    output = (char)SigFox.read();
    status += output;
    delay(10);
  }
  if (status == "OK\r"){
    //Success :)
    return true;
  }
  else{
    return false;
  }
}

Any help or tips would be gratefully accepted as the Sigfox module is currently unusable :(

@smkkHw
Copy link
Contributor

smkkHw commented Jun 21, 2016

It could be that your Fw is old and need to upgrade
Please run the readSWVersion example and check on the serial usb if U have this version
GP.S03.02.00-B002GP.B00.01.0C

if not, run the FwUpgrade example

@ghynes
Copy link
Author

ghynes commented Jun 22, 2016

It was using an older version of the firmware.
I have updated the firmware but the problem remains :(

@smkkHw
Copy link
Contributor

smkkHw commented Jun 22, 2016

I did not use the AT command, which are more design for configuration.
Try, instead, the downlink example.
Mik
sent from Mobile

@ghynes
Copy link
Author

ghynes commented Jun 23, 2016

I tried the downlink example just now.
It kept looping waiting for sfxAntenna.hasSfxAnswer() to return true ... so the blue light stays on indefinitely.

I've tried an Akeru board in the same location and I'm able to get Sigfox messages so I don't think signal strength is a problem.

@smkkHw
Copy link
Contributor

smkkHw commented Jun 26, 2016

Ok, please one check more.

When U use the SmartEverything did U have the confirmation from the Back End that the message has been sent in down link?

If U goes to the "Message" Tab of the device page U use, U should see the green arrow down like those are in the picture in attach
downlink

@smkkHw
Copy link
Contributor

smkkHw commented Jun 30, 2016

Hi ghynes.

I tried the downlink example with one of my SmartEverything, and I faced the same issue.

I'm in contact with Telit because the chip itself return an ERROR information even if the Sigfox BackEnd shows that the message is correctly received and acknowledged.

If U change a little bit the code on the example U post at the beginning of this thread U should see the ERROR message coming from Telit Chip

char sendSigfox(const void* data, uint8_t len){
String frame = getSigfoxFrame(data, len);
String status = "";
char output;
SigFox.print("AT$SF=");
SigFox.print(frame+",1");
SigFox.print("\r");
while (!SigFox.available());

while(SigFox.available()){
output = (char)SigFox.read();
status += output;
delay(10);
}

if (status == "OK\r"){
//Success :)
return 0;
} else if (status == "ERROR\r") {
return 1;
}
else{
return 3;
}
}

@NaKroTeK
Copy link

NaKroTeK commented Jul 5, 2016

Hi,

I have the same problem for some time too (before & after update)
I thought it was on my side, since within some situation it does not happened.
Oddly enough by reloading the example of reading the FW version, I can reload my program over & over WITHOUT unplugging the USB Cable and no problem anymore.
Does it happened to you when using AT command ??
@smkkHw your lib use AT command too no ?

@smkkHw
Copy link
Contributor

smkkHw commented Jul 5, 2016

Yes NaKro,
Actully my code use the AT commad,too.
This is the only way with Telit chip to have the downlik, I wrapped it on the library, but internally the AT command is sent.

I just received today the answer from Telit.

The point is that there is an internal 45 Sec. timeout, after that the chip send the ERROR message back.
This could happen when the ASME is on the border of a good signal (If U see the picture I added on top of the Thread my quality is Yellow).
There are 2 work around on this:

  1. send the ack request closer to the antenna (this is what I tried yesterday with success)
  2. change the default antenna of the ASME with a more powerful antenna:
    one 1/2Wave instead of the default 1/4Wave.
    put the antenna in vertical position for a proper radiation.

Anyway, I'm still in contact with Telit because there is one point that is not clear to me.
from where I have the error on ACK, I have the 100% of succes of uplink message, and 0% of not succes in downlik, why ? the downlink is more critiacl of uplink? I will append here the answer soon I have it.

capture

@NaKroTeK
Copy link

NaKroTeK commented Jul 5, 2016

Hi !

I do believe the 45 sec Timeout is for the chip to wait for the Ack.
(nominal behavior IMO). I found some documentation on that, I will post it
if I found it again.
I have always Green status callback on the Sigfox backend, even when i have
an error(Fail to receive ACK) on the board. Indeed "it could happen when
the ASME is on the border of a good signal".

@smkkHw
Copy link
Contributor

smkkHw commented Jul 5, 2016

Same as mine situation, always a green arrow down-link, but error on Telit chip.

This is why I'd not close the issue with Telit.

They should tell me why the down-link is so critical, I have green arrow and 100% of success on up-link, and, green arrow 0% of success in down-link.

There is a reason behind this asymmetric behavior?

@NaKroTeK
Copy link

NaKroTeK commented Jul 6, 2016

Here is my problem,
I can run DataModeEU example without any problem
But in my code with this :

void setup()
{
  delay(6000);
  int initFinish=1;
  SerialUSB.begin(57600);
  SerialUSB.println("Startup");
  sfxAntenna.begin();
  GPS.begin(9600);
  ledRedLight(HIGH);
  ledRedLight(LOW);
  ledGreenLight(HIGH);
  // Switch SigFox modem to config mode
   SerialUSB.println("SFX in config mode");
   sfxAntenna.setSfxConfigurationMode(); // enter in configuration Mode
   do {
        uint8_t answerReady = sfxAntenna.hasSfxAnswer();
        if (answerReady){
            switch (initFinish){
            case 1:                                
                SerialUSB.println("SFX in Data mode");
                sfxAntenna.setSfxDataMode();
                initFinish++;
                break;

            case 2:
                initFinish++; // exit
                break;
            }
        }
    } while (initFinish!=3);
  ledGreenLight(LOW);
  SerialUSB.println("Configuration Complete");
}

Why adding a delay on startup before initialization of module break the board ?

@smkkHw
Copy link
Contributor

smkkHw commented Jul 6, 2016

Hi Alex.

First of all, the next line is based on my assumption that U change only the setup() function from the original example, and not the setup (U post only the setup.... that's why I'm assuming that)
Based on this:

The point is not the delay(6000) but the fact that U remove the send of the "HELLO" string removing the following lines from the setup()
SerialUSB.println("sending Hello over the network"); // send Hello on the air sfxAntenna.sfxSendData(helloMsg, strlen((char*)helloMsg));
because the ASME does not send anything the loop will never have
bool answerReady = sfxAntenna.hasSfxAnswer();
set to true.
And and the ends no OK nor KO message will be displayed, so basically the loop() function will exit immediately continuously.

giving 6 Sec at the begin U have enough time to, at least, read the configuration enter exit strings but only those.
Strings that are not visible if U run without that delay due to the high speed of the micro compared with the human reaction, U open the Serialmonitor too late (or RU SUperman? :):):) )

Try just adding the above line at the end of the setup, and please tell me if it work (it should).

Mik.

P.s.
BTW, the enter in conf mode is not required, that is an old example, sooner we will exit with a new library and the example will looks like this.

#include <Wire.h>
#include <SmeSFX.h>
#include <Arduino.h>

char helloMsg[5]= {'H','e', 'l', 'l', 'o'};
bool messageSent;

// the setup function runs once when you press reset or power the board
void setup() {

SerialUSB.begin(115200);
sfxAntenna.begin();
int initFinish=1;

while (!SerialUSB) {
    ; 
}    

SerialUSB.println("sending Hello over the network");
// send Hello on the air
sfxAntenna.sfxSendData(helloMsg, strlen((char*)helloMsg));

}

// the loop function runs over and over again forever
void loop() {

bool answerReady = sfxAntenna.hasSfxAnswer();

if (answerReady) {
    if (sfxAntenna.getSfxMode() == sfxDataMode) {

        switch (sfxAntenna.sfxDataAcknoledge()) {
        case SFX_DATA_ACK_START:
            SerialUSB.println("Waiting Answer");
            break;

        case SFX_DATA_ACK_PROCESSING:
            SerialUSB.print('.');
            break;

        case SFX_DATA_ACK_OK:

#ifdef ARDUINO_SAMD_SMARTEVERYTHING
ledGreenLight(HIGH);
#endif
SerialUSB.println(' ');
SerialUSB.println("Answer OK :) :) :) :)");
break;

        case SFX_DATA_ACK_KO:

#ifdef ARDUINO_SAMD_SMARTEVERYTHING
ledRedLight(HIGH);
#endif
SerialUSB.println(' ');
SerialUSB.println("Answer KO :( :( :( :(");
break;
}
}
}
}

@NaKroTeK
Copy link

NaKroTeK commented Jul 7, 2016

Hi mike,

Too be sure of your saying I just tested with the DataModeEU example (Talis qualis)
It works :)

Add delay(6000); does not anymore :(
here is the setup function of DataModeEu modified :

// the setup function runs once when you press reset or power the board
void setup() {
    delay(6000);
    SerialUSB.begin(115200);
    sfxAntenna.begin();
    int initFinish=1;

    SerialUSB.println("SFX in Command mode");
    sfxAntenna.setSfxConfigurationMode(); // enter in configuration Mode

    do {
        uint8_t answerReady = sfxAntenna.hasSfxAnswer();
        if (answerReady){
            switch (initFinish){
            case 1:                                
                SerialUSB.println("SFX in Data mode");
                sfxAntenna.setSfxDataMode();
                initFinish++;
                break;

            case 2:
                initFinish++; // exit
                break;
            }
        }
    } while (initFinish!=3);

    SerialUSB.println("sending Hello over the network");
    // send Hello on the air
    sfxAntenna.sfxSendData(helloMsg, strlen((char*)helloMsg));
}

PS : indeed I just follow you example if it change in the futur, I will no longer go in configurationMode again.

PPS : The Goal for the 6 sec delay was 1st to be able to reload programs to the board as I am using Interruption timer and __WFI() sleep mode [it may block the usb commmunication]. So no I'm not Superman. :)

@NaKroTeK
Copy link

Why am I not doing this to get serial monitor....

  SerialUSB.begin(57600);
  while (!SerialUSB) {
        ;
    }
  SerialUSB.println("Startup");
  }

@escalanterj
Copy link

Hello,
I executed FWupgrade and since then the module does not communicate with sigfox. Any clue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants