fix xbee cli info
This commit is contained in:
parent
1c51a6da90
commit
27f0e349ba
|
@ -5,6 +5,7 @@ package cli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
@ -78,6 +79,11 @@ writtend to stdout.
|
||||||
`,
|
`,
|
||||||
Action: netcat,
|
Action: netcat,
|
||||||
HideHelpCommand: true,
|
HideHelpCommand: true,
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "hex",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -85,7 +91,7 @@ writtend to stdout.
|
||||||
func xbeeInfo(ctx *cli.Context) error {
|
func xbeeInfo(ctx *cli.Context) error {
|
||||||
|
|
||||||
logger := slog.New(slog.NewTextHandler(os.Stderr))
|
logger := slog.New(slog.NewTextHandler(os.Stderr))
|
||||||
transport := ctx.Context.Value(keyIODevice).(xbee.Transport)
|
transport := ctx.Context.Value(keyIODevice).(*xbee.Transport)
|
||||||
xb, err := xbee.NewSession(transport, logger.With("device", transport.Type()))
|
xb, err := xbee.NewSession(transport, logger.With("device", transport.Type()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cli.Exit(err, 1)
|
return cli.Exit(err, 1)
|
||||||
|
@ -95,7 +101,7 @@ func xbeeInfo(ctx *cli.Context) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cli.Exit(err, 1)
|
return cli.Exit(err, 1)
|
||||||
}
|
}
|
||||||
fmt.Println(b)
|
fmt.Printf("Network ID: %X\n", binary.BigEndian.Uint16(b))
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -109,7 +115,7 @@ func netcat(ctx *cli.Context) error {
|
||||||
}
|
}
|
||||||
logger := slog.New(slog.NewTextHandler(os.Stderr))
|
logger := slog.New(slog.NewTextHandler(os.Stderr))
|
||||||
|
|
||||||
transport := ctx.Context.Value(keyIODevice).(xbee.Transport)
|
transport := ctx.Context.Value(keyIODevice).(*xbee.Transport)
|
||||||
xb, _ := xbee.NewSession(transport, logger.With("devtype", transport.Type()))
|
xb, _ := xbee.NewSession(transport, logger.With("devtype", transport.Type()))
|
||||||
|
|
||||||
sent := make(chan int64)
|
sent := make(chan int64)
|
||||||
|
|
Loading…
Reference in a new issue