简体   繁体   English

Google Cloud IOT-通过 Firebase/云功能进行设备配置?

[英]Google Cloud IOT- Device Configuration via Firebase/cloud functions?

I have been able to successfully receive state and telemetry from my iot device using mqtt->pubsub->firebase functions->FCM to an android app.我已经能够使用 mqtt->pubsub->firebase 函数->FCM 从我的物联网设备成功接收状态和遥测数据到一个 android 应用程序。 My iot device is also registered to receive the config callback, and it successfully receives the current config mqtt message when the device connects.我的iot设备也注册了接收config回调,在设备连接时成功接收到当前的config mqtt消息。

Now, I would like to be able to use my android app to initiate a config message to send a run/stop command.现在,我希望能够使用我的 android 应用程序启动配置消息以发送运行/停止命令。 I had thought I could accomplish this via an android api call or from within a cloud function.我曾以为我可以通过 android api 调用或从云函数中完成此操作。 There don't seem to be any examples on the web for this.网络上似乎没有任何示例。

This example appears to be intended to run on a 3rd party node.js server rather than from inside a cloud function or an android app: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/iot/manager/manager.js#L865此示例似乎旨在在第 3 方 node.js 服务器上运行,而不是从云函数或 android 应用程序内部运行: https : //github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/iot/经理/经理.js#L865

From within the cloud function it was very easy to use admin.firestore() and admin.messaging() to call functions and accomplish what I needed.在云函数中,使用 admin.firestore() 和 admin.messaging() 调用函数并完成我需要的操作非常容易。 However the IOT API's don't appear to work the same way.然而,IOT API 的工作方式似乎不同。 I'm clearly missing something.我显然错过了一些东西。

So in short- How can I initiate an IOT config message from android or a cloud function?简而言之-如何从 android 或云功能启动 IOT 配置消息? It would be great if I could access the other registry management functions as well.如果我也可以访问其他注册表管理功能,那就太好了。

Thanks in advance for any help.在此先感谢您的帮助。

You should be able to call a cloud function from the android app and then have that integrate with the IOT api's - you could also have the android client call the rest api's https://cloud.google.com/iot/docs/reference/rest/您应该能够从 android 应用程序调用云函数,然后将其与 IOT api 集成 - 您也可以让 android 客户端调用其余 api 的https://cloud.google.com/iot/docs/reference/休息/

DeviceManager also has a JAVA interface: DeviceManager也有JAVA接口:

https://cloud.google.com/iot/docs/samples/device-manager-samples https://cloud.google.com/iot/docs/samples/device-manager-samples

Dazza5000 pointed me to the IOT Core API for Java: Dazza5000 向我指出了适用于 Java 的 IOT Core API:

https://developers.google.com/api-client-library/java/apis/cloudiot/v1 https://developers.google.com/api-client-library/java/apis/cloudiot/v1

This will allow me to send config data to my IOT device from Android.这将允许我从 Android 向我的 IOT 设备发送配置数据。 I don't think this API can be called from a cloud function.我不认为可以从云函数调用此 API。

With Cloud Functions for Firebase , all you have to do to make a function you can directly invoke is create an HTTPS trigger .使用Cloud Functions for Firebase ,您只需创建一个HTTPS 触发器即可创建可直接调用的函数。 Then, when you have its URL that's shown after deployment, you can invoke that URL using whatever HTTP library is available on the device.然后,当您在部署后显示其 URL 时,您可以使用设备上可用的任何 HTTP 库调用该 URL。 For Android devices, URLConnection is the built-in option.对于 Android 设备, URLConnection是内置选项。 There should be tons of examples of HTTP triggers (especially in the functions-samples repo) and URLConnection code that you can borrow to build this out.应该有大量的 HTTP 触发器示例(尤其是在函数示例存储库中)和 URLConnection 代码,您可以借用它们来构建它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过Http请求通过Cloud Functions进行Firebase Cloud Messaging - Firebase Cloud Messaging via Cloud Functions via Http requests 如何使用 Firebase 云功能向设备发送通知? - How to send device to device notifications using Firebase cloud functions? 适用于Android的Firebase Cloud功能 - Firebase Cloud Functions for Android 适用于Firebase的云功能:向Android设备发送无法正常工作的主题通知 - Cloud Functions for Firebase: Sending topic notification to Android device not working 通过Firebase Cloud Messaging将消息发送到Android设备 - Sending messages via Firebase Cloud Messaging to an Android device 使用Google Cloud Functions和Google Firebase推送通知 - Push Notification Using Google Cloud Functions and Google Firebase 在没有 Google Play 服务的设备中使用 Firebase 云消息传递 - Using firebase cloud messaging in a device without Google Play Services 使用 Google Cloud Functions 在 Firebase 服务器上运行计时器? - Run timer on Firebase servers using Google Cloud Functions? Google Cloud Functions:在特定时间编辑Firebase节点 - Google Cloud Functions: edit Firebase node at a specific time Firebase云功能更改超时 - Firebase Cloud Functions Change Timeout
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM