Author Topic: Writing to Custom Service  (Read 15365 times)

Offline briandunham

  • Newbie
  • *
  • Posts: 29
  • Karma: 0
Writing to Custom Service
« on: February 07, 2022, 07:01:11 PM »
Hi,

I'm trying to write to characteristics within a custom service that is defined here: https://www.lairdconnect.com/wireless-modules/bluetooth-module/sable-x-ble-module/serial-ble-profile

I've been referencing the GattClient Demo, and I see that it reads the available services with the wclGattClient.ReadServices() call. It then stores the services and references them later when writing to the characteristics. However, my question is how can I write to the service characteristics without first reading the services? I know the hardware we're writing to contains the service, and I just want to write directly to it without having to do a ReadServices().

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: Writing to Custom Service
« Reply #1 on: February 07, 2022, 07:05:47 PM »
Hi,

You can do it by saving all the characteristic data from the wclGattCharacteristic structure. You have to store all the fields from that structure. If your device has hardcoded characteristi you also can hard code it in your application.

Offline briandunham

  • Newbie
  • *
  • Posts: 29
  • Karma: 0
Re: Writing to Custom Service
« Reply #2 on: February 07, 2022, 07:32:26 PM »
Our hardware currently doesn't support reading any services profiles from it, but I will just manually fill out all the wclGattCharacteristic fields and just call the wclGattClient.WriteCharacteristicValue() function.

But now I'm confused on how I can hardcode the UUID field in the wclGattCharacteristic. After looking at the definition, there is a 20 byte GUID struct. But the UUID 3347AB00-FB94-11E2-A8E4-F23C91AEC05E is 16 bytes. What am I missing here?

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: Writing to Custom Service
« Reply #3 on: February 07, 2022, 07:37:13 PM »
Not sure what you mean by "hardware currently doesn't support reading any services profiles" but fi the device does not allow to read its services it will never work with any GATT client. It is mandatory feature of GATT specification.

UUID (GUID) is 16 bytes always (by definition, it is 128 bits / 8 = 16 bytes). There is no 20 bytes UUID (GUID) definition (https://en.wikipedia.org/wiki/Universally_unique_identifier)

Offline briandunham

  • Newbie
  • *
  • Posts: 29
  • Karma: 0
Re: Writing to Custom Service
« Reply #4 on: February 07, 2022, 07:49:18 PM »
I miscounted the number of bytes in the GUID struct. Clearly it's too early in the morning here and I'm not thinking straight. There needs to be a facepalm emoji in this forum.

We're in the beginning stages of adding BLE to our hardware. And also updating the Windows engineering tools to connect to the hardware using your libraries. But you're saying that we need to add support for reading the service definitions from the device? Or else the writing to the characteristics won't work?

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: Writing to Custom Service
« Reply #5 on: February 07, 2022, 07:57:28 PM »
No problem with UUID. In fact in GATT there is also something known as Short UUID (which is 2 bytes long).

About services reading. Well. In fact there is no something like "services reading" or "characteristics reading". There is just a commands called "read by groups" and "read by type". Both requires handles range. To know characteristic handles range it is required to know service handle. Both commands are mandatory and must be implemented in the device.

 

Sitemap 1 2 3 4 5 6 7