kubeedge / mappers-go

KubeEdge Device Mappers written in go
Apache License 2.0
46 stars 65 forks source link

the part of inittwin in ble mapper #62

Open 1180300515 opened 2 years ago

1180300515 commented 2 years ago

now i have a ble device , the twin propertyName is on-off , as it's name ,it control the sensor on-off ,the question is that it's property is write,so i can't read it's value ,but the twin has the desire and report value,so how can i get the report value? in the code about the func inittwin ,after the func setVisitor finish,it begin to judge whether the property is notify or read ,and then send the report value.but the property is write ,so i can't get the report value. the code is from device.go

if (c.Property&ble.CharNotify) != 0 && c.CCCD != nil {
    wg.Add(1)
    go func() {
        if err := twinData.BleClient.Client.Subscribe(c, false, twinData.notificationHandler()); err != nil {
            klog.Errorf("Subscribe error: %v", err)
            wg.Done()
        }
    }()
} else if (c.Property & ble.CharRead) != 0 { // // read data actively
        timer := mappercommon.Timer{Function: twinData.Run, Duration: collectCycle, Times: 0}
    wg.Add(1)
    go func() {
        defer wg.Done()
        timer.Start()
    }()
}