如何用 ESP8266 监听 Firestore 的变化?

How to listen to changes in Firestore with ESP8266?

如何使用 ESP8266 监听 Firebase Cloud Firestore 中的数据变化?到目前为止,我已经设法将 ESP8266 与 firestore 连接起来,使用 REST API 读取和 post 数据到 Firestore,但我不想不断地从 Firestore 读取数据,而是想在数据发生变化时收听一个事件在 Firestore 中。

简而言之,我想打开一个流,我正在监听 Firestore 中的变化。

这可以通过 Firebase 实时数据库完成,但我还没有找到 Firestore 的示例。

这是我正在尝试做的事情的一个例子,但是使用实时数据库:https://github.com/mobizt/Firebase-ESP8266/blob/master/examples/Stream/Stream.ino

我在一些论坛上四处询问,遗憾的是我发现这是不可能的:(

The Cloud Firestore supports the REST API unless stream like feature are not available due to poor performance and Firebase team decided to remove this feature.

The only possible method that suitable for no Firebase SDK installation is the RPC (gRPC) which is not currently available in embedded device. The other problem is database secret can't use in the Cloud Firestore, the auth or custom token is required and need the SSL/TLS library for key encryption and signing. This can be done in ESP32 with mbed TLS which can't do this in ESP8266 with BearSSL.

Then Cloud Firestore with realtime feature (using gRPC) is not possible in ESP8266.

解决方法是使用网络服务器 and/or Firebase Functions,遗憾的是我试图避免这种情况。