/iobt

Library for manage bluetooth in MacOS system

Primary LanguageObjective-CGNU General Public License v3.0GPL-3.0

iobt

CMake

Library for manage bluetooth in MacOS system

Structs

// 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.
struct DeviceArray search(int8_t timout);
  1. Return array with paired devices.
struct DeviceArray paired();
  1. Return array with connected devices.
struct DeviceArray connected();
  1. 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.
struct Device getDevice(const char * address, bool strict);
  1. Close connection. If device not disconnected, return false.
bool closeConnection(const char * address);
  1. Open connection. If device not connected, return false. If device not found it try to connect with current address.
bool openConnection(const char * address);
  1. Pair devices. If device paired when return 0. If device error when return value > 0.
int pair(const char * address, const char * pin);
  1. Unpair devices. If device could not unpair, return false.
bool unpair(const char * address);
  1. Return Bluetooth adapter power state.
bool power();
  1. Power on/off (true/false) Bluetooth adapter. Return success flag.
bool setPower(bool enable);

Building

Dev tools

  • Apple clang
  • cmake
  • git

Make

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.<version>.dylib
   │  │  ├─ libiobt.<version-major>.dylib
   │  │  └─ libiobt.dylib
   │  │
   │  └─ static
   │     ├─ libiobt.<version>.a
   │     ├─ libiobt.<version-major>.a
   │     └─ libiobt.a
   │  
   └─ iobt.zip

Contacts

Telegram: @artem_du
Gmail: dubisoft1520@gmail.com

Contribute

Welcome