Getting all BLE services from Android app

Viewed 192

I have an Android app, that must connect to a BLE server, discover its services, and read a specific characteristic of a specific service.

The server code is written in go and is a simple template that I took here. From it, I register a service and a characteristic with the followings UUIDs:

MyService:         00010000-0001-1000-8000-00805F9B34FC
MyCharacteristic:  00010000-0002-1000-8000-00805F9B34FC

Then here's my Android code that discovers for services:

override fun onServicesDiscovered(gatt: BluetoothGatt?, status: Int) {
            if (status == BluetoothGatt.GATT_SUCCESS) {
                gatt?.services?.forEach { service ->
                    Log.d("onServicesDiscovered", "new service: ${service.uuid.toString()}")
                    if (service.uuid == EnrollServiceUUID) {
                        Log.d("onServicesDiscovered", "SUCCESS")
                    }
                }
            } else {
                Log.d("onServicesDiscovered", "Error while fetching services: $status")
            }
        }

if I scan for my go server with an nRF connect app, here's what I get:

enter image description here

(Notice that my declared service is found with the declared UUID)

But when running my android code: Here are the services I find:

onServicesDiscovered: 00001800-0000-1000-8000-00805f9b34fb
onServicesDiscovered: 00001801-0000-1000-8000-00805f9b34fb
onServicesDiscovered: 0000180a-0000-1000-8000-00805f9b34fb

Actually I figured out that my service and my characteristic have been "renamed" to another UUIDs. In fact, only the two first parts are modified, as following:

Go server     | Android app
00010000-0001 | 180a-0000
00010000-0002 | 00002a50-0000

I'm able to interact with from my app, but I would like to understand why they have a different UUID that the ones I declare from my Go server and I see with nRF connect.

0 Answers
Related