Actions on google 接收UDP扫描数据的TypeError
使用Google Assistant的开发者预览,我在Actions on google 接收UDP扫描数据的TypeError,actions-on-google,google-smart-home,Actions On Google,Google Smart Home,使用Google Assistant的开发者预览,我在IDENTIFY期间从我的应用程序收到了一个TypeError,它以前工作正常。当我尝试解码有效负载时,错误是声称UdpScanData不是有效字符串 示例代码: const device = identifyRequest.inputs[0].payload.device; const response = Buffer.from(device.udpScanData, "hex"); 如何访问UDP发现有效负载?在开发者预览SDK的0.
IDENTIFY
期间从我的应用程序收到了一个TypeError
,它以前工作正常。当我尝试解码有效负载时,错误是声称UdpScanData
不是有效字符串
示例代码:
const device = identifyRequest.inputs[0].payload.device;
const response = Buffer.from(device.udpScanData, "hex");
如何访问UDP发现有效负载?在开发者预览SDK的0.2.0更新中,我们已将
UdpScanData
参数迁移为接口,而不仅仅是string
的类型别名(请参见更新内容),以提高与其他扫描数据类型的一致性
要在最新SDK中访问UDP扫描的响应负载,请更新您的package.json
依赖项以使用v0.2.0:
{
...
"dependencies": {
"@google/local-home-sdk": "^0.2.0"
}
}
然后,使用新的数据属性访问有效负载:
const device = identifyRequest.inputs[0].payload.device;
const scanData = device.udpScanData;
const response = Buffer.from(scanData.data, "hex");