chirpstack / chirpstack-gateway-bridge

ChirpStack Gateway Bridge abstracts Packet Forwarder protocols into Protobuf or JSON over MQTT.
https://www.chirpstack.io
MIT License
415 stars 269 forks source link

Long interleaving CodeRate is not support on semtechudp downlink. #217

Closed ian-lee-mxc closed 1 year ago

ian-lee-mxc commented 1 year ago

What happened?

When using with Semtech gateway_2g4_hal, the downlink will get an error. It complains of an invalid CodeRate CR_LORA_LI_4_8.

What did you expect?

The gateway_2g4_hal could works with the Chirpstack v4.

Steps to reproduce this issue

Steps:

  1. Setup the chirpstack-docker with gateway-bridge for ISM2400.
  2. Run the lora_pkg_fwd of gateway_2g4_hal, which using CR_LORA_LI_4_8 for CodeRate.
  3. Config gateway and device
  4. Device sending JOIN Request
  5. When server sending JOIN Accept, the gateway-bridge will report invalid CodeRate error.

Patch

diff --git a/internal/backend/semtechudp/packets/pull_resp.go b/internal/backend/semtechudp/packets/pull_resp.go
index 46320b5..60e5496 100644
--- a/internal/backend/semtechudp/packets/pull_resp.go
+++ b/internal/backend/semtechudp/packets/pull_resp.go
@@ -117,6 +117,12 @@ func GetPullRespPacket(protoVersion uint8, randomToken uint16, frame *gw.Downlin
            packet.Payload.TXPK.CodR = "4/7"
        case gw.CodeRate_CR_4_8:
            packet.Payload.TXPK.CodR = "4/8"
+       case gw.CodeRate_CR_LI_4_5:
+           packet.Payload.TXPK.CodR = "4/5LI"
+       case gw.CodeRate_CR_LI_4_6:
+           packet.Payload.TXPK.CodR = "4/6LI"
+       case gw.CodeRate_CR_LI_4_8:
+           packet.Payload.TXPK.CodR = "4/8LI"
        default:
            return PullRespPacket{}, fmt.Errorf("invalid CodeRate: %s", lora.GetCodeRate())
        }
-- 
2.25.1

Your Environment

Docker images chirpstack/chirpstack:4.0.5 chirpstack-gateway-bridge:4.0.1 chirpstack-rest-api:4.0.4

brocaar commented 1 year ago

Thanks for reporting :+1: