DiscoverDescriptors Method

Used to discover all descriptors for a specific characteristic.

Syntax

ANSI (Cross Platform)
int DiscoverDescriptors(const char* lpszServiceId, const char* lpszCharacteristicId);

Unicode (Windows)
INT DiscoverDescriptors(LPCWSTR lpszServiceId, LPCWSTR lpszCharacteristicId);
#define MID_BLECLIENT_DISCOVERDESCRIPTORS 7

IPWORKSBLE_EXTERNAL int IPWORKSBLE_CALL IPWorksBLE_BLEClient_Do(void *lpObj, int methid, int cparam, void *param[], int cbparam[], int64 *lpllVal);

Remarks

This method is used to discover all descriptors that belong to the characteristic represented by CharacteristicId (which is owned by the service represented by ServiceId). Discovered descriptors' data will be used to populate the Descriptors* properties when the Characteristic property is set to the applicable characteristic Id.

During the discovery process, the Discovered event will fire once for each descriptor discovered. You may control whether it fires when a descriptor is rediscovered by setting the IncludeRediscovered configuration setting.

Keep in mind that having any of the following configuration settings enabled when you call this method may cause additional, unwanted power consumption: AutoDiscoverCharacteristics, AutoDiscoverDescriptors, or AutoDiscoverIncludedServices.

Descriptor Discovery

// Discovered event handler.
bleclient1.OnDiscovered += (s, e) => {
  Console.WriteLine("Descriptor discovered:" +
    "\r\n\tOwning Service Id: " + e.ServiceId +
    "\r\n\tOwning Characteristic Id: " + e.CharacteristicId +
    "\r\n\tDescriptor Id: " + e.DescriptorId +
    // The discovered descriptor's 128-bit UUID string, in the format
    // "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
    "\r\n\tUUID: " + e.Uuid +
    // For standard descriptors whose UUIDs are defined by the Bluetooth SIG,
    // the Description event parameter will contain the name of the descriptor.
    "\r\n\tDescription: " + e.Description);
};

// Discover all descriptors for characteristic Id "001C001D0000", owned by 
// service Id "001C00000000". (On our CC2650STK TI SensorTag, this is the 
// Battery Level characteristic, which is owned by the Battery Service.)
bleclient1.DiscoverDescriptors("001C00000000", "001C001D0000");

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks BLE 2020 C++ Edition - Version 20.0 [Build 8158]