@@ -556,6 +556,10 @@ fsmDispatch(
556
556
}
557
557
558
558
case LMIC_COMPLIANCE_FSMSTATE_TESTMODE : {
559
+ if (LMIC .opmode & OP_TXDATA ) {
560
+ // stay here until we can do something
561
+ break ;
562
+ }
559
563
if (eventflags_TestAndClear (LMIC_COMPLIANCE_EVENT_DEACTIVATE )) {
560
564
newState = LMIC_COMPLIANCE_FSMSTATE_INACTIVE ;
561
565
} else if (eventflags_TestAndClear (LMIC_COMPLIANCE_EVENT_JOIN_CMD )) {
@@ -652,10 +656,12 @@ static void lmicEventCb(
652
656
);
653
657
}
654
658
655
- // if it's a EV_JOINED, we should tell the FSM.
659
+ // if it's a EV_JOINED, or a TXCMOMPLETE, we should tell the FSM.
656
660
if (ev == EV_JOINED ) {
657
661
LMIC_Compliance .eventflags |= LMIC_COMPLIANCE_EVENT_JOINED ;
658
662
fsmEvalDeferred ();
663
+ } else if (ev == EV_TXCOMPLETE ) {
664
+ fsmEvalDeferred ();
659
665
}
660
666
}
661
667
@@ -679,22 +685,34 @@ static void acSendUplink(void) {
679
685
LMIC_Compliance .eventflags &= ~LMIC_COMPLIANCE_EVENT_UPLINK_COMPLETE ;
680
686
681
687
// don't try to send if busy; might be sending echo message.
682
- if (( LMIC . opmode & OP_TXRXPEND ) == 0 &&
688
+ lmic_tx_error_t const eSend =
683
689
LMIC_sendWithCallback (
684
690
LORAWAN_PORT_COMPLIANCE ,
685
691
payload , sizeof (payload ),
686
692
/* confirmed? */
687
693
!! (LMIC_Compliance .fsmFlags & LMIC_COMPLIANCE_FSM_CONFIRM ),
688
- sendUplinkCompleteCb , NULL ) == 0 ) {
694
+ sendUplinkCompleteCb , NULL
695
+ );
696
+
697
+ if (eSend == LMIC_ERROR_SUCCESS ) {
689
698
// queued successfully
690
699
LMIC_COMPLIANCE_PRINTF (
691
- "lmic_compliance.acSendUplink: queued uplink message(%u, %p)\n" ,
700
+ "lmic_compliance.%s: queued uplink message(%u, %p)\n" ,
701
+ __func__ ,
692
702
(unsigned ) downlink & 0xFFFF ,
693
703
LMIC .client .txMessageCb
694
704
);
695
705
} else {
696
706
// failed to queue; just skip this cycle.
697
- sendUplinkCompleteCb (NULL , false);
707
+ LMIC_COMPLIANCE_PRINTF (
708
+ "lmic_compliance.%s: error(%d) sending uplink message(%u), %u bytes\n" ,
709
+ __func__ ,
710
+ eSend ,
711
+ (unsigned ) downlink & 0xFFFF ,
712
+ LMIC .client .txMessageCb
713
+ );
714
+ LMIC_Compliance .eventflags |= LMIC_COMPLIANCE_EVENT_UPLINK_COMPLETE ;
715
+ fsmEval ();
698
716
}
699
717
}
700
718
@@ -706,16 +724,18 @@ static void sendUplinkCompleteCb(void *pUserData, int fSuccess) {
706
724
707
725
static void acSendUplinkBuffer (void ) {
708
726
// send uplink data.
709
- if (LMIC_sendWithCallback (
727
+ lmic_tx_error_t const eSend =
728
+ LMIC_sendWithCallback (
710
729
LORAWAN_PORT_COMPLIANCE ,
711
730
LMIC_Compliance .uplinkMessage , LMIC_Compliance .uplinkSize ,
712
731
/* confirmed? */ (LMIC_Compliance .fsmFlags & LMIC_COMPLIANCE_FSM_CONFIRM ) != 0 ,
713
732
sendUplinkCompleteCb ,
714
- NULL ) == 0
715
- ) {
733
+ NULL );
734
+
735
+ if (eSend == LMIC_ERROR_SUCCESS ) {
716
736
LMIC_COMPLIANCE_PRINTF ("%s: queued %u bytes\n" , __func__ , LMIC_Compliance .uplinkSize );
717
737
} else {
718
- LMIC_COMPLIANCE_PRINTF ("%s: uplink %u bytes failed\n" , __func__ , LMIC_Compliance .uplinkSize );
738
+ LMIC_COMPLIANCE_PRINTF ("%s: uplink %u bytes failed (error %d) \n" , __func__ , LMIC_Compliance .uplinkSize , eSend );
719
739
LMIC_Compliance .eventflags |= LMIC_COMPLIANCE_EVENT_UPLINK_COMPLETE ;
720
740
fsmEval ();
721
741
}
0 commit comments