Skip to content

Commit 0f2b36a

Browse files
author
eriklins
committed
Added Lazarus projects and folder with the unit.
1 parent 53ac90c commit 0f2b36a

38 files changed

+2950
-2
lines changed

Pascal_Unit/simpleble.pas

Lines changed: 320 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,60 @@
1-
# Pascal-Bindings-For-SimpleBLE-Library
2-
These are Lazarus/FreePascal Bindings for the SimpleBLE Cross-Platform Library
1+
# Pascal Bindings For SimpleBLE Library
2+
These are Lazarus/FreePascal bindings for the SimpleBLE cross-platform Bluetooth LE (BLE) library.
3+
4+
## SimpleBLE
5+
SimpleBLE is a fully-fledged cross-platform library and bindings for Bluetooth Low Energy (BLE).
6+
7+
> "The SimpleBLE project aims to provide fully cross-platform BLE libraries and bindings for Python and C++, designed for simplicity and ease of use with a licencing scheme chosen to be friendly towards commercial use. All specific operating system quirks are handled internally to provide a consistent behavior across all platforms. The libraries also provide first-class support for vendorization of all third-party dependencies, allowing for easy integration into existing projects."
8+
9+
The project lives on github (https://github.com/OpenBluetoothToolbox/SimpleBLE) and documentation is available through ReadTheDocs (https://simpleble.readthedocs.io/en/latest/).
10+
11+
It can be easily compiled into a shared library (.dll, .so, .dylib) and so far comes with C/C++ and Python bindings for the library functions. This project here adds Pascal bindings based on the C API in form of a unit to leverage the library functionality in [Lazarus](https://www.lazarus-ide.org/) / [FreePascal](https://www.freepascal.org/) projects.
12+
13+
## Usage
14+
The SimpleBLE bindings come as a single-file Pascal unit and this is in the folder "Pascal\_Unit". To use it in a Lazarus/FreePascal project just copy it to the folder of your Lazarus project and add it to your project files list.
15+
16+
To actually use the SimpleBLE functions in the compiled application, the corresponding shared libraries need to be copied into the same path as the compiled application. (Alternatively other location could be used, provided it's on the PATH or it's some system wide location like Windows\System32 - however, at least the latter is usually not recommended.)
17+
18+
Here is a list of required files:
19+
* **simpleble.pas**
20+
The Pascal unit with SimpleBLE bindings.
21+
* **simpleble-c.dll, simpleble.dll, fmt.dll**
22+
The three shared libraries with all the SimpleBLE functionality in. You need all three of them.
23+
24+
On Windows systems shared libraries use the extension ".dll", but on other systems this is different (like .so on Linux/Unix).
25+
26+
### Building the SimpleBLE Shared Libraries
27+
The SimpleBLE project comes with batch files / shell scripts for Windows / Linux which automagically compile the shared libraries. These are located in the "utils" folder of the SimpleBLE repo. The compiled libraries will go into "build\_simpleble/bin/Release". A suitable compiler needs to be installed, I used Visual Studio Community edition 2022 (64 bit), version 17.3.6 on Windows 10 / 64 bit.
28+
29+
Currently the Pascal bindings have been implemented and tested with Lazarus version 2.3.0 and Free Pascal version 3.3.1 (installed 'trunk' with fpdupdeluxe) on Windows 10 / 64 bit. Other CPUs and OS's is work in progress.
30+
31+
## Examples
32+
The original SimpleBLE project comes with three C examples, which have been ported to Lazarus:
33+
34+
* **SimpleBleScanExample**
35+
A console application based on scan.c from SimpleBLE and demonstrates scanning for BLE advertisements from peripherals. The output shows a list of devices with device name (if present) and BLE MAC address.
36+
* **SimpleBleConnectExample**
37+
A console application based on connect.c from SimpleBLE and demonstrates
38+
* Scanning for BLE advertisements from peripherals like above.
39+
* Selecting a peripheral to connect to.
40+
* Fetch BLE services, characteristics and descriptors from the peripherals's GATT table and shows as a list.
41+
* **SimpleBleNotifyExample**
42+
A console application based on notify.c from SimpleBLE and demonstrates
43+
* Scanning for BLE advertisements from peripherals like above.
44+
* Selecting a peripheral to connect to.
45+
* Fetch BLE services, characteristics and descriptors from the peripherals's GATT table and shows as a list.
46+
* Selecting a characteristic and subscribe to notifications.
47+
* If characteristic value changes on the peripheral, the new values are shown.
48+
49+
There are some more examples, but those are C++ and weren't (yet...) ported to Pascal.
50+
51+
## Releases
52+
Pre-built SimpleBLE shared libraries are available on the [releases tab](https://github.com/eriklins/Pascal-Bindings-For-SimpleBLE-Library/releases). Currently there are only Windows 64 bit DLLs available (more to come).
53+
54+
## Contributing/Feedback
55+
I'm far from being an expert in Pascal programming, but liked and used Lazarus/FreePascal for some projects. So, feedback / improvements / pull-requests / etc. are welcome!
56+
57+
## License
58+
Copyright (C) 2022 Erik Lins
59+
60+
This project is released under the MIT License.
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<CONFIG>
3+
<ProjectOptions>
4+
<Version Value="12"/>
5+
<PathDelim Value="\"/>
6+
<General>
7+
<Flags>
8+
<MainUnitHasCreateFormStatements Value="False"/>
9+
<MainUnitHasScaledStatement Value="False"/>
10+
</Flags>
11+
<SessionStorage Value="InProjectDir"/>
12+
<Title Value="SimpleBleConnectExample"/>
13+
<UseAppBundle Value="False"/>
14+
<ResourceType Value="res"/>
15+
</General>
16+
<BuildModes>
17+
<Item Name="Debug" Default="True"/>
18+
<Item Name="Win64">
19+
<CompilerOptions>
20+
<Version Value="11"/>
21+
<PathDelim Value="\"/>
22+
<Target>
23+
<Filename Value="bin\$(TargetOS)-$(TargetCPU)\SimpleBleConnectExample"/>
24+
</Target>
25+
<SearchPaths>
26+
<IncludeFiles Value="$(ProjOutDir)"/>
27+
<UnitOutputDirectory Value="lib\$(TargetOS)-$(TargetCPU)"/>
28+
</SearchPaths>
29+
<CodeGeneration>
30+
<TargetCPU Value="x86_64"/>
31+
<TargetOS Value="win64"/>
32+
<Optimizations>
33+
<OptimizationLevel Value="2"/>
34+
</Optimizations>
35+
</CodeGeneration>
36+
<Linking>
37+
<Debugging>
38+
<GenerateDebugInfo Value="False"/>
39+
<DebugInfoType Value="dsDwarf3"/>
40+
</Debugging>
41+
</Linking>
42+
</CompilerOptions>
43+
</Item>
44+
<Item Name="Win32">
45+
<CompilerOptions>
46+
<Version Value="11"/>
47+
<PathDelim Value="\"/>
48+
<Target>
49+
<Filename Value="bin\$(TargetOS)-$(TargetCPU)\SimpleBleConnectExample"/>
50+
</Target>
51+
<SearchPaths>
52+
<IncludeFiles Value="$(ProjOutDir)"/>
53+
<UnitOutputDirectory Value="lib\$(TargetOS)-$(TargetCPU)"/>
54+
</SearchPaths>
55+
<CodeGeneration>
56+
<TargetCPU Value="i386"/>
57+
<TargetOS Value="win32"/>
58+
<Optimizations>
59+
<OptimizationLevel Value="2"/>
60+
</Optimizations>
61+
</CodeGeneration>
62+
<Linking>
63+
<Debugging>
64+
<GenerateDebugInfo Value="False"/>
65+
<DebugInfoType Value="dsDwarf3"/>
66+
</Debugging>
67+
</Linking>
68+
</CompilerOptions>
69+
</Item>
70+
<Item Name="Linux64">
71+
<CompilerOptions>
72+
<Version Value="11"/>
73+
<PathDelim Value="\"/>
74+
<Target>
75+
<Filename Value="bin\$(TargetOS)-$(TargetCPU)\SimpleBleConnectExample"/>
76+
</Target>
77+
<SearchPaths>
78+
<IncludeFiles Value="$(ProjOutDir)"/>
79+
<UnitOutputDirectory Value="lib\$(TargetOS)-$(TargetCPU)"/>
80+
</SearchPaths>
81+
<CodeGeneration>
82+
<TargetCPU Value="x86_64"/>
83+
<TargetOS Value="linux"/>
84+
<Optimizations>
85+
<OptimizationLevel Value="2"/>
86+
</Optimizations>
87+
</CodeGeneration>
88+
<Linking>
89+
<Debugging>
90+
<GenerateDebugInfo Value="False"/>
91+
<DebugInfoType Value="dsDwarf3"/>
92+
</Debugging>
93+
</Linking>
94+
</CompilerOptions>
95+
</Item>
96+
<Item Name="Linux32">
97+
<CompilerOptions>
98+
<Version Value="11"/>
99+
<PathDelim Value="\"/>
100+
<Target>
101+
<Filename Value="bin\$(TargetOS)-$(TargetCPU)\SimpleBleConnectExample"/>
102+
</Target>
103+
<SearchPaths>
104+
<IncludeFiles Value="$(ProjOutDir)"/>
105+
<UnitOutputDirectory Value="lib\$(TargetOS)-$(TargetCPU)"/>
106+
</SearchPaths>
107+
<CodeGeneration>
108+
<TargetCPU Value="i386"/>
109+
<TargetOS Value="linux"/>
110+
<Optimizations>
111+
<OptimizationLevel Value="2"/>
112+
</Optimizations>
113+
</CodeGeneration>
114+
<Linking>
115+
<Debugging>
116+
<GenerateDebugInfo Value="False"/>
117+
<DebugInfoType Value="dsDwarf3"/>
118+
</Debugging>
119+
</Linking>
120+
</CompilerOptions>
121+
</Item>
122+
</BuildModes>
123+
<PublishOptions>
124+
<Version Value="2"/>
125+
<UseFileFilters Value="True"/>
126+
</PublishOptions>
127+
<RunParams>
128+
<FormatVersion Value="2"/>
129+
</RunParams>
130+
<Units>
131+
<Unit>
132+
<Filename Value="SimpleBleConnectExample.lpr"/>
133+
<IsPartOfProject Value="True"/>
134+
</Unit>
135+
<Unit>
136+
<Filename Value="simpleble.pas"/>
137+
<IsPartOfProject Value="True"/>
138+
<UnitName Value="SimpleBle"/>
139+
</Unit>
140+
</Units>
141+
</ProjectOptions>
142+
<CompilerOptions>
143+
<Version Value="11"/>
144+
<PathDelim Value="\"/>
145+
<Target>
146+
<Filename Value="bin\Debug\SimpleBleConnectExample"/>
147+
</Target>
148+
<SearchPaths>
149+
<IncludeFiles Value="$(ProjOutDir)"/>
150+
<UnitOutputDirectory Value="lib\Debug"/>
151+
</SearchPaths>
152+
<Linking>
153+
<Debugging>
154+
<DebugInfoType Value="dsDwarf3"/>
155+
</Debugging>
156+
</Linking>
157+
</CompilerOptions>
158+
<Debugging>
159+
<Exceptions>
160+
<Item>
161+
<Name Value="EAbort"/>
162+
</Item>
163+
<Item>
164+
<Name Value="ECodetoolError"/>
165+
</Item>
166+
<Item>
167+
<Name Value="EFOpenError"/>
168+
</Item>
169+
</Exceptions>
170+
</Debugging>
171+
</CONFIG>

0 commit comments

Comments
 (0)