Winsoft Bluetooth Library for Android v1.2 for Delphi/C++ Builder 10.1 - 10.3 Full Source
Winsoft Bluetooth Library for Android v1.2 for Delphi/C++ Builder 10.1 - 10.3 Full Source
Delphi and C++ Builder Bluetooth library for Android.
FEATURES
Uses Android Bluetooth API
Supports BLE clients
Available for Delphi/C++ Builder 10.1 - 10.3
Source code included in registered version
Royalty free distribution in applications
WHAT'S NEW
Version 1.2
added TScanError enumeration
added TScanMode enumeration
added TScanResult class
added TBluetoothAdapter.FlushLeScan method
added TBluetoothAdapter.BatchingSupported property
added TBluetoothAdapter.OnLeScanBatch event
added TBluetoothAdapter.OnLeScanFailed event
added TBluetoothAdapter.OnLeScanResult event
added ScanMode parameter to TBluetoothAdapter.StartLeScan method
added ReportDelay parameter to TBluetoothAdapter.StartLeScan method
added ValidAddress function
improved demo examples
bug fixes
Version 1.2
added TScanError enumeration
added TScanMode enumeration
added TScanResult class
added TBluetoothAdapter.FlushLeScan method
added TBluetoothAdapter.BatchingSupported property
added TBluetoothAdapter.OnLeScanBatch event
added TBluetoothAdapter.OnLeScanFailed event
added TBluetoothAdapter.OnLeScanResult event
added ScanMode parameter to TBluetoothAdapter.StartLeScan method
added ReportDelay parameter to TBluetoothAdapter.StartLeScan method
added ValidAddress function
improved demo examples
bug fixes
Library API
const
GattSuccess = ;
type
TAdapterScanMode = (None, Connectable, Discoverable);
TAdapterState = (Off, On, TurningOff, TurningOn);
TBondState = (None, Bonding, Bonded);
TConnectionPriority = (Balanced, High, LowPower);
TDeviceClass = (Unknown,
// AudioVideo
Camcorder, CarAudio, Handsfree, Headphones, HifiAudio, Loudspeaker,
Microphone, PortableAudio, SetTopBox, UncategorizedAudioVideo,
VCR, VideoCamera, VideoConferencing, VideoDisplayAndLoudspeaker,
VideoGamingToy, VideoMonitor, WearableHeadset,
// Computer
Desktop, HandheldPcPda, Laptop, PalmSizePcPda, Server,
UncategorizedComputer, Wearable,
// Health
BloodPressure, DataDisplay, Glucose, PulseOximeter, PulseRate,
Thermometer, UncategorizedHealth, Weighing,
// Phone
Cellular, Cordless, ISDN, ModemOrGateway, Smart, UncategorizedPhone,
// Toy
Controller, DollActionFigure, Game, Robot, UncategorizedToy, Vehicle,
// Wearable
Glasses, Helmet, Jacket, Pager, UncategorizedWearable, WristWatch);
TDeviceMajorClass = (Unknown, AudioVideo, Computer, Health, Imaging,
Misc, Networking, Peripheral, Phone, Toy, Uncategorized, Wearable);
TDeviceType = (Unknown, Classic, LE, Dual);
TPermission = (Read, ReadEncrypted, ReadEncryptedMITM, Write, WriteEncrypted,
WriteEncrptedMITM, WriteSigned, WriteSignedMITM);
TPermissions = set of TPermission;
TProperty = (Broadcast, ExtendedProperties, Indicate, Notify, Read,
SignedWrite, Write, WriteNoResponse);
TProperties = set of TProperty;
TProfileState = (Disconnected, Connected, Disconnecting, Connecting);
TScanError = (AlreadyStarted, RegistrationFailed, UnsupportedFeature, InternalError);
TScanMode = (LowPower, LowLatency, Balanced);
TServiceType = (Primary, Secondary);
TTransport = (Auto, BREDR, LE);
TWriteType = (Default, NoResponse, Signed);
TGattAssignment = record
Name: string;
Number: Word;
end;
EBluetoothException = class(Exception);
TBluetoothManager = class
property Adapter: TBluetoothAdapter read;
property Manager: JBluetoothManager read;
property Supported: Boolean read;
end;
TLeScanEvent = procedure (Sender: TObject; Device: TBluetoothDevice; RSSI: Integer; const ScanRecord: TBytes) of object;
TBluetoothAdapter = class
procedure FlushLeScan;
procedure RequestEnabled;
procedure StartLeScan(ScanMode: TScanMode = TScanMode.LowPower; ReportDelay: Integer = 0);
procedure StopLeScan;
function GetRemoteDevice(const Address: string): TBluetoothDevice;
function GetRemoteDevice(const Address: TBytes): TBluetoothDevice;
property Adapter: JBluetoothAdapter read;
property BatchingSupported: Boolean read;
property BluetoothName: string read write;
property BondedDevices: TBluetoothDevices read;
property Enabled: Boolean read write;
property ScanMode: TAdapterScanMode read;
property State: TAdapterState read;
property OnLeScan: TLeScanEvent read write;
property OnLeScanBatch: TLeScanBatchEvent read write;
property OnLeScanFailed: TLeScanFailedEvent read write;
property OnLeScanResult: TLeScanResultEvent read write;
property OnStateChanged: TNotifyEvent read write;
end;
TCharacteristicChangedEvent = procedure (Sender: TObject; Characteristic: TBluetoothGattCharacteristic) of object;
TCharacteristicReadEvent = procedure (Sender: TObject; Status: Integer; Characteristic: TBluetoothGattCharacteristic) of object;
TCharacteristicWriteEvent = procedure (Sender: TObject; Status: Integer; Characteristic: TBluetoothGattCharacteristic) of object;
TConnectionStateChangeEvent = procedure (Sender: TObject; Status: Integer; NewState: TProfileState) of object;
TDescriptorReadEvent = procedure (Sender: TObject; Status: Integer; Descriptor: TBluetoothGattDescriptor) of object;
TDescriptorWriteEvent = procedure (Sender: TObject; Status: Integer; Descriptor: TBluetoothGattDescriptor) of object;
TMtuChangedEvent = procedure (Sender: TObject; Status: Integer; MTU: Integer) of object;
TReadRemoteRssiEvent = procedure (Sender: TObject; Status: Integer; RSSI: Integer) of object;
TReliableWriteCompletedEvent = procedure (Sender: TObject; Status: Integer) of object;
TServicesDiscoveredEvent = procedure (Sender: TObject; Status: Integer) of object;
TBluetoothDevice = class
procedure ConnectGatt(AutoConnect: Boolean = False; Transport: TTransport = TTransport.Auto);
procedure CloseGatt;
procedure CreateBond;
property Address: string read;
property BondState: TBondState read;
property Device: JBluetoothDevice read;
property DeviceClass: TDeviceClass read;
property DeviceName: string read;
property DeviceType: TDeviceType read;
property Gatt: TBluetoothGatt read;
property MajorClass: TDeviceMajorClass read;
property OnBondStateChanged: TNotifyEvent read write;
property OnCharacteristicChanged: TCharacteristicChangedEvent read write;
property OnCharacteristicRead: TCharacteristicReadEvent read write;
property OnCharacteristicWrite: TCharacteristicWriteEvent read write;
property OnConnectionStateChange: TConnectionStateChangeEvent read write;
property OnDescriptorRead: TDescriptorReadEvent read write;
property OnDescriptorWrite: TDescriptorWriteEvent read write;
property OnMtuChanged: TMtuChangedEvent read write;
property OnReadRemoteRssi: TReadRemoteRssiEvent read write;
property OnReliableWriteCompleted: TReliableWriteCompletedEvent read write;
property OnServicesDiscovered: TServicesDiscoveredEvent read write;
end;
TBluetoothGatt = class
procedure AbortReliableWrite;
procedure BeginReliableWrite;
procedure Close;
procedure Connect;
procedure DisableNotifications(Characteristic: TBluetoothGattCharacteristic; SetDescriptor: Boolean = True);
procedure Disconnect;
procedure DiscoverServices;
procedure EnableNotifications(Characteristic: TBluetoothGattCharacteristic; SetDescriptor: Boolean = True);
procedure ExecuteReliableWrite;
function GetService(AssignedNumber: Word): TBluetoothGattService;
function GetService(UUID: TGUID): TBluetoothGattService;
procedure Read(Characteristic: TBluetoothGattCharacteristic);
procedure Read(Descriptor: TBluetoothGattDescriptor);
procedure ReadRemoteRSSI;
procedure RequestConnectionPriority(Priority: TConnectionPriority);
procedure RequestMTU(MTU: Integer);
procedure Write(Characteristic: TBluetoothGattCharacteristic);
procedure Write(Descriptor: TBluetoothGattDescriptor);
property Gatt: JBluetoothGatt read;
property Services: TBluetoothGattServices read;
end;
TBluetoothGattService = class
const
GenericAccessService = ;
...
Assignments: array [..] of TGattAssignment =
(
(Name: 'Generic Access'; Number: GenericAccessService),
...
);
function GetCharacteristic(AssignetNumber: Word): TBluetoothGattCharacteristic;
function GetCharacteristic(UUID: TGUID): TBluetoothGattCharacteristic;
property AssignedNumber: Word read;
property GattService: JBluetoothGattService read;
property Characteristics: TBluetoothGattCharacteristics read;
property IncludedServices: TBluetoothGattServices read;
property InstanceId: Integer read;
property ServiceName: string read;
property ServiceType: TServiceType read;
property UUID: TGUID read;
end;
TBluetoothGattCharacteristic = class
const
AerobicHeartRateLowerLimit = ;
...
Assignments: array [..] of TGattAssignment =
(
(Name: 'Aerobic Heart Rate Lower Limit'; Number: AerobicHeartRateLowerLimit),
...
);
function GetDescriptor(AssignedNumber: Word): TBluetoothGattDescriptor;
function GetDescriptor(UUID: TGUID): TBluetoothGattDescriptor;
function GetInt8Value(Offset: Integer = 0): Int8;
function GetInt16Value(Offset: Integer = 0): Int16;
function GetInt32Value(Offset: Integer = 0): Int32;
function GetInt64Value(Offset: Integer = 0): Int64;
function GetUInt8Value(Offset: Integer = 0): UInt8;
function GetUInt16Value(Offset: Integer = 0): UInt16;
function GetUInt32Value(Offset: Integer = 0): UInt32;
function GetUInt64Value(Offset: Integer = 0): UInt64;
function GetFloat32(Offset: Integer = 0): Float32;
function GetFloat64(Offset: Integer = 0): Float64;
function GetStringValue(Offset: Integer = 0): string;
procedure SetInt8Value(Value: Int8; Offset: Integer = 0);
procedure SetInt16Value(Value: Int16; Offset: Integer = 0);
procedure SetInt32Value(Value: Int32; Offset: Integer = 0);
procedure SetInt64Value(Value: Int64; Offset: Integer = 0);
procedure SetUInt8Value(Value: UInt8; Offset: Integer = 0);
procedure SetUInt16Value(Value: UInt16; Offset: Integer = 0);
procedure SetUInt32Value(Value: UInt32; Offset: Integer = 0);
procedure SetUInt64Value(Value: UInt64; Offset: Integer = 0);
procedure SetFloat32(Value: Float32; Offset: Integer = 0);
procedure SetFloat64(Value: Float64; Offset: Integer = 0);
procedure SetStringValue(const Value: string);
property AssignedNumber: Word read;
property CharacteristicName: string read;
property GattCharacteristic: JBluetoothGattCharacteristic read;
property Descriptors: TBluetoothGattDescriptors read;
property InstanceId: Integer read;
property Permissions: TPermissions read;
property Properties: TProperties read;
property Service: TBluetoothGattService read;
property UUID: TGUID read;
property Value: TBytes read write;
property WriteType: TWriteType read write;
end;
TBluetoothGattDescriptor = class
const
CharacteristicAggregateFormat = ;
...
Assignments: array [..] of TGattAssignment =
(
(Name: 'Characteristic Aggregate Format'; Number: CharacteristicAggregateFormat),
...
);
property AssignedNumber: Word read;
property Characteristic: TBluetoothGattCharacteristic read;
property DescriptorName: string read;
property GattDescriptor: JBluetoothGattDescriptor read;
property Indication: Boolean read write;
property Notification: Boolean read write;
property Permissions: TPermissions read;
property Value: TBytes read write;
property UUID: TGUID read;
end;
TScanResult = class
property Device: TBluetoothDevice read;
property RSSI: Integer read;
property ScanResult: JScanResult read;
property Timestamp: Int64 read;
end;
const
BaseUUID: TGUID = '{00000000-0000-1000-8000-00805F9B34FB}';
type
TResultProc = reference to procedure();
function ApiVersion: Integer;
procedure Check(Value: Boolean; const Message: string);
procedure RequestPermission(const OnPermissionGranted, OnPermissionDenied: TResultProc;
OnDisplayRationale: TDisplayRationaleProc = nil);
function LocationEnabled: Boolean;
function ValidAddress(const BluetoothAddress: string): Boolean;
function ToGUID(Value: JUUID): TGUID;
function ToJUUID(Value: TGUID): JUUID;
function ToGUID(AssignedNumber: Word): TGUID;
function ToJUUID(AssignedNumber: Word): JUUID;
function ToAssignedNumber(Value: JUUID): Word;
function ToAssignedNumber(Value: TGUID): Word;
function ToByteArray(JavaArray: TJavaArray): TArray;
function ToJavaByteArray(ByteArray: TArray): TJavaArray;
Only for V.I.P
Warning! You are not allowed to view this text.