There is a problem either in parsing in Sigfox module, or in the way data is sent to the Sigfox module. If you send a message in an array like following:
there would be a parsing error produced and your message will not be sent to Sigfox servers, due to msg[2]=13; //0xD
. If you change it to msg[2]=16; //0x10
the issue will be resolved. It seems that this part is seen as a nibble instead of a byte, as long as the value is equal or less than F in HEX. The complete and simple example is as below.
#include <SoftwareSerial.h>
#define SF_rxPin 5 //Sigfox
#define SF_txPin 6 //Sigfox
boolean debug = true;
uint8_t msg[12];
SoftwareSerial Sigfox = SoftwareSerial(SF_rxPin, SF_txPin); //((Module.Tx>>>MCU.Rx), (Module.Rx>>>MCU.Tx))
void setup() {
pinMode(SF_rxPin, INPUT);
pinMode(SF_txPin, OUTPUT);
if(debug){
Serial.begin(9600);
}
Sigfox.begin(9600);
delay(500);
if(debug){
Serial.println("Hello!");
}
}
void loop() {
msg[0]=76; //0x4C
msg[1]=20; //0x14
msg[2]=13; //0xD
if(debug){
Serial.println(msg[0],HEX);
Serial.println(msg[1],HEX);
Serial.println(msg[2],HEX);
}
delay(20);
sendMessage(msg, strlen(msg)); // Sending messages here
delay(20*1000);
}
//Send Sigfox Message
void sendMessage(uint8_t msg[], int size){
String status = "";
char output;
Sigfox.print("AT$SF=");
for(uint8_t i= 0;i<size;i++){
Sigfox.print(String(msg[i], HEX));
if(debug){
Serial.print("Byte:");
Serial.println(msg[i], HEX);
}
}
Sigfox.print("\n");
while (!Sigfox.available()){
//blink();
}
while(Sigfox.available()){
output = (char)Sigfox.read();
status += output;
delay(10);
}
if(debug){
Serial.println();
Serial.print("Status \t");
Serial.println(status);
}
}
I also tried with the following message structure and nothing changed. The issue still exists.
#include <SoftwareSerial.h>
#define SF_rxPin 5 //Sigfox
#define SF_txPin 6 //Sigfox
boolean debug = true;
SoftwareSerial Sigfox = SoftwareSerial(SF_rxPin, SF_txPin); //((Module.Tx>>>MCU.Rx), (Module.Rx>>>MCU.Tx))
typedef struct {
uint8_t A; //Value 1
uint16_t B; //Value 2
} SigfoxMessage;
SigfoxMessage M;
void setup() {
pinMode(SF_rxPin, INPUT);
pinMode(SF_txPin, OUTPUT);
if(debug){
Serial.begin(9600);
}
Sigfox.begin(9600);
delay(500);
if(debug){
Serial.println("Hello!");
}
}
void loop() {
M.A=76; //0x4C
M.B=333; //0x14D
if (debug) {
Serial.println("Value1: "+String(M.A));
Serial.println("Value2: "+String(M.B)+"\n");
}
delay(20);
send(&M, sizeof(M)); // Sending messages here
delay(20*1000);
}
void send(const void* data, uint8_t size){
uint8_t* bytes = (uint8_t*)data;
if(debug){
Serial.println("Message Size: " + String(size));
}
Sigfox.print("AT$SF=");
for(uint8_t i= 0; i<(size); ++i){
Sigfox.print(bytes[i], HEX);
if(debug){
Serial.print("Byte:");
Serial.println(bytes[i], HEX);
}
}
Sigfox.print("\n");//// \n or \r
}
In this way there is a limitation in sending different values and as long as the value is <= 0xF, there would be a problem.
Is there a fix for this issue?