Closed ayeosq closed 7 years ago
My biggest suspect is this:
if (!sendCommand(toHex('U'), 1, data, markers)) return false;
Would suggest a flush method.
My solution:
1) Add this method in radiocraft:
bool Radiocrafts::getReady() { // get the SIGFOX module to be ready for message sending. if (!sendCommand(toHex('U'), 1, data, markers)) return false; if (data.length() != 2) { log1(F(" - Radiocrafts.flush: failed to execute ")); return false; } log1(F(" - Radiocrafts.flushed successfully ")); return true; }
Call it in your .ino file via transceiver.getReady()
Thanks @ayeosq for the suggestion. The code has an issue handling 3 modes: Command Mode, Send Mode, Config Mode. Right now it only handles Command and Send Modes.
I'm fixing now, will update you thanks!
Hi @ayeosq I have updated the code to handle the Send, Command and Config modes. Can you update the unabiz-arduino library in Arduino IDE and retry? Lemme know thanks
Also @ayeosq here's the expected output for DemoTestV1.ino, which I also added to the end of the DemoTestV1.ino file:
Running setup...
- Disabling emulation mode...
- Entering command mode...
- Radiocrafts.sendBuffer: 00
>> 00
<< 3e
- Radiocrafts.sendBuffer: response:
- Radiocrafts.enterCommandMode: OK
- Entering config mode from send mode...
- Radiocrafts.sendBuffer: 4d
>> 4d
<< 3e
- Radiocrafts.sendBuffer: response:
- Radiocrafts.enterConfigMode: OK
- Radiocrafts.sendBuffer: 2800
>> 28 00
<<
- Radiocrafts.sendBuffer: response:
- Exiting config mode to send mode...
- Radiocrafts.sendBuffer: ff
>> ff
<< 3e
- Radiocrafts.sendBuffer: response:
- Radiocrafts.exitConfigMode: OK
- Exiting command mode...
- Radiocrafts.sendBuffer: 58
>> 58
<<
- Radiocrafts.sendBuffer: response:
- Radiocrafts.exitCommandMode: OK
- Checking emulation mode (expecting 0)...
- Radiocrafts.getParameter: address=0x28
- Entering command mode...
- Radiocrafts.sendBuffer: 00
>> 00
<< 3e
- Radiocrafts.sendBuffer: response:
- Radiocrafts.enterCommandMode: OK
- Radiocrafts.sendBuffer: 5928
>> 59 28
<< 3e 00 3e
- Radiocrafts.sendBuffer: response: 00
- Exiting command mode...
- Radiocrafts.sendBuffer: 58
>> 58
<<
- Radiocrafts.sendBuffer: response:
- Radiocrafts.exitCommandMode: OK
- Radiocrafts.getParameter: address=0x28 returned 00
- Getting SIGFOX ID...
- Entering command mode...
- Radiocrafts.sendBuffer: 00
>> 00
<< 3e
- Radiocrafts.sendBuffer: response:
- Radiocrafts.enterCommandMode: OK
- Radiocrafts.sendBuffer: 39
>> 39
<< 34 8a 1c 00 7e ec d9 02 49 bf 58 8b 3e
- Radiocrafts.sendBuffer: response: 348a1c007eecd90249bf588b
- Exiting command mode...
- Radiocrafts.sendBuffer: 58
>> 58
<<
- Radiocrafts.sendBuffer: response:
- Radiocrafts.exitCommandMode: OK
- Radiocrafts.getID: returned id=001c8a34, pac=7eecd90249bf588b
- SIGFOX ID = 001c8a34
- PAC = 7eecd90249bf588b
- Setting frequency for country -26112
- Radiocrafts.setFrequencySG
- Entering command mode...
- Radiocrafts.sendBuffer: 00
>> 00
<< 3e
- Radiocrafts.sendBuffer: response:
- Radiocrafts.enterCommandMode: OK
- Entering config mode from send mode...
- Radiocrafts.sendBuffer: 4d
>> 4d
<< 3e
- Radiocrafts.sendBuffer: response:
- Radiocrafts.enterConfigMode: OK
- Radiocrafts.sendBuffer: 0003
>> 00 03
<<
- Radiocrafts.sendBuffer: response:
- Exiting config mode to send mode...
- Radiocrafts.sendBuffer: ff
>> ff
<< 3e
- Radiocrafts.sendBuffer: response:
- Radiocrafts.exitConfigMode: OK
- Exiting command mode...
- Radiocrafts.sendBuffer: 58
>> 58
<<
- Radiocrafts.sendBuffer: response:
- Radiocrafts.exitCommandMode: OK
- Set frequency result =
- Getting frequency (expecting 3)...
- Entering command mode...
- Radiocrafts.sendBuffer: 00
>> 00
<< 3e
- Radiocrafts.sendBuffer: response:
- Radiocrafts.enterCommandMode: OK
- Radiocrafts.sendBuffer: 5900
>> 59 00
<< 3e
- Radiocrafts.sendBuffer: response:
- Exiting command mode...
- Radiocrafts.sendBuffer: 58
>> 58
<< 00 3e
- Radiocrafts.sendBuffer: response: 00
- Warning: Radiocrafts.exitCommandMode resending exit command, may be in incorrect mode
- Radiocrafts.sendBuffer: 58
>> 58
<<
- Radiocrafts.sendBuffer: response:
- Radiocrafts.exitCommandMode: OK
- Frequency (expecting 3) =
- Radiocrafts.sendMessage: 001c8a34,0102030405060708090a0b0c
- Radiocrafts.sendBuffer: 0c0102030405060708090a0b0c
>> 0c 01 02 03 04 05 06 07 08 09 0a 0b 0c
<<
- Radiocrafts.sendBuffer: response:
Waiting 10 seconds...
Running loop #0
- Entering command mode...
- Radiocrafts.sendBuffer: 00
>> 00
<< 3e
- Radiocrafts.sendBuffer: response:
- Radiocrafts.enterCommandMode: OK
- Radiocrafts.sendBuffer: 55
>> 55
<< a0 3e
- Radiocrafts.sendBuffer: response: a0
- Exiting command mode...
- Radiocrafts.sendBuffer: 58
>> 58
<<
- Radiocrafts.sendBuffer: response:
- Radiocrafts.exitCommandMode: OK
- Radiocrafts.getTemperature: returned 32
- Entering command mode...
- Radiocrafts.sendBuffer: 00
>> 00
<< 3e
- Radiocrafts.sendBuffer: response:
- Radiocrafts.enterCommandMode: OK
- Radiocrafts.sendBuffer: 56
>> 56
<< 71 3e
- Radiocrafts.sendBuffer: response: 71
- Exiting command mode...
- Radiocrafts.sendBuffer: 58
>> 58
<<
- Radiocrafts.sendBuffer: response:
- Radiocrafts.exitCommandMode: OK
- Radiocrafts.getVoltage: returned 3.39
- Message.addField: ctr=0
- Message.addField: tmp=32
- Message.addField: vlt=33.3
- Radiocrafts.sendMessage: 001c8a34,920e0000b051400194592100
Warning: Should wait 10 mins before sending the next message
- Radiocrafts.sendBuffer: 0c920e0000b051400194592100
>> 0c 92 0e 00 00 b0 51 40 01 94 59 21 00
<<
- Radiocrafts.sendBuffer: response:
Waiting 10 seconds...
Running loop #1
- Entering command mode...
- Radiocrafts.sendBuffer: 00
>> 00
<< 3e
- Radiocrafts.sendBuffer: response:
- Radiocrafts.enterCommandMode: OK
- Radiocrafts.sendBuffer: 55
>> 55
<< a0 3e
- Radiocrafts.sendBuffer: response: a0
- Exiting command mode...
- Radiocrafts.sendBuffer: 58
>> 58
<<
- Radiocrafts.sendBuffer: response:
- Radiocrafts.exitCommandMode: OK
- Radiocrafts.getTemperature: returned 32
- Entering command mode...
- Radiocrafts.sendBuffer: 00
>> 00
<< 3e
- Radiocrafts.sendBuffer: response:
- Radiocrafts.enterCommandMode: OK
- Radiocrafts.sendBuffer: 56
>> 56
<< 71 3e
- Radiocrafts.sendBuffer: response: 71
- Exiting command mode...
- Radiocrafts.sendBuffer: 58
>> 58
<<
- Radiocrafts.sendBuffer: response:
- Radiocrafts.exitCommandMode: OK
- Radiocrafts.getVoltage: returned 3.39
- Message.addField: ctr=1
- Message.addField: tmp=32
- Message.addField: vlt=33.3
- Radiocrafts.sendMessage: 001c8a34,920e0a00b051400194592100
Warning: Should wait 10 mins before sending the next message
- Radiocrafts.sendBuffer: 0c920e0a00b051400194592100
>> 0c 92 0e 0a 00 b0 51 40 01 94 59 21 00
<<
- Radiocrafts.sendBuffer: response:
Waiting 10 seconds...
Running loop #2
- Entering command mode...
- Radiocrafts.sendBuffer: 00
>> 00
<< 3e
- Radiocrafts.sendBuffer: response:
- Radiocrafts.enterCommandMode: OK
- Radiocrafts.sendBuffer: 55
>> 55
<< a1 3e
- Radiocrafts.sendBuffer: response: a1
- Exiting command mode...
- Radiocrafts.sendBuffer: 58
>> 58
<<
- Radiocrafts.sendBuffer: response:
- Radiocrafts.exitCommandMode: OK
- Radiocrafts.getTemperature: returned 33
- Entering command mode...
- Radiocrafts.sendBuffer: 00
>> 00
<< 3e
- Radiocrafts.sendBuffer: response:
- Radiocrafts.enterCommandMode: OK
- Radiocrafts.sendBuffer: 56
>> 56
<< 71 3e
- Radiocrafts.sendBuffer: response: 71
- Exiting command mode...
- Radiocrafts.sendBuffer: 58
>> 58
<<
- Radiocrafts.sendBuffer: response:
- Radiocrafts.exitCommandMode: OK
- Radiocrafts.getVoltage: returned 3.39
- Message.addField: ctr=2
- Message.addField: tmp=33
- Message.addField: vlt=33.3
- Radiocrafts.sendMessage: 001c8a34,920e1400b0514a0194592100
Warning: Should wait 10 mins before sending the next message
- Radiocrafts.sendBuffer: 0c920e1400b0514a0194592100
>> 0c 92 0e 14 00 b0 51 4a 01 94 59 21 00
<<
- Radiocrafts.sendBuffer: response:
Waiting 10 seconds...
Running loop #3
- Entering command mode...
- Radiocrafts.sendBuffer: 00
>> 00
<< 3e
- Radiocrafts.sendBuffer: response:
- Radiocrafts.enterCommandMode: OK
- Radiocrafts.sendBuffer: 55
>> 55
<< a1 3e
- Radiocrafts.sendBuffer: response: a1
- Exiting command mode...
- Radiocrafts.sendBuffer: 58
>> 58
<<
- Radiocrafts.sendBuffer: response:
- Radiocrafts.exitCommandMode: OK
- Radiocrafts.getTemperature: returned 33
- Entering command mode...
- Radiocrafts.sendBuffer: 00
>> 00
<< 3e
- Radiocrafts.sendBuffer: response:
- Radiocrafts.enterCommandMode: OK
- Radiocrafts.sendBuffer: 56
>> 56
<< 71 3e
- Radiocrafts.sendBuffer: response: 71
- Exiting command mode...
- Radiocrafts.sendBuffer: 58
>> 58
<<
- Radiocrafts.sendBuffer: response:
- Radiocrafts.exitCommandMode: OK
- Radiocrafts.getVoltage: returned 3.39
- Message.addField: ctr=3
- Message.addField: tmp=33
- Message.addField: vlt=33.3
- Radiocrafts.sendMessage: 001c8a34,920e1e00b0514a0194592100
Warning: Should wait 10 mins before sending the next message
- Radiocrafts.sendBuffer: 0c920e1e00b0514a0194592100
>> 0c 92 0e 1e 00 b0 51 4a 01 94 59 21 00
<<
- Radiocrafts.sendBuffer: response:
Waiting 10 seconds...
Running loop #4
- Entering command mode...
- Radiocrafts.sendBuffer: 00
>> 00
<< 3e
- Radiocrafts.sendBuffer: response:
- Radiocrafts.enterCommandMode: OK
- Radiocrafts.sendBuffer: 55
>> 55
<< a0 3e
- Radiocrafts.sendBuffer: response: a0
- Exiting command mode...
- Radiocrafts.sendBuffer: 58
>> 58
<<
- Radiocrafts.sendBuffer: response:
- Radiocrafts.exitCommandMode: OK
- Radiocrafts.getTemperature: returned 32
- Entering command mode...
- Radiocrafts.sendBuffer: 00
>> 00
<< 3e
- Radiocrafts.sendBuffer: response:
- Radiocrafts.enterCommandMode: OK
- Radiocrafts.sendBuffer: 56
>> 56
<< 71 3e
- Radiocrafts.sendBuffer: response: 71
- Exiting command mode...
- Radiocrafts.sendBuffer: 58
>> 58
<<
- Radiocrafts.sendBuffer: response:
- Radiocrafts.exitCommandMode: OK
- Radiocrafts.getVoltage: returned 3.39
- Message.addField: ctr=4
- Message.addField: tmp=32
- Message.addField: vlt=33.3
- Radiocrafts.sendMessage: 001c8a34,920e2800b051400194592100
Warning: Should wait 10 mins before sending the next message
- Radiocrafts.sendBuffer: 0c920e2800b051400194592100
>> 0c 92 0e 28 00 b0 51 40 01 94 59 21 00
<<
- Radiocrafts.sendBuffer: response:
Waiting 10 seconds...
Running loop #5
- Entering command mode...
- Radiocrafts.sendBuffer: 00
>> 00
<< 3e
- Radiocrafts.sendBuffer: response:
- Radiocrafts.enterCommandMode: OK
- Radiocrafts.sendBuffer: 55
>> 55
<< a0 3e
- Radiocrafts.sendBuffer: response: a0
- Exiting command mode...
- Radiocrafts.sendBuffer: 58
>> 58
<<
- Radiocrafts.sendBuffer: response:
- Radiocrafts.exitCommandMode: OK
- Radiocrafts.getTemperature: returned 32
- Entering command mode...
- Radiocrafts.sendBuffer: 00
>> 00
<< 3e
- Radiocrafts.sendBuffer: response:
- Radiocrafts.enterCommandMode: OK
- Radiocrafts.sendBuffer: 56
>> 56
<< 71 3e
- Radiocrafts.sendBuffer: response: 71
- Exiting command mode...
- Radiocrafts.sendBuffer: 58
>> 58
<<
- Radiocrafts.sendBuffer: response:
- Radiocrafts.exitCommandMode: OK
- Radiocrafts.getVoltage: returned 3.39
- Message.addField: ctr=5
- Message.addField: tmp=32
- Message.addField: vlt=33.3
- Radiocrafts.sendMessage: 001c8a34,920e3200b051400194592100
Warning: Should wait 10 mins before sending the next message
- Radiocrafts.sendBuffer: 0c920e3200b051400194592100
>> 0c 92 0e 32 00 b0 51 40 01 94 59 21 00
<<
- Radiocrafts.sendBuffer: response:
Waiting 10 seconds...
Running loop #6
- Entering command mode...
- Radiocrafts.sendBuffer: 00
>> 00
<< 3e
- Radiocrafts.sendBuffer: response:
- Radiocrafts.enterCommandMode: OK
- Radiocrafts.sendBuffer: 55
>> 55
<< a0 3e
- Radiocrafts.sendBuffer: response: a0
- Exiting command mode...
- Radiocrafts.sendBuffer: 58
>> 58
<<
- Radiocrafts.sendBuffer: response:
- Radiocrafts.exitCommandMode: OK
- Radiocrafts.getTemperature: returned 32
- Entering command mode...
- Radiocrafts.sendBuffer: 00
>> 00
<< 3e
- Radiocrafts.sendBuffer: response:
- Radiocrafts.enterCommandMode: OK
- Radiocrafts.sendBuffer: 56
>> 56
<< 71 3e
- Radiocrafts.sendBuffer: response: 71
- Exiting command mode...
- Radiocrafts.sendBuffer: 58
>> 58
<<
- Radiocrafts.sendBuffer: response:
- Radiocrafts.exitCommandMode: OK
- Radiocrafts.getVoltage: returned 3.39
- Message.addField: ctr=6
- Message.addField: tmp=32
- Message.addField: vlt=33.3
- Radiocrafts.sendMessage: 001c8a34,920e3c00b051400194592100
Warning: Should wait 10 mins before sending the next message
- Radiocrafts.sendBuffer: 0c920e3c00b051400194592100
>> 0c 92 0e 3c 00 b0 51 40 01 94 59 21 00
<<
- Radiocrafts.sendBuffer: response:
Waiting 10 seconds...
Running loop #7
- Entering command mode...
- Radiocrafts.sendBuffer: 00
>> 00
<< 3e
- Radiocrafts.sendBuffer: response:
- Radiocrafts.enterCommandMode: OK
- Radiocrafts.sendBuffer: 55
>> 55
<< a1 3e
- Radiocrafts.sendBuffer: response: a1
- Exiting command mode...
- Radiocrafts.sendBuffer: 58
>> 58
<<
- Radiocrafts.sendBuffer: response:
- Radiocrafts.exitCommandMode: OK
- Radiocrafts.getTemperature: returned 33
- Entering command mode...
- Radiocrafts.sendBuffer: 00
>> 00
<< 3e
- Radiocrafts.sendBuffer: response:
- Radiocrafts.enterCommandMode: OK
- Radiocrafts.sendBuffer: 56
>> 56
<< 71 3e
- Radiocrafts.sendBuffer: response: 71
- Exiting command mode...
- Radiocrafts.sendBuffer: 58
>> 58
<<
- Radiocrafts.sendBuffer: response:
- Radiocrafts.exitCommandMode: OK
- Radiocrafts.getVoltage: returned 3.39
- Message.addField: ctr=7
- Message.addField: tmp=33
- Message.addField: vlt=33.3
- Radiocrafts.sendMessage: 001c8a34,920e4600b0514a0194592100
Warning: Should wait 10 mins before sending the next message
- Radiocrafts.sendBuffer: 0c920e4600b0514a0194592100
>> 0c 92 0e 46 00 b0 51 4a 01 94 59 21 00
<<
- Radiocrafts.sendBuffer: response:
Waiting 10 seconds...
Running loop #8
- Entering command mode...
- Radiocrafts.sendBuffer: 00
>> 00
<< 3e
- Radiocrafts.sendBuffer: response:
- Radiocrafts.enterCommandMode: OK
- Radiocrafts.sendBuffer: 55
>> 55
<< a0 3e
- Radiocrafts.sendBuffer: response: a0
- Exiting command mode...
- Radiocrafts.sendBuffer: 58
>> 58
<<
- Radiocrafts.sendBuffer: response:
- Radiocrafts.exitCommandMode: OK
- Radiocrafts.getTemperature: returned 32
- Entering command mode...
- Radiocrafts.sendBuffer: 00
>> 00
<< 3e
- Radiocrafts.sendBuffer: response:
- Radiocrafts.enterCommandMode: OK
- Radiocrafts.sendBuffer: 56
>> 56
<< 71 3e
- Radiocrafts.sendBuffer: response: 71
- Exiting command mode...
- Radiocrafts.sendBuffer: 58
>> 58
<<
- Radiocrafts.sendBuffer: response:
- Radiocrafts.exitCommandMode: OK
- Radiocrafts.getVoltage: returned 3.39
- Message.addField: ctr=8
- Message.addField: tmp=32
- Message.addField: vlt=33.3
- Radiocrafts.sendMessage: 001c8a34,920e5000b051400194592100
Warning: Should wait 10 mins before sending the next message
- Radiocrafts.sendBuffer: 0c920e5000b051400194592100
>> 0c 92 0e 50 00 b0 51 40 01 94 59 21 00
<<
- Radiocrafts.sendBuffer: response:
Waiting 10 seconds...
Running loop #9
- Entering command mode...
- Radiocrafts.sendBuffer: 00
>> 00
<< 3e
- Radiocrafts.sendBuffer: response:
- Radiocrafts.enterCommandMode: OK
- Radiocrafts.sendBuffer: 55
>> 55
<< a1 3e
- Radiocrafts.sendBuffer: response: a1
- Exiting command mode...
- Radiocrafts.sendBuffer: 58
>> 58
<<
- Radiocrafts.sendBuffer: response:
- Radiocrafts.exitCommandMode: OK
- Radiocrafts.getTemperature: returned 33
- Entering command mode...
- Radiocrafts.sendBuffer: 00
>> 00
<< 3e
- Radiocrafts.sendBuffer: response:
- Radiocrafts.enterCommandMode: OK
- Radiocrafts.sendBuffer: 56
>> 56
<< 71 3e
- Radiocrafts.sendBuffer: response: 71
- Exiting command mode...
- Radiocrafts.sendBuffer: 58
>> 58
<<
- Radiocrafts.sendBuffer: response:
- Radiocrafts.exitCommandMode: OK
- Radiocrafts.getVoltage: returned 3.39
- Message.addField: ctr=9
- Message.addField: tmp=33
- Message.addField: vlt=33.3
- Radiocrafts.sendMessage: 001c8a34,920e5a00b0514a0194592100
Warning: Should wait 10 mins before sending the next message
- Radiocrafts.sendBuffer: 0c920e5a00b0514a0194592100
>> 0c 92 0e 5a 00 b0 51 4a 01 94 59 21 00
<<
- Radiocrafts.sendBuffer: response:
STOPSTOPSTOP: Messages sent successfully: 10, failed: 0
All good, it's working as it should now. appreciate your help.
To use Message method to send the data to sigfox, such as:
Message msg(transceiver); // Will contain the structured sensor data. msg.addField("ctr", counter); // 4 bytes for the counter. msg.send();
It is impossible, you can never successfully send message if you ever comment this line from any of your example before you declare a Message object.
int temperature; transceiver.getTemperature(temperature);
It seems that by using get temperature, you enter command mode:
Else you only see Message.addField: xxxx at your console.