Cofi icon indicating copy to clipboard operation
Cofi copied to clipboard

Connect to and use Decent Scale

Open Blechpirat opened this issue 2 years ago • 10 comments

Is your feature request related to a problem? Please describe. Connecting to a good bluetooth scale would allow the app to be even greater, since being exact is very important - esp. flowrates are hard to hit (V60)

Describe the solution you'd like The Decent Scale is open source and has a well documented API. Decent even offers a free scale for app developers (https://youtu.be/IpjN_FzjUW8?t=457) and is made for coffee lovers.

Describe alternatives you've considered There are other bluetooth scales, but I don't know them well enough to recommend.

Additional context Especially getting shown the flowrates of the water you put into your V60 would be awesome. But also automatically calculating how much water you need for the exact amount of coffee the scale registers, etc - awesome!

Blechpirat avatar Aug 14 '23 07:08 Blechpirat

Thanks for bringing to my attention that Decent has a developer program, and that they can send free scale to help with the implementation. I've sent them an email and I'll wait for the response. It would be nice to have features you are talking about

rozPierog avatar Aug 14 '23 11:08 rozPierog

Yeah, absolutely, and double-plus absolutely because you're a FLOSS app.

I'm in France, so if you don't mind I'll send you one of my own, kinda scratched up, Decent Scales, so we can avoid any EU tax fun.

API docs here: https://decentespresso.com/decentscale_api

and I can help if any questions.

decentjohn avatar Aug 15 '23 09:08 decentjohn

Thanks John!

Blechpirat avatar Aug 16 '23 08:08 Blechpirat

Resources to look at when implementing: https://punchthrough.com/android-ble-guide/ https://developer.android.com/guide/topics/connectivity/bluetooth/ble-overview https://decentespresso.com/decentscale_api

rozPierog avatar Sep 10 '23 14:09 rozPierog

@rozPierog I'm not sure how much BLE experience you have, but I've worked professionally with Android BLE for years and I'm happy to be a resource if that's helpful. I'd also be happy to contribute!

Here's another link for you: JuulLabs/Kable is a fantastic multi-platform Kotlin library for working with BLE. We use it to great effect at @Parsyl on both Android and iOS. It translates all of the callback-based Android APIs to a great Kotlin coroutines-based API that makes development much easier.

mtrewartha avatar Sep 27 '23 16:09 mtrewartha

Oooooh, that's amazing thanks @mtrewartha I'll definitely look into this as my experience with BLE is non-existent.

rozPierog avatar Sep 29 '23 15:09 rozPierog

It's super easy, though. The steps are:

  1. scan for devices, get a bluetooth device id
  2. connect to that device id
  3. "subscribe" to data from one of the numbered services
  4. receive weight data

decentjohn avatar Sep 29 '23 15:09 decentjohn

I'm sure that it's easy, but sadly I don't have time to learn ins and outs of Android bluetooth stack, right now, so to have that burden lifted via already battle tested library will be a great help

rozPierog avatar Sep 29 '23 15:09 rozPierog

oh, totally think you should use the library, but the steps will likely be the same. It's just that the library will hide some complexity of the implementation, and (nicely) avoid you having to learn the different platform issues.

I'm reading the docs: https://github.com/JuulLabs/kable

and my 1-2-3-4 steps will still apply. But you'll likely have code from Kable that you can copy/paste.

decentjohn avatar Sep 29 '23 15:09 decentjohn

Yup, I think those same steps likely apply (admittedly haven't looked at the scale BLE API). There's definitely a learning curve to BLE so if you beat me to this, don't hesitate to ping me with questions!

mtrewartha avatar Sep 29 '23 16:09 mtrewartha