stm32duino / STM32LoRaWAN

Arduino library to support LoRaWAN communication using the STM32WL series.
https://stm32duino.github.io/STM32LoRaWAN/
Other
37 stars 7 forks source link

la915 #42

Open tcpipchip opened 2 months ago

tcpipchip commented 2 months ago

got some progress to port to LA915. I rebuilt the AU915 files. Start Setting TX Config: modem=MODEM_LORA, power=30, fdev=0, bandwidth=0, datarate=10, coderate=1 preambleLen=8, fixLen=0, crcOn=1, freqHopOn=0, hopPeriod=0, iqInverted=0, timeout=4000 TX on freq 916400000 Hz at DR 2 TX: 00 41 1c fc 7f 67 e9 4a 53 25 cc 1f 05 15 e1 80 00 d0 aa 44 08 15 83 MAC txDone RX_1 on freq 926900000 Hz at DR 10 MAC rxDone RX: 204b5717c2185f9767d9e924db27d5d687 MlmeConfirm: req=MLME_JOIN, status=LORAMAC_EVENT_INFO_STATUS_OK, airtime=371, margin=0, gateways=0 Joined Setting TX Config: modem=MODEM_LORA, power=30, fdev=0, bandwidth=0, datarate=10, coderate=1 preambleLen=8, fixLen=0, crcOn=1, freqHopOn=0, hopPeriod=0, iqInverted=0, timeout=4000 TX on freq 916000000 Hz at DR 2 TX: 80 66 3a 34 16 80 01 00 01 7b 1e e3 9c 97 55 af 3b 5d 14 39 9e da ee 09 8f 01 9f 44 14 8e 62 c2 15 73 MAC txDone RX_1 on freq 925700000 Hz at DR 10 MAC rxDone RX: 60663a3416b0000000a3d35d8dcfb5246ecd829b7d7ce842fe9f26116b880ca1b2ceb76ba2 McpsConfirm: req=MCPS_CONFIRMED, status=LORAMAC_EVENT_INFO_STATUS_OK, datarate=2, power=0, ack=1, retries=1, airtime=453, upcnt=1, channel=4 McpsIndication: ind=MCPS_UNCONFIRMED, status=LORAMAC_EVENT_INFO_STATUS_OK, multicast=0, port=0, datarate=10, pending=1, size=0, rxdata=0, ack=1, dncnt=0, devaddr=16343a66, rssi=-101, snr=-3, slot=0 Sent packet Setting TX Config: modem=MODEM_LORA, power=10, fdev=0, bandwidth=0, datarate=12, coderate=1 preambleLen=8, fixLen=0, crcOn=1, freqHopOn=0, hopPeriod=0, iqInverted=0, timeout=4000 TX on freq 916600000 Hz at DR 0 TX: 80 66 3a 34 16 8a 02 00 09 03 07 03 07 03 07 04 05 07 01 7a 7d 25 de 9f ed 32 d7 50 97 5d 0e e2 65 de 0c 5c 3f 2d da 17 3a 5c 1d 6e MAC txDone RX_1 on freq 927500000 Hz at DR 8 MAC rxDone RX: a0663a3416a0010001c46c6ee956088be8d2c1 McpsConfirm: req=MCPS_CONFIRMED, status=LORAMAC_EVENT_INFO_STATUS_OK, datarate=0, power=10, ack=1, retries=1, airtime=2139, upcnt=2, channel=7 McpsIndication: ind=MCPS_CONFIRMED, status=LORAMAC_EVENT_INFO_STATUS_OK, multicast=0, port=1, datarate=8, pending=1, size=6, rxdata=1, ack=1, dncnt=1, devaddr=16343a66, rssi=-101, snr=-2, slot=0 Sent packet Received packet on port 1: 6D 69 67 75 65 6C

tcpipchip commented 2 months ago

Still running well on LA915 (LATIN AMERICA) sir, how can i access the LOG info core_debug( "McpsIndication: ind=%s, status=%s, multicast=%u, port=%u, datarate=%u, pending=%u, size=%u, rxdata=%u, ack=%u, dncnt=%u, devaddr=%08x, rssi=%d, snr=%d, slot=%u\r\n", toString(i->McpsIndication), ### toString(i->Status), i->Multicast, i->Port, i->RxDatarate, i->IsUplinkTxPending, i->BufferSize, i->RxData, i->AckReceived, i->DownLinkCounter, i->DevAddress, status->Rssi, status->Snr, status->RxSlot);

--> toString(i->Status) <--- Inside the Arduino code ?

fpistm commented 2 months ago

Enable the debug.

tcpipchip commented 2 months ago

Yes, but i want to get access to that Status from my main source code. For example, i want to compare if toString(i->Status) = LORAMAC_EVENT_INFO_STATUS_OK, for example...

fpistm commented 2 months ago

Could you point exactly where it is?

tcpipchip commented 2 months ago

yes, of course

void STM32LoRaWAN::MacMcpsConfirm(McpsConfirm_t* c) {
  // Called after an Mcps request (data TX) when the stack becomes idle again (so after RX windows)
  strcpy(STAT, toString(c->Status));
  core_debug(
    "McpsConfirm: req=%s, status=%s, datarate=%u, power=%d, ack=%u, %s=%u, airtime=%u, upcnt=%u, channel=%u\r\n",
     toString(c->McpsRequest), toString(c->Status), c->Datarate, c->TxPower,
     c->AckReceived,
    #if (defined( LORAMAC_VERSION ) && ( LORAMAC_VERSION == 0x01000300 ))
      "retries", c->NbRetries,
    #elif (defined( LORAMAC_VERSION ) && ( LORAMAC_VERSION == 0x01000400 ))
      "trans", c->NbTrans,
    #endif /* LORAMAC_VERSION */
    (unsigned)c->TxTimeOnAir, (unsigned)c->UpLinkCounter, (unsigned)c->Channel);
  instance->last_tx_acked = c->AckReceived;
  instance->fcnt_up = c->UpLinkCounter;
}

On stm32lorawan.cpp

I want to compare if the toString(c->Status) has some value on Arduino code.

tcpipchip commented 2 months ago

hi @fpistm my workaround is create a extern variable...but i dont like this :)

char STAT[128];

void STM32LoRaWAN::MacMcpsConfirm(McpsConfirm_t* c) {
  // Called after an Mcps request (data TX) when the stack becomes idle again (so after RX windows)
  strcpy(STAT, toString(c->Status));

and in the C Arduino

extern char STAT[128]; to have access to that variable with Status of LoRaWAN mac

tcpipchip commented 2 months ago

work around

void lora_done()
{
  // If, after calling maintain() the library is no longer
  // busy, then the asynchronous operation has completed,
  // so check its results.
  String STAT_R = String(STAT);
  if (lora_state == TRANSMITTING) {
    if (STAT_R == "LORAMAC_EVENT_INFO_STATUS_OK")
       Serial.println("Sent packet");
    else
       Serial.println("Fail sent packet");    
fpistm commented 2 months ago

Hi @tcpipchip Please try to format the code else it is really hard to read.

It is fine if you achieve to get the value you want.