Skip to content

Commit 38a74e3

Browse files
committed
Aligned bindings with SimpleBle v0.6.0
1 parent 2fcd470 commit 38a74e3

File tree

1 file changed

+13
-34
lines changed

1 file changed

+13
-34
lines changed

SimpleBleUnit/simpleble.pas

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
{$UNDEF DYNAMIC_LOADING}
1616
{$IFDEF WINDOWS}
17-
{$DEFINE DYNAMIC_LOADING} { UNCOMMENT IF YOU WANT DYNAMIC LOADING }
17+
//{$DEFINE DYNAMIC_LOADING} { UNCOMMENT IF YOU WANT DYNAMIC LOADING }
1818
{$ENDIF}
1919

2020

@@ -101,12 +101,21 @@ TSimpleBleCharacteristic = record
101101
end;
102102

103103
//typedef struct {
104-
// simpleble_uuid_t uuid;
105-
// size_t characteristic_count;
106-
// simpleble_characteristic_t characteristics[SIMPLEBLE_CHARACTERISTIC_MAX_COUNT];
104+
// simpleble_uuid_t uuid;
105+
// size_t data_length;
106+
// uint8_t data[27];
107+
// // Note: The maximum length of a BLE advertisement is 31 bytes.
108+
// // The first byte will be the length of the field,
109+
// // the second byte will be the type of the field,
110+
// // the next two bytes will be the service UUID,
111+
// // and the remaining 27 bytes are the manufacturer data.
112+
// size_t characteristic_count;
113+
// simpleble_characteristic_t characteristics[SIMPLEBLE_CHARACTERISTIC_MAX_COUNT];
107114
//} simpleble_service_t;
108115
TSimpleBleService = record
109116
Uuid: TSimpleBleUuid;
117+
DataLength: NativeUInt;
118+
Data: array[0..27-1] of Byte;
110119
CharacteristicCount: NativeUInt;
111120
Characteristics: array[0..SIMPLEBLE_CHARACTERISTIC_MAX_COUNT-1] of TSimpleBleCharacteristic;
112121
end;
@@ -127,22 +136,6 @@ TSimpleBleManufacturerData = record
127136
Data: array[0..27-1] of Byte
128137
end;
129138

130-
//typedef struct {
131-
// simpleble_uuid_t service_uuid;
132-
// size_t data_length;
133-
// uint8_t data[27];
134-
// // Note: The maximum length of a BLE advertisement is 31 bytes.
135-
// // The first byte will be the length of the field,
136-
// // the second byte will be the type of the field,
137-
// // the next two bytes will be the service UUID,
138-
// // and the remaining 27 bytes are the manufacturer data.
139-
//} simpleble_service_data_t;
140-
TSimpleBleServiceData = record
141-
ServiceUuid: TSimpleBleUuid;
142-
DataLength: NativeUInt;
143-
Data: array[0..27-1] of Byte
144-
end;
145-
146139
//typedef void* simpleble_adapter_t;
147140
//typedef void* simpleble_peripheral_t;
148141
TSimpleBleAdapter = NativeUInt;
@@ -303,12 +296,6 @@ function SimpleBlePeripheralManufacturerDataCount(Handle: TSimpleBlePeripheral):
303296
//SIMPLEBLE_EXPORT simpleble_err_t simpleble_peripheral_manufacturer_data_get(simpleble_peripheral_t handle, size_t index, simpleble_manufacturer_data_t* manufacturer_data);
304297
function SimpleBlePeripheralManufacturerDataGet(Handle: TSimpleBlePeripheral; Index: NativeUInt; var ManufacturerData: TSimpleBleManufacturerData): TSimpleBleErr; cdecl; external SimpleBleExtLibrary name 'simpleble_peripheral_manufacturer_data_get';
305298

306-
//SIMPLEBLE_EXPORT size_t simpleble_peripheral_service_data_count(simpleble_peripheral_t handle);
307-
function SimpleBlePeripheralServiceDataCount(Handle: TSimpleBlePeripheral): NativeUInt; cdecl; external SimpleBleExtLibrary name 'simpleble_peripheral_service_data_count';
308-
309-
//SIMPLEBLE_EXPORT simpleble_err_t simpleble_peripheral_service_data_get(simpleble_peripheral_t handle, size_t index, simpleble_service_data_t* service_data);
310-
function SimpleBlePeripheralServiceDataGet(Handle: TSimpleBlePeripheral; Index: NativeUInt; var ServiceData: TSimpleBleServiceData): TSimpleBleErr; cdecl; external SimpleBleExtLibrary name 'simpleble_peripheral_service_data_get';
311-
312299
//SIMPLEBLE_EXPORT simpleble_err_t simpleble_peripheral_read(simpleble_peripheral_t handle, simpleble_uuid_t service, simpleble_uuid_t characteristic, uint8_t** data, size_t* data_length);
313300
function SimpleBlePeripheralRead(Handle: TSimpleBlePeripheral; service: TSimpleBleUuid; Characteristic: TSimpleBleUuid; var Data: PByte; var DataLength: NativeUInt): TSimpleBleErr; cdecl; external SimpleBleExtLibrary name 'simpleble_peripheral_read';
314301

@@ -454,8 +441,6 @@ procedure SimpleBleUnloadLibrary();
454441
SimpleBlePeripheralServicesGet : function(Handle: TSimpleBlePeripheral; Index: NativeUInt; var Services: TSimpleBleService): TSimpleBleErr; cdecl;
455442
SimpleBlePeripheralManufacturerDataCount : function(Handle: TSimpleBlePeripheral): NativeUInt; cdecl;
456443
SimpleBlePeripheralManufacturerDataGet : function(Handle: TSimpleBlePeripheral; Index: NativeUInt; var ManufacturerData: TSimpleBleManufacturerData): TSimpleBleErr; cdecl;
457-
SimpleBlePeripheralServiceDataCount: function(Handle: TSimpleBlePeripheral): NativeUInt; cdecl;
458-
SimpleBlePeripheralServiceDataGet: function (Handle: TSimpleBlePeripheral; Index: NativeUInt; var ServiceData: TSimpleBleServiceData): TSimpleBleErr; cdecl;
459444
SimpleBlePeripheralRead : function(Handle: TSimpleBlePeripheral; service: TSimpleBleUuid; Characteristic: TSimpleBleUuid; var Data: PByte; var DataLength: NativeUInt): TSimpleBleErr; cdecl;
460445
SimpleBlePeripheralWriteRequest : function(Handle: TSimpleBlePeripheral; service: TSimpleBleUuid; Characteristic: TSimpleBleUuid; Data: PByte; DataLength: NativeUInt): TSimpleBleErr; cdecl;
461446
SimpleBlePeripheralWriteCommand : function(Handle: TSimpleBlePeripheral; service: TSimpleBleUuid; Characteristic: TSimpleBleUuid; Data: PByte; DataLength: NativeUInt): TSimpleBleErr; cdecl;
@@ -549,8 +534,6 @@ procedure ClearPointers;
549534
pointer(SimpleBlePeripheralServicesGet) := Nil;
550535
pointer(SimpleBlePeripheralManufacturerDataCount) := Nil;
551536
pointer(SimpleBlePeripheralManufacturerDataGet) := Nil;
552-
pointer(SimpleBlePeripheralServiceDataCount) := Nil;
553-
pointer(SimpleBlePeripheralServiceDataGet) := Nil;
554537
pointer(SimpleBlePeripheralRead) := Nil;
555538
pointer(SimpleBlePeripheralWriteRequest) := Nil;
556539
pointer(SimpleBlePeripheralWriteCommand) := Nil;
@@ -628,8 +611,6 @@ function SimpleBleLoadLibrary(dllPath:string=''): Boolean;
628611
pointer(SimpleBlePeripheralServicesGet) := GetProcedureAddress(hLib, 'simpleble_peripheral_services_get');
629612
pointer(SimpleBlePeripheralManufacturerDataCount) := GetProcedureAddress(hLib, 'simpleble_peripheral_manufacturer_data_count');
630613
pointer(SimpleBlePeripheralManufacturerDataGet) := GetProcedureAddress(hLib, 'simpleble_peripheral_manufacturer_data_get');
631-
pointer(SimpleBlePeripheralServiceDataCount) := GetProcedureAddress(hLib, 'simpleble_peripheral_service_data_count');
632-
pointer(SimpleBlePeripheralServiceDataGet) := GetProcedureAddress(hLib, 'simpleble_peripheral_service_data_get');
633614
pointer(SimpleBlePeripheralRead) := GetProcedureAddress(hLib, 'simpleble_peripheral_read');
634615
pointer(SimpleBlePeripheralWriteRequest) := GetProcedureAddress(hLib, 'simpleble_peripheral_write_request');
635616
pointer(SimpleBlePeripheralWriteCommand) := GetProcedureAddress(hLib, 'simpleble_peripheral_write_command');
@@ -695,8 +676,6 @@ function SimpleBleLoadLibrary(dllPath:string=''): Boolean;
695676
(pointer(SimpleBlePeripheralServicesGet) = Nil) or
696677
(pointer(SimpleBlePeripheralManufacturerDataCount) = Nil) or
697678
(pointer(SimpleBlePeripheralManufacturerDataGet) = Nil) or
698-
(pointer(SimpleBlePeripheralServiceDataCount) = Nil) or
699-
(pointer(SimpleBlePeripheralServiceDataGet) = Nil) or
700679
(pointer(SimpleBlePeripheralRead) = Nil) or
701680
(pointer(SimpleBlePeripheralWriteRequest) = Nil) or
702681
(pointer(SimpleBlePeripheralWriteCommand) = Nil) or

0 commit comments

Comments
 (0)