forked from Elara6331/itd
3. Added builder
This commit is contained in:
@@ -89,7 +89,51 @@ type ITNode struct {
|
||||
path string
|
||||
}
|
||||
|
||||
func BuildRootNode(dev *infinitime.Device) *ITNode {
|
||||
inodemap = make(map[string]uint64)
|
||||
myfs, _ = dev.FS()
|
||||
|
||||
return &ITNode{kind: 0}
|
||||
}
|
||||
|
||||
var properties = make([]ITProperty, 6)
|
||||
|
||||
func BuildProperties(dev *infinitime.Device) {
|
||||
properties[0] = ITProperty{"heartrate", 2,
|
||||
func(ctx context.Context) (<-chan []byte, error) {
|
||||
ans, err := dev.WatchHeartRate(ctx)
|
||||
return converterU8(ctx, ans), err
|
||||
}}
|
||||
properties[1] = ITProperty{"battery", 3,
|
||||
func(ctx context.Context) (<-chan []byte, error) {
|
||||
ans, err := dev.WatchBatteryLevel(ctx)
|
||||
return converterU8(ctx, ans), err
|
||||
}}
|
||||
properties[2] = ITProperty{"motion", 4,
|
||||
func(ctx context.Context) (<-chan []byte, error) {
|
||||
ans, err := dev.WatchMotion(ctx)
|
||||
return converterMotionValues(ctx, ans), err
|
||||
}}
|
||||
properties[3] = ITProperty{"stepcount", 5,
|
||||
func(ctx context.Context) (<-chan []byte, error) {
|
||||
ans, err := dev.WatchStepCount(ctx)
|
||||
return converterU32(ctx, ans), err
|
||||
}}
|
||||
properties[4] = ITProperty{"version", 6,
|
||||
func(ctx context.Context) (<-chan []byte, error) {
|
||||
ans, err := dev.Version()
|
||||
return converter1String(ctx, ans), err
|
||||
}}
|
||||
properties[5] = ITProperty{"address", 7,
|
||||
func(ctx context.Context) (<-chan []byte, error) {
|
||||
ans := dev.Address()
|
||||
return converter1String(ctx, ans), nil
|
||||
}}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
var myfs *blefs.FS = nil;
|
||||
var inodemap map[string]uint64 = nil;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user