10

I'm working on an idea which requires my Mac to send some data to my iOS device. I know CoreBluetooth framework is not there for Mac OS and only for iOS, so is there any way that I can get my Mac to pose a peripheral ?

I've done some Googling around - haven't got a straight answer :(

Mohit Athwani
  • 883
  • 9
  • 17

2 Answers2

11

The CoreBluetooth.Framework is there for OSX. It's embedded inside of the IOBluetooth.framework. Download the sample mac apps from the Apple Dev Site. The one difference is that the OSX version of the CoreBluetooth.Framework does not contain the CBPeripheralManager class. You should just have your iOS device act as the peripheral and the Mac as the central. The iOS device can act as both at the same time and data can be sent both ways.

Tommy Devoy
  • 13,441
  • 3
  • 48
  • 75
  • 4
    Note that `CBPeripheralManager` is available in OS X 10.9 and later ([link](https://developer.apple.com/library/mac/documentation/CoreBluetooth/Reference/CBPeripheralManager_Class/)). – KevinH Nov 24 '14 at 06:07
  • Its recommended that you use your mac as a peripheral if you require 2 way communication. Because you should close connections as soon as tasks are completed. – Sentry.co Nov 24 '20 at 10:35
5

If you are comfortable with writing JavaScript, you can use bleno. It is a node.js module for implementing BLE (Bluetooth Low Energy) peripherals, and it support Mac OS X 10.9 or later, Linux and Windows.

You can find an example for implementing a Battery Service in peripheral mode in their github repository:

https://github.com/sandeepmistry/bleno/tree/master/examples/battery-service

urish
  • 8,943
  • 8
  • 54
  • 75