camera.switchWi-Fi
应用将此命令发送到相机,为相机提供
以及可连接互联网的基础设施 Wi-Fi。该命令包括
预共享密钥 K,应用稍后将使用该密钥进行身份验证
在两台设备都切换到基础架构 Wi-Fi 后,使用相机。
此命令是在 API 级别 2.1 中添加的,它与
直接上传。
参数
preSharedKey:
随机生成的 256 位密钥,用于对
摄像头与应用一起显示。
例如,可以使用 OpenSSL 中的 RAND_bytes() 生成此内容。
wifiSsid:
Wi-Fi SSID。
wifiPwd:
Wi-Fi 密码(如果有)。
结果
错误
missingParameter:
缺少某个参数,例如 preSharedKey
。
invalidParameterName:
一个或多个输入参数名称
无法识别。
invalidParameterValue:
可识别输入参数名称
但传递的一个或多个值无效。例如,wifiPwd
以整数而非字符串的形式传入。
命令 I/O |
|
命令输入 |
{ "parameters": { "preSharedKey": "random key", "wifiSsid": "home Wi-Fi", "wifiPwd": "wifi password" } } |
命令输出 |
none |
命令输出(错误) |
{ "error": { "code": "missingParameter", "message": "Parameter preSharedKey is missing." } } |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-08-21。
[null,null,["最后更新时间 (UTC):2024-08-21。"],[[["The command enables the app to provide the camera with infrastructure Wi-Fi credentials, including a pre-shared key for subsequent authentication."],["Introduced in API level 2.1, this command is specifically for Direct Upload functionality and facilitates camera-app communication over Wi-Fi."],["It requires parameters like preSharedKey, wifiSsid, and wifiPwd, and potential errors include missing or invalid parameters."],["The command itself doesn't return a result, but errors are indicated through specific error codes and messages."]]],["The app sends a command to the camera to grant it access to an infrastructure Wi-Fi network. This command requires three parameters: a 256-bit pre-shared key (`preSharedKey`) for later authentication, the Wi-Fi SSID (`wifiSsid`), and the Wi-Fi password (`wifiPwd`). The camera uses this information to connect to the network. No result is returned, but errors can occur if parameters are missing, unrecognized, or invalid. This was added in API level 2.1.\n"]]