examples: use shorter names for Lora radio functions

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram
2023-01-08 18:51:03 +01:00
parent 38ba7772e2
commit 24b6f0f296
5 changed files with 22 additions and 22 deletions
+4 -4
View File
@@ -67,7 +67,7 @@ func msg(data string) error {
cmd := "MSG" cmd := "MSG"
writeCommandOutput(cmd, "Start") writeCommandOutput(cmd, "Start")
if err := radio.LoraTx([]byte(data), defaultTimeout); err != nil { if err := radio.Tx([]byte(data), defaultTimeout); err != nil {
writeCommandOutput(cmd, err.Error()) writeCommandOutput(cmd, err.Error())
return err return err
@@ -82,7 +82,7 @@ func cmsg(data string) error {
cmd := "CMSG" cmd := "CMSG"
writeCommandOutput(cmd, "Start") writeCommandOutput(cmd, "Start")
if err := radio.LoraTx([]byte(data), defaultTimeout); err != nil { if err := radio.Tx([]byte(data), defaultTimeout); err != nil {
writeCommandOutput(cmd, err.Error()) writeCommandOutput(cmd, err.Error())
return err return err
@@ -337,7 +337,7 @@ func send(data string) error {
// remove leading/trailing quotes // remove leading/trailing quotes
data = strings.Trim(data, "\"'") data = strings.Trim(data, "\"'")
if err := radio.LoraTx([]byte(data), defaultTimeout); err != nil { if err := radio.Tx([]byte(data), defaultTimeout); err != nil {
writeCommandOutput(cmd, err.Error()) writeCommandOutput(cmd, err.Error())
return err return err
@@ -363,7 +363,7 @@ func sendhex(data string) error {
return err return err
} }
if err := radio.LoraTx(payload, defaultTimeout); err != nil { if err := radio.Tx(payload, defaultTimeout); err != nil {
writeCommandOutput(cmd, err.Error()) writeCommandOutput(cmd, err.Error())
return err return err
+8 -8
View File
@@ -11,12 +11,12 @@ var (
type LoraRadio interface { type LoraRadio interface {
Reset() Reset()
LoraTx(pkt []uint8, timeoutMs uint32) error Tx(pkt []uint8, timeoutMs uint32) error
LoraRx(timeoutMs uint32) ([]uint8, error) Rx(timeoutMs uint32) ([]uint8, error)
SetLoraFrequency(freq uint32) SetFrequency(freq uint32)
SetLoraIqMode(mode uint8) SetIqMode(mode uint8)
SetLoraCodingRate(cr uint8) SetCodingRate(cr uint8)
SetLoraBandwidth(bw uint8) SetBandwidth(bw uint8)
SetLoraCrc(enable bool) SetCrc(enable bool)
SetLoraSpreadingFactor(sf uint8) SetSpreadingFactor(sf uint8)
} }
+8 -8
View File
@@ -13,20 +13,20 @@ type SimLoraRadio struct {
func (sr *SimLoraRadio) Reset() { func (sr *SimLoraRadio) Reset() {
} }
func (sr *SimLoraRadio) LoraTx(pkt []uint8, timeoutMs uint32) error { func (sr *SimLoraRadio) Tx(pkt []uint8, timeoutMs uint32) error {
return nil return nil
} }
func (sr *SimLoraRadio) LoraRx(timeoutMs uint32) ([]uint8, error) { func (sr *SimLoraRadio) Rx(timeoutMs uint32) ([]uint8, error) {
return nil, nil return nil, nil
} }
func (sr *SimLoraRadio) SetLoraFrequency(freq uint32) {} func (sr *SimLoraRadio) SetFrequency(freq uint32) {}
func (sr *SimLoraRadio) SetLoraIqMode(mode uint8) {} func (sr *SimLoraRadio) SetIqMode(mode uint8) {}
func (sr *SimLoraRadio) SetLoraCodingRate(cr uint8) {} func (sr *SimLoraRadio) SetCodingRate(cr uint8) {}
func (sr *SimLoraRadio) SetLoraBandwidth(bw uint8) {} func (sr *SimLoraRadio) SetBandwidth(bw uint8) {}
func (sr *SimLoraRadio) SetLoraCrc(enable bool) {} func (sr *SimLoraRadio) SetCrc(enable bool) {}
func (sr *SimLoraRadio) SetLoraSpreadingFactor(sf uint8) {} func (sr *SimLoraRadio) SetSpreadingFactor(sf uint8) {}
func firmwareVersion() string { func firmwareVersion() string {
return "simulator " + currentVersion() return "simulator " + currentVersion()
+1 -1
View File
@@ -65,5 +65,5 @@ func firmwareVersion() string {
} }
func lorarx() ([]byte, error) { func lorarx() ([]byte, error) {
return loraRadio.LoraRx(LORA_DEFAULT_RXTIMEOUT_MS) return loraRadio.Rx(LORA_DEFAULT_RXTIMEOUT_MS)
} }
+1 -1
View File
@@ -81,5 +81,5 @@ func firmwareVersion() string {
} }
func lorarx() ([]byte, error) { func lorarx() ([]byte, error) {
return loraRadio.LoraRx(LORA_DEFAULT_RXTIMEOUT_MS) return loraRadio.Rx(LORA_DEFAULT_RXTIMEOUT_MS)
} }