本文整理汇总了Golang中github.com/paypal/gatt/xpc.Dict.MustGetUUID方法的典型用法代码示例。如果您正苦于以下问题:Golang Dict.MustGetUUID方法的具体用法?Golang Dict.MustGetUUID怎么用?Golang Dict.MustGetUUID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/paypal/gatt/xpc.Dict
的用法示例。
在下文中一共展示了Dict.MustGetUUID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: respondToRequest
func (d *device) respondToRequest(id int, args xpc.Dict) {
switch id {
case 19: // ReadRequest
u := UUID{args.MustGetUUID("kCBMsgArgDeviceUUID")}
t := args.MustGetInt("kCBMsgArgTransactionID")
a := args.MustGetInt("kCBMsgArgAttributeID")
o := args.MustGetInt("kCBMsgArgOffset")
attr := d.attrs[a]
v := attr.value
if v == nil {
c := newCentral(d, u)
req := &ReadRequest{
Request: Request{Central: c},
Cap: int(c.mtu - 1),
Offset: o,
}
rsp := newResponseWriter(int(c.mtu - 1))
if c, ok := attr.pvt.(*Characteristic); ok {
c.rhandler.ServeRead(rsp, req)
v = rsp.bytes()
}
}
d.sendCmd(13, xpc.Dict{
"kCBMsgArgAttributeID": a,
"kCBMsgArgData": v,
"kCBMsgArgTransactionID": t,
"kCBMsgArgResult": 0,
})
case 20: // WriteRequest
u := UUID{args.MustGetUUID("kCBMsgArgDeviceUUID")}
t := args.MustGetInt("kCBMsgArgTransactionID")
a := 0
noRsp := false
xxws := args.MustGetArray("kCBMsgArgATTWrites")
for _, xxw := range xxws {
xw := xxw.(xpc.Dict)
if a == 0 {
a = xw.MustGetInt("kCBMsgArgAttributeID")
}
o := xw.MustGetInt("kCBMsgArgOffset")
i := xw.MustGetInt("kCBMsgArgIgnoreResponse")
b := xw.MustGetBytes("kCBMsgArgData")
_ = o
attr := d.attrs[a]
c := newCentral(d, u)
r := Request{Central: c}
attr.pvt.(*Characteristic).whandler.ServeWrite(r, b)
if i == 1 {
noRsp = true
}
}
if noRsp {
break
}
d.sendCmd(13, xpc.Dict{
"kCBMsgArgAttributeID": a,
"kCBMsgArgData": nil,
"kCBMsgArgTransactionID": t,
"kCBMsgArgResult": 0,
})
case 21: // subscribed
u := UUID{args.MustGetUUID("kCBMsgArgDeviceUUID")}
a := args.MustGetInt("kCBMsgArgAttributeID")
attr := d.attrs[a]
c := newCentral(d, u)
d.subscribers[u.String()] = c
c.startNotify(attr, c.mtu)
case 22: // unubscribed
u := UUID{args.MustGetUUID("kCBMsgArgDeviceUUID")}
a := args.MustGetInt("kCBMsgArgAttributeID")
attr := d.attrs[a]
if c := d.subscribers[u.String()]; c != nil {
c.stopNotify(attr)
}
case 23: // notificationSent
}
}