Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Machine disconnected #2

Closed
martijnmnnk opened this issue Apr 21, 2021 · 10 comments
Closed

Machine disconnected #2

martijnmnnk opened this issue Apr 21, 2021 · 10 comments
Labels
question Further information is requested

Comments

@martijnmnnk
Copy link

martijnmnnk commented Apr 21, 2021

Thanks for creating this plugin, I'd love to get it to work and get Siri to brew me a fresh coffee in the morning.

I've used Bluetooth HCI Snoop on an Android phone to get the btsnoop_hci.log file. I tried the hexdump command, but gave me no results. Tried with Wireshark, but was not abled to get the key.

Then I followed the instructions by n2k here [ https://gist.github.com/farminf/94f681eaca2760212f457ac59da99f23 ] and tried extracting the key from the database by using a rooted Android phone.

$ sqlite3 nespresso_app_fusion.db 'SELECT pairing_key FROM MyMachines;'
2FAECC7DFF8C42E6BBBCAC1810F011E8

Running the pairing_key.java script gave me this result
Current key: 2FAECC7DFF8C42E6BBBCAC1810F011E8
Current key hex: 82FAECC7DFF8C42E

So now I have a key, but how do I convert this into a valid token?

Firmware 6.0
Connectivity Firmware 1.27

@martijnmnnk martijnmnnk added the question Further information is requested label Apr 21, 2021
@martijnmnnk
Copy link
Author

martijnmnnk commented Apr 22, 2021

Already found the token by using the Xcode tool PacketLogger with my iPhone by following these instructions [ https://www.bluetooth.com/blog/a-new-way-to-debug-iosbluetooth-applications/ ].

Screenshot 2021-04-22 at 08 17 16

Also by using PacketLogger, I exported the log snoop.log an run the hexdump command, resulting:
$ hexdump -v -e '/1 "%02X "' snoop.log | grep -o '0B 00 04 00 12 14 00 <.. .. .. .. .. .. .. ..>'
0B 00 04 00 12 14 00 82 FA EC C7 DF F8 C4 2E

This is the same key as extracted from the nespresso_app_fusion.db by using my rooted Android phone, which means that there is some other problem as the machine disconnects immediately after connecting.

Config:
"platforms": [ "machines": [ { "name": "Expert&Milk_ED4BBFE387C8", "token": "82-FA-EC-C7-DF-F8-C4-2E", "temperature": "Medium" } ], "platform": "Brewer" } ]

Log:
[22/04/2021, 08:14:49] [Brewer] Initializing Brewer platform... [22/04/2021, 08:14:49] [Brewer] Loading accessory from cache: Expert&Milk_ED4BBFE387C8 [22/04/2021, 08:14:49] [Brewer] Restoring existing accessory from cache: Expert&Milk_ED4BBFE387C8 [22/04/2021, 08:14:49] Homebridge v1.3.4 (Homebride Expert) is running on port 51050. [22/04/2021, 08:17:21] [Brewer] Start scan... [22/04/2021, 08:17:23] [Brewer] Connected to Expert&Milk_ED4BBFE387C8 [22/04/2021, 08:17:26] [Brewer] Machine disconnected [22/04/2021, 08:17:35] [Brewer] Start scan... [22/04/2021, 08:17:36] [Brewer] Connected to Expert&Milk_ED4BBFE387C8 [22/04/2021, 08:17:36] [Brewer] Machine disconnected [22/04/2021, 08:19:24] [Brewer] Start scan... [22/04/2021, 08:19:25] [Brewer] Connected to Expert&Milk_ED4BBFE387C8 [22/04/2021, 08:21:25] [Brewer] Machine disconnected

Did I miss something? Any suggestions on how to get the plugin working with my machine?

@martijnmnnk martijnmnnk changed the title Unable to get token Machine disconnected Apr 22, 2021
@tritter
Copy link
Owner

tritter commented May 2, 2021

Hi @martijnmnnk,

Sorry didn't see the email of this issue at first. Could you try to run home bridge on another device? I experienced Problems with some Raspberry's Zero. I plan to improve the connection disconnection logic in a further update.
Could you also please attach the logs with DEBUG enabled inside the Homebridge settings? "To run Homebridge in full debug mode run the following command DEBUG=* homebridge -D." (https://github.com/homebridge/homebridge/wiki/Basic-Troubleshooting). Your research is perfect, I can't see issues there.

@martijnmnnk
Copy link
Author

Hey @tritter thanks for your response. I've run homebridge in debug mode but honestly the log does not make any sense to me. I've uploaded the logfile here [ homebridge-log.txt ], maybe you can see what's wrong? I've tried running the plugin on a RasPi 4 Model B Rev 1.1 and based on your suggestion I've installed the plugin on a RasPi 3 Model B Rev 1.2, and also tried running that Homebridge instance as root but to no avail.

@tritter
Copy link
Owner

tritter commented May 2, 2021

@martijnmnnk Thanks a lot, everything looks pretty good to me. It looks like the machine is rejecting the connection. Could you try to remove the device and re-add it again. (I just tried to change my token and it still worked with a wrong token). So it seems like homebridge or I may cache the token inside the homekit device between restarts.
Could you try:

  1. Remove device inside the config.json
  2. Restart home bridge
  3. (You should see in the log discovered device, and the device should be gone from your Home.app)
  4. Add the device again inside the config.json
  5. Restart again
  6. Should work? 🤞

Also make sure you're not connected with the app at the same time.

@martijnmnnk
Copy link
Author

Thanks for the suggestions and your help. I followed your instructions and removed the machine from config.json, restarted homebridge and added the machine again.. no succes :(

In addition I also tried factory resetting the machine and retrieving a new token with PacketLogger, closed the app and switched off bluetooth on my iPhone, and created a new homebridge instance with the new machine config.. unfortunately this also does not work.

I'm wondering which firmware version you are using. According to the app my machine is using firmware 6.0 and connectivity firmware 1.27. Is your machine maybe running on a different version?

@tritter
Copy link
Owner

tritter commented May 5, 2021

@martijnmnnk Thanks a lot for all the tests! I started the plugin using this website in Chrome: https://github.com/petergullberg/brewbutton/blob/master/brewbutton.html That will also probably not work for you!?

And I have firmware 6.0! Maybe that's the issue. Can you download the brewbutton.html open it in Chrome what works for you??

Maybe there is a new notify bluetooth characteristic which is only supported in 6.1. Unfortunately I only have one machine.

@martijnmnnk
Copy link
Author

My machine is on firmware 6.0 as well. I've tried the page brewbutton.html in Chrome but this also does not seem to work. I am sure the token is correct, but I can't figure out what I'm missing :(
Screenshot 2021-05-05 at 22 12 37

@tritter
Copy link
Owner

tritter commented May 5, 2021

You first need to press: Connect, then Status then Brew! Mine shows this. Yours should at least connect though. Did you get the connect dialog in Chrome? It doesn't even seem to write the Auth..

Screenshot 2021-05-05 at 22 25 42

@martijnmnnk
Copy link
Author

Goog news! Its finally working! The plugin is connecting with the machine and I can brew a coffee with the Home app.

I have some other bluetooth devices connected to the pi, some of them quite far away (10+ meters). However, the Nespresso machine needs a very strong connection. My machine is located roughly 4 meters from the Raspberry pi with a thin wall in between. When placing the machine next to the Raspberry Pi brewing a coffee is working without any issues.

I'm feeling a bit stupid that I did not try this before... Big thank you for your patience and help, and an even bigger thank you for creating the plugin. I'll buy you a coffee, you deserved it!

@tritter
Copy link
Owner

tritter commented May 6, 2021

Amazing! Thanks a lot, yes that was also a suggestion I wanted to make but I thought your probably did that ;-) I will add it to the README, as the Bluetooth-Chip isn't the strongest one in the raspberry. I think they wanted to make sure you're standing next to it...

No problem! I'm happy to help. PS. There's still many things I would like to add and improve. This was just my initial throw to schedule my coffee every morning :) If you have any ideas feel free to put them in the round here are also some: #1

Thanks a ton for the coffee 🙏🥳, just ordered some cups 💯 👍 If you have any issues, never feel stupid always feel free to ask!

@tritter tritter closed this as completed May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants