arduino-lmic
arduino-lmic copied to clipboard
Can have that library a TX_INTERVAL over 3600?
Hello, (can you read my fift post?) I actually have a problem and I have pain to debug or to find the start point to debug it.
I am collecting data sensor and I sent it each hour. It works fine. But know I change the schedule to 2 hours (even 4 hours) and the data are not sent any more.
What I know, the program stop at at the second attend
LMIC_setTxData2(1, payload, strlen((char *)payload-1), 0);
In other words, when I lunch the data are sent. Because I setedup
const unsigned TX_INTERVAL = 7200; // 2h
it wait 2 hour until the next send, amd it just before the funtion
LMIC_setTxData2(1, payload, strlen((char *)payload-1), 0);
that the program stop
I also tried with
LMIC_setTxData2(1, payload, sizeof(payload)-1, 0);
But with this, it's not send at the fiirst attend. At least I do not have the message
1475691: EV_TXCOMPLETE (includes waiting for RX windows)
The problem I have, I do not know wher to debug because my program has always been working. But it's true, I always schedule the send below 1h.
'payload' is not overloaded.
Do you have any suggestion to start looking into the code , or the library to fix the problem? Do you have any question which help to support me?
Thank a lot
Pierrot, not sure this is the root cause but as I read
strlen((char *)payload-1)
I understand "length of the string starting 1 byte before payload".
Maybe you want to use instead :
strlen((char *)payload) - 1 ?
Dear DeuxVis, Yes, I observed it just after posting my post. I have not replied yet, because I am testing my code with the cottection you mentionned, and I need to wait two hours. May be it's the cause but in any case, this look wrong. I got a result in about 30mn.
Hello, Unfortunately, it did not solve the problem
Si.sprintln(F("hhhhhhh"),2);
// Prepare upstream data transmission at the next possible time.
LMIC_setTxData2(1, payload, strlen((char *)payload)-1, 0);
My program stopped juste after 'hhhhhhhhh'
Is there a wayto debug the Arduino-LMIC library? I went to the cofnig file I changed
#define LMIC_DEBUG_LEVEL 1
but I can not compile any more because of this message:
C:\Users\pierrot\Documents\Arduino\libraries\arduino-lmic-master\src\hal\hal.cpp:223:54: error: '_FDEV_SETUP_WRITE' was not declared in this scope
fdev_setup_stream (&uartout, uart_putchar, NULL, _FDEV_SETUP_WRITE);
As I do have an AVR Feather MO adalogger, I am not sure if I can use this function, but I really want to be able to print message to my terminal, by adding some thing like Serial.println("DEBUG"); in order to tracl the issue
Apparently, this
int LMIC_setTxData2 (u1_t port, xref2u1_t data, u1_t dlen, u1_t confirmed) {
if( dlen > SIZEOFEXPR(LMIC.pendTxData) )
//Serial.println("return -2");
return -2;
if( data != (xref2u1_t)0 ){
//Serial.println("oc_copyMem");
os_copyMem(LMIC.pendTxData, data, dlen);
}
LMIC.pendTxConf = confirmed;
LMIC.pendTxPort = port;
LMIC.pendTxLen = dlen;
//Serial.println("LMIC_setTxData")
LMIC_setTxData();
return 0;
}
return me -2, but I can not print the value of dlen and SIZEOFEXPR()
I really wonder if the library can have a TX_INTERVAL over 3600.
I take that exemple ttn-abp and I only replaced
static uint8_t mydata[] = "Hello, world!";
to
static uint8_t mydata[] = "26,0,364,53,108,0,0,0,0,0,0,0";
const unsigned = 60;
to
const unsigned TX_INTERVAL = 7200;
and adapt
// Pin mapping
const lmic_pinmap lmic_pins = {
.nss = 5,
.rxtx = LMIC_UNUSED_PIN,
.rst = 6,
.dio = {10, 11, 12},
};
and after two hours, I have not get a new line as
762110: EV_TXCOMPLETE (includes waiting for RX windows)
What is the maximum of TX_INTERVAL ???
@pierrot10 , could you try to change
const unsigned TX_INTERVAL = 7200;
to
const int32_t TX_INTERVAL = 7200;
@pierrot10 , did that work ?
Dear gizmocuz, I just discover your answer 20mn ago. I will try it this evening and let you know tomorrow as I need at least two hours to have two measures. But it's look interesting. By the way, I wonder if I should better do
const unsigned long TX_INTERVAL
At the time writing, I reading this article Using millis() for timing. A beginners guide
- It is an unsigned long because that is what millis() returns.
- It is important that it is unsigned (more on this later)
I come back to you tomorrow, but I will try the two solution (int32_t, uint32_t and long)
@pierrot10 , actually the best is to define it, like
#define TX_INTERVAL 7200
I see it is used in this function, which returns a int64_t function:
#define sec2osticks(sec) ((ostime_t)( (int64_t)(sec) * OSTICKS_PER_SEC))
Hope it works ! Thats some long delay between transmits ;)
Appently none ofthis work.
I tried
const unsigned long TX_INTERVAL
and
#define TX_INTERVAL 7200
The program bug or stop running just before the enxt send
LMIC_setTxData2(1, payload, strlen((char *)payload)-1, 0);
I can not understanf how work the intervals TX_INTERVAL
Thats some long delay between transmits ;) I ma measuring the soil moisture and I do not need to send the easure each minute. Each two hours is enough and I am planning to measure ech 4 hours.
Apparently it's work if I send each hour, but not each I extend the intervals.
Any idea what happen?
Should I try with
const int64_t TX_INTERVAL
but that will really make the difference?
Thank for helping
Do you have an idea ow work the arduino-lmic interval? When the interval is "rested" after sending?
I take my sensor measure at the
do_send funtion. Just before
LMIC_setTxData2(1, payload, strlen((char *)payload)-1, 0);
I am wondering if I can add my own interval within the do_send function.
Somethink like this:
const unsigned long INTERVAL_LORA = 7200;
void do_send(osjob_t* j){
// Check if there is not a current TX/RX job running
if (LMIC.opmode & OP_TXRXPEND) {
Serial.println(F("OP_TXRXPEND, not sending"));
} else {
if (millis()/1000 > scheduler_lora)
{
scheduler_lora = millis()/1000 + INTERVAL_LORA;
get_wmsmx(); //moisture
get_baro();
get_luminosity();
/*
here come the code to save measure in payload
*/
LMIC_setTxData2(1, payload, strlen((char *)payload)-1, 0);
}
}
I really have pain to understand how work the arduino-lmic interval and WHY can I not send each 2 hours :)