|
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. |
0 commit comments