zampino

zampino

Help with pairing device with BlueHeron on Raspberry Pi Zero 2 W

Hello nervlers!

I’m trying to connect a bluetooth printer (thermal ESC/POS “driverless”) to a Raspberry Pi Zero 2 W.
Nerves on the RaspBerry and BlueHeron are working fine (at least with this commit :slight_smile:) and I can connect to the printer via the ATT Client (as per the govee lightbulb examples in BlueHeron repo).

But from there on I’m lost, and not sure if the ATT layer alone is sufficient for this task at all.
To start with, the Govee example uses a hardcoded handle (0x0015) in the BlueHeron.ATT.Client.write/3 which I don’t know where is coming from, so I tried the connection handle itself but that gave no outcome.

The point is: the printer peripheral requires an authentication step via a PIN to be paired with the central role.

  • Did anyone try/manage to pair a device via PIN with BlueHeron?
  • Does that correspond to integrate the SMP layer with the ATT client?
  • Can I convince my device to not require authentication?

In fact I can e.g. send data to the printer from mac OS only after first pairing it via its PIN:

This is an excerpt of the packet logs (via packetlogger) between macOS and the printer during pairing:

A lot of the mentioned packets (link policy, authentication requested, etc.) are present in the BlueHeron library but I wouldn’t know how/if they can be fitted into the ATT Client connection.

And these are the packets exchanged when I send data via a serial debugging tool from mac to the printer to have it print “hello”:

Mac OS seems to change the connection packet type (?) to RFCOMM, but the RFCOMM packet type is not mentioned at all in BlueHeron packets/modules, is there an alternative to that?

I’ll keep trying to integrate SMP, but any help around that would be much appreciated.
A big thank you to the maintainers of nerves and blue heron!!

Most Liked

ConnorRigby

ConnorRigby

Nerves Core Team

To start with, the Govee example uses a hardcoded handle (0x0015) in the `BlueHeron.ATT.Client.write/3

This handle came from the ATT table. When that example was written, we didn’t have GATT support yet, so the hardcoded value was used.

You’re on the right track with SMP. I know that BlueHeron doesn’t currently support SMP for the ATT client, but it shouldn’t be that hard to add. It’s been a while since i looked in there, but the spec is pretty readable on how it should work. I think all of the required algorithms should be implemented already.

Last Post!

zampino

zampino

Turns out that was drastically false!

Again, it’s a matter of finding the correct characteristic handle as mentioned above.

I used a different bluetooth debugging tool (SmartBond for Mac OS) which is able to discover the services/characteristic tree of the device and send via ATT/L2CAP/ACL, bypassing SMP entirely.

I’m confused, but happy it worked.

I guess the missing link in the ATT Client in BlueHeron is implementing the ReadByTypeRequest/Response (hinted at here and here) messages to discover such a handle?

Hope this can turn out useful to others as well.

Where Next?

Popular in Questions Top

RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New

Other popular topics Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

We're in Beta

About us Mission Statement