aboutsummaryrefslogtreecommitdiff
path: root/example/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'example/main.go')
-rw-r--r--example/main.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/example/main.go b/example/main.go
index 3986791..884ee36 100644
--- a/example/main.go
+++ b/example/main.go
@@ -9,6 +9,7 @@ import (
"google.golang.org/protobuf/proto"
"os"
"os/signal"
+ "time"
)
func main() {
@@ -37,7 +38,9 @@ func main() {
pkt := msg.(*pb.MeshPacket)
log.Info("Received message from radio", "msg", pkt)
})
- if client.Connect() != nil {
+ ctxTimeout, cancelTimeout := context.WithTimeout(ctx, 10*time.Second)
+ defer cancelTimeout()
+ if client.Connect(ctxTimeout) != nil {
panic("Failed to connect to the radio")
}