diff --git a/cli/cmd/deviceSubscribe.go b/cli/cmd/deviceSubscribe.go index baa3a86f248fd8c12257264a74498b873e06609e..dbe2e5c9edf87b74567e65d56e1f2dcca3ac3a6f 100644 --- a/cli/cmd/deviceSubscribe.go +++ b/cli/cmd/deviceSubscribe.go @@ -63,11 +63,11 @@ The device UUID and request path must be specified as a positional arguments.`, Subscription: []*pnd.Subscription{ { Path: args[1], - StreamMode: pnd.StreamMode_STREAM_MODE_TARGET_DEFINED, + StreamMode: pnd.StreamMode_STREAM_MODE_SAMPLE, SampleInterval: 1000000000, }, }, - Mode: pnd.SubscriptionMode_SUBSCRIPTION_MODE_ONCE, + Mode: pnd.SubscriptionMode_SUBSCRIPTION_MODE_STREAM, }, ) if err != nil { diff --git a/controller/nucleus/gnmi_transport.go b/controller/nucleus/gnmi_transport.go index 8b8e5a2c3d4ad64bbdc9f752106ded25dfcf3c04..5e7e2e145e79d937774aef1a3fd2694261a9c66c 100644 --- a/controller/nucleus/gnmi_transport.go +++ b/controller/nucleus/gnmi_transport.go @@ -198,7 +198,7 @@ func (g *Gnmi) Subscribe(ctx context.Context, params ...string) error { if g.client == nil { return &errors.ErrNilClient{} } - return g.subscribe(ctx) + return g.subscribe2(ctx) } // Type returns the gNMI transport type @@ -330,7 +330,7 @@ func (g *Gnmi) subscribe(ctx context.Context) error { } // Subscribe calls GNMI subscribe -func (g *Gnmi) subscribe2(ctx context.Context, stringRespChan chan string) error { +func (g *Gnmi) subscribe2(ctx context.Context) error { ctx = gnmi.NewContext(ctx, g.config) opts, ok := ctx.Value(types.CtxKeyOpts).(*gnmi.SubscribeOptions) if !ok { @@ -339,6 +339,19 @@ func (g *Gnmi) subscribe2(ctx context.Context, stringRespChan chan string) error Type: &gnmi.SubscribeOptions{}, } } + stringRespChan := make(chan string) + + go func() { + for { + resp := <-stringRespChan + if resp != "" { + log.Info(resp) + } else { + log.Info("recieved empty string") + } + } + }() + go func() { log.WithFields(log.Fields{ "address": opts.Target,