问题
I'm trying to make a raspberry pi bluetooth peripheral, so I try running the BlueZ example "example-gatt-server" and "example-advertising" at the same time. Then communicate it with my phone. But I got "Failed to encrypt the connection, the connection has timed out unexpectedly." on my iOS with nrf connect app.
I'm using iOS 14, BlueZ 5.50, Raspberry Pi 4, Raspberry Pi OS Stretch
回答1:
Instead of using ready made examples, I recommend that you create your own GATT server and then advertise as a peripheral through the bluetoothctl tool. You can do this through the following sequence:-
#bluetoothctl
[bluetoothctl] menu gatt
[bluetoothctl] register-service 0xFFFF # (Choose yes when asked if primary service)
[bluetoothctl] register-characteristic 0xAAAA read # (Select a value of 1 when prompted)
[bluetoothctl] register-characteristic 0xBBBB read,write # (Select a value of 0 when prompted)
[bluetoothctl] register-characteristic 0xCCCC read # (Select a value of 2 when prompted)
[bluetoothctl] register-application # (This commits the services/characteristics and registers the profile)
[bluetoothctl] back
[bluetoothctl] advertise on
Have a look at the following links for more information on how to set up your own peripheral:-
- How to set up a gatt server from the command line
- BLE: Use BlueZ stack as a peripheral
- Creating a BLE Peripheral with BlueZ
来源:https://stackoverflow.com/questions/65299644/failed-to-encrypt-the-connection-with-bluez-peripheral-and-ios