Turn standard 4 bit UUID into 2 16 bit UUIDs

I am writing a program for a Garmin Edge which needs to connect to a power meter via Bluetooth, some of the characteristic / service UUIDs are 4 digits which cannot be used when coding for Garmin products. For example, this is the code to connect to one of the services vis Bluetooth:

public const POWER_METER_UART_SERVICE      = BluetoothLowEnergy.longToUuid(0x6E****************, 0xE0****************);

Is there anyway to convert these 4 bit UUIDs so they would be compatible with this format? 

Thanks

Parents
  • Hi,

    Can you provide some more detail about the Bluetooth connection code? It is not from nRF Connect SDK. What language, SDK/library, etc. does it come from?

    Do you have examples of the UUIDs in question? Is it for particular BLE services / characteristics?

    When you write "4 digits", what is the base of the number (hexadecimal? decimal? binary?) I suspect that we are either talking about the 16 bit UUIDs defined by Bluetooth SIG, or we are talking about 16 bit UUIDs to  be combined with a "base UUID" to generate a full 128 bit UUID?

    Regards,
    Terje

  • Hi, thanks for the reply.

    The language I'm programming in is Monkey C which is the language you use to develop apps for Garmin devices. You are correct I should have said 16 bit UUID to 128 bit UUID or to be more accurate 16 bit to two 64 bit UUIDs as you can see from the code above that you need to provide the starting and end UUIDs.

  • The service UUID for generic access is 1800 which I belive is pretty standerd

  • Hi,

    That is a standard 16 bit UUID from Bluetooth SIG, yes.

    Ref. the Bluetooth Core Specification 5.2, Vol 3, Part B, section 2.5.1 UUID:

    "The first UUID in this pre-allocated range is known as the
    Bluetooth Base UUID and has the value 00000000-0000-1000-8000-
    00805F9B34FB

    (...)

    The full 128-bit value of a 16-bit or 32-bit UUID may be computed by a simple
    arithmetic operation.

    128_bit_value = 16_bit_value * 2^96 + Bluetooth_Base_UUID


    128_bit_value = 32_bit_value * 2^96 + Bluetooth_Base_UUID"

    What it means in practice, is that you take a "base UUID" of 0000xxxx-0000-1000-8000-
    00805F9B34FB, and replace the x-es with the 16 bit UUID.

    I do not know how that maps to the BluetoothLowEnergy.longToUuid() call. For that you must consult the documentation for the paraticular library that you use. With some luck, there is also an API call for generating Bluetooth SIG UUIDs from 16 bit (and from 32 bit) numbers.

    Regards,
    Terje

Reply
  • Hi,

    That is a standard 16 bit UUID from Bluetooth SIG, yes.

    Ref. the Bluetooth Core Specification 5.2, Vol 3, Part B, section 2.5.1 UUID:

    "The first UUID in this pre-allocated range is known as the
    Bluetooth Base UUID and has the value 00000000-0000-1000-8000-
    00805F9B34FB

    (...)

    The full 128-bit value of a 16-bit or 32-bit UUID may be computed by a simple
    arithmetic operation.

    128_bit_value = 16_bit_value * 2^96 + Bluetooth_Base_UUID


    128_bit_value = 32_bit_value * 2^96 + Bluetooth_Base_UUID"

    What it means in practice, is that you take a "base UUID" of 0000xxxx-0000-1000-8000-
    00805F9B34FB, and replace the x-es with the 16 bit UUID.

    I do not know how that maps to the BluetoothLowEnergy.longToUuid() call. For that you must consult the documentation for the paraticular library that you use. With some luck, there is also an API call for generating Bluetooth SIG UUIDs from 16 bit (and from 32 bit) numbers.

    Regards,
    Terje

Children
Related