https://github.com/artem14133q/iobt
Library for manage bluetooth in MacOS system
https://github.com/artem14133q/iobt
bluetooth clang lib macos objective-c shared-library static-library
Last synced: about 2 months ago
JSON representation
Library for manage bluetooth in MacOS system
- Host: GitHub
- URL: https://github.com/artem14133q/iobt
- Owner: artem14133q
- License: gpl-3.0
- Created: 2022-07-25T13:45:28.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-07-04T21:59:33.000Z (almost 3 years ago)
- Last Synced: 2025-01-17T10:26:19.277Z (over 1 year ago)
- Topics: bluetooth, clang, lib, macos, objective-c, shared-library, static-library
- Language: Objective-C
- Homepage:
- Size: 34.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# iobt
[](https://github.com/artem14133q/iobt/actions/workflows/cmake.yml)
Library for manage bluetooth in MacOS system
## Structs
```objectivec
// Contains some IOBluetoothDevice object parameters
// Alias: IOBT_DEVICE
struct Device {
char * address;
char * name;
char * recentAccessDate;
enum ConnectionStatus connected;
int rssi;
bool favorite;
bool paired;
};
// List of devices
// Alias: IOBT_DEVICES
struct DeviceArray {
int len;
struct Device * devices;
};
```
## Connection statuses
| Value | Name |
| ----- | ----------------- |
| `1` | **Not connected** |
| `2` | **Slave** |
| `3` | **Master** |
## Usage
1. Start scan device in range (seconds). If `timeout < 1` when `timeout = 10` sec.
```objectivec
struct DeviceArray search(int8_t timout);
```
2. Return array with paired devices.
```objectivec
struct DeviceArray paired();
```
3. Return array with connected devices.
```objectivec
struct DeviceArray connected();
```
4. Find device by `address`. If device not found, return fake device with current `address`.
If `strict` flag is `true` it exit with error when device not paired and not favorite.
```objectivec
struct Device getDevice(const char * address, bool strict);
```
5. Close connection. If device not disconnected, return `false`.
```objectivec
bool closeConnection(const char * address);
```
6. Open connection. If device not connected, return false. If device not found it try to connect with current `address`.
```objectivec
bool openConnection(const char * address);
```
7. Pair devices. If device paired when return 0. If device error when return `value > 0`.
```objectivec
int pair(const char * address, const char * pin);
```
8. Unpair devices. If device could not unpair, return `false`.
```objectivec
bool unpair(const char * address);
```
9. Return Bluetooth adapter power state.
```objectivec
bool power();
```
10. Power on/off (`true`/`false`) Bluetooth adapter. Return success flag.
```objectivec
bool setPower(bool enable);
```
## Building
#### Dev tools
* Apple clang
* cmake
* git
#### Make
```zsh
git clone git@github.com:artem14133q/iobt.git
cd iobt
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -G "CodeBlocks - Unix Makefiles" .. --build . --target all -- -j 1
```
`bin` directory will be generated in root project dir
#### Folder structure
```
.
└─ bin
│
├─ iobt
│ ├─ headers
│ │ ├─ iobt.h
│ │ └─ iobtTypes.h
│ │
│ ├─ shared
│ │ ├─ libiobt..dylib
│ │ ├─ libiobt..dylib
│ │ └─ libiobt.dylib
│ │
│ └─ static
│ ├─ libiobt..a
│ ├─ libiobt..a
│ └─ libiobt.a
│
└─ iobt.zip
```
## Contacts
**Telegram:** @artem_du
**Gmail:** dubisoft1520@gmail.com
## Contribute
**Welcome**