Library for manage bluetooth in MacOS system
// 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;
};
Value | Name |
---|---|
1 |
Not connected |
2 |
Slave |
3 |
Master |
- Start scan device in range (seconds). If
timeout < 1
whentimeout = 10
sec.
struct DeviceArray search(int8_t timout);
- Return array with paired devices.
struct DeviceArray paired();
- Return array with connected devices.
struct DeviceArray connected();
- Find device by
address
. If device not found, return fake device with currentaddress
. Ifstrict
flag istrue
it exit with error when device not paired and not favorite.
struct Device getDevice(const char * address, bool strict);
- Close connection. If device not disconnected, return
false
.
bool closeConnection(const char * address);
- Open connection. If device not connected, return false. If device not found it try to connect with current
address
.
bool openConnection(const char * address);
- Pair devices. If device paired when return 0. If device error when return
value > 0
.
int pair(const char * address, const char * pin);
- Unpair devices. If device could not unpair, return
false
.
bool unpair(const char * address);
- Return Bluetooth adapter power state.
bool power();
- Power on/off (
true
/false
) Bluetooth adapter. Return success flag.
bool setPower(bool enable);
- Apple clang
- cmake
- git
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
.
└─ bin
│
├─ iobt
│ ├─ headers
│ │ ├─ iobt.h
│ │ └─ iobtTypes.h
│ │
│ ├─ shared
│ │ ├─ libiobt.<version>.dylib
│ │ ├─ libiobt.<version-major>.dylib
│ │ └─ libiobt.dylib
│ │
│ └─ static
│ ├─ libiobt.<version>.a
│ ├─ libiobt.<version-major>.a
│ └─ libiobt.a
│
└─ iobt.zip
Telegram: @artem_du
Gmail: dubisoft1520@gmail.com
Welcome