mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-16 12:53:23 +00:00
lorawan cleanup and optimizations:
- Remove all default loraconf default initialisation in lorawan examples (Region Settings takes care of this now) - Remove retries while receiving JoinAccept and increase LoraRX to 10s (no need to wait more than 10s) - Add constants for RegionSetting default frequencies - Standardize all lora default configurations in lora examples - Add new AT+LW=NET,(ON|OFF) command in atcmd example
This commit is contained in:
committed by
deadprogram
parent
4e687b29c3
commit
fa0cf6ec7f
+10
-7
@@ -276,8 +276,8 @@ func (d *Device) SetCodingRate(cr uint8) {
|
||||
d.WriteRegister(SX127X_REG_MODEM_CONFIG_1, (d.ReadRegister(SX127X_REG_MODEM_CONFIG_1)&0xf1)|(cr<<1))
|
||||
}
|
||||
|
||||
// SetImplicitHeaderModeOn Enables implicit header mode ***
|
||||
func (d *Device) SetHeaderMode(headerType uint8) {
|
||||
// SetHeaderType set implicit or explicit mode
|
||||
func (d *Device) SetHeaderType(headerType uint8) {
|
||||
d.loraConf.HeaderType = headerType
|
||||
if headerType == lora.HeaderImplicit {
|
||||
d.WriteRegister(SX127X_REG_MODEM_CONFIG_1, d.ReadRegister(SX127X_REG_MODEM_CONFIG_1)|0x01)
|
||||
@@ -346,6 +346,14 @@ func (d *Device) SetIqMode(val uint8) {
|
||||
d.WriteRegister(SX127X_REG_INVERTIQ2, 0x19)
|
||||
}
|
||||
}
|
||||
// SetPublicNetwork changes Sync Word to match network type
|
||||
func (d *Device) SetPublicNetwork(enabled bool) {
|
||||
if enabled {
|
||||
d.SetSyncWord(SX127X_LORA_MAC_PUBLIC_SYNCWORD)
|
||||
} else {
|
||||
d.SetSyncWord(SX127X_LORA_MAC_PRIVATE_SYNCWORD)
|
||||
}
|
||||
|
||||
|
||||
// Tx sends a lora packet, (with timeout)
|
||||
func (d *Device) Tx(pkt []uint8, timeoutMs uint32) error {
|
||||
@@ -538,9 +546,4 @@ func bandwidth(bw uint8) uint8 {
|
||||
}
|
||||
}
|
||||
|
||||
func syncword(sw int) uint16 {
|
||||
if sw == lora.SyncPublic {
|
||||
return SX127X_LORA_MAC_PUBLIC_SYNCWORD
|
||||
}
|
||||
return SX127X_LORA_MAC_PRIVATE_SYNCWORD
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user