shamblett / iot-home

A google iot-core project using MQTT for Dart
MIT License
10 stars 6 forks source link

More question then issue... #3

Closed Radagan closed 5 years ago

Radagan commented 5 years ago

..., but your Medium article mentioned it would be okay to do so. Here goes.

I had a rude realization today. While my Flutter app can connect to Google IoT Core now with all the cryptography bits in place, thanks in no small part to your code, and I can subscribe to events, I can't actually receive them. It seems that Google's MQTT is one way.

Have you had any luck connecting to Google PubSub via Flutter/Dart?

I have a number of devices that have dashboard data that changes. I have an iOS/Android Flutter app that would like to subscribe/unsubscribe to those changes. Currently, the app polls an App Engine app for status wasting a lot of cycles and causing an update delay on the app, unless the user requests a refresh.

The problem with PubSub, I think, is a lack of library support and the need to use a service account or Google account to authenticate. With MQTT it was elegant: the keypair was generated on the phone and App Engine managed the IoT device for the authenticated user. But I am using Firebase Auth, just with the email/password option.

Any and all advice most welcome.

shamblett commented 5 years ago

I think you can get sent device status or config or something from the IOT core but yes, its not like a normal MQTT subscription. I have this project, its part of a larger project I'm still working on(and have been for some time!), its the pub/sub part, it does work, you will need the JSON auth file as described in the google docs but other than that it should be good to go, its a little old and may need sprucing up for Dart 2.4 but it has been updated for Dart 2.0 usage, have a look and see how you go.

Radagan commented 5 years ago

Many thanks again! I cloned your Dartivity project and made a few hackish changes to get this working in prototype. A couple of those might be useful once I clean it up a bit. Would you like me to open a pull request? I've never actually done that before... I'm far from new to programming, but I am new to open source.

Also, couldn't help but notice the "who has" and "I have" messages. Do you have a BACnet protocol background? I work in building automation.

shamblett commented 5 years ago

Please open a pull request, feedback from users is always useful.

I did use BACnet many years ago(early 90's I think) on what was then called a smart homes project, can't remember why I used it in Dartivity though as I've not used it since. I mainly work in Industrial SCADA systems and control/information systems for control centres such as railways, underground etc these days, usually doing the equipment interface side of things.

Radagan commented 5 years ago

Many thanks again! I cloned your Dartivity project and made a few hackish changes to get this working in prototype. A couple of those might be useful once I clean it up a bit. Would you like me to open a pull request? I've never actually done that before... I'm far from new to programming, but I am new to open source.

Also, couldn't help but notice the "who has" and "I have" messages. Do you have a BACnet protocol background? I work in building automation.