Skip to content

nick10811/BLEManager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BLEManager

Descriptions

This is a library of Bluetooth 4.0 which based on iOS. It makes you easy to implement Bluetooth technique on your project. First of all, you should initial object of BLEManager, it is a singleton object, then you can re-use in your program by the method of “sharedManager”. When you need to communicate with device, you should use the method of “scanningForServicesWithPeripheral“ to search all services and characters first. It is an important procedure before you want to send or receive data with device. If you do not use this method, it cannot correct to communicate with device. When the length of transmission data is too long, the write/read method may has long time to process.

Installation

  • BLEManager is available through CocoaPods.
  • You can also download the BLEManager.{m,h} files into your project directly.

How to use

  • Inital this object
+ (BLEManager *)sharedManagerWithDelegate:(id<BLEManagerDelegate>)delegate;
  • Reuse object (singleton)
+ (BLEManager *)sharedManager;
  • Kill object
- (void)disableBLEManager;
  • Check bluetooth device is connected
- (BOOL)isConnecting;
  • Scan all devices
- (void)scanningForPeripherals;
  • Scan all devices by restricted distance
- (void)scanningForPeripheralsWithDistance:(int)RSSI;
  • Stop scan devices
- (void)stopScanningForPeripherals;
  • Connect specified device
- (void)connectingPeripheral:(CBPeripheral *)peripheral;
  • Disconnect specified device
- (void)disconnectPeripheral:(CBPeripheral *)peripheral;
  • Get Received Signal Strength Indicator(RSSI) by device
- (int)readRSSI:(CBPeripheral *)peripheral;
  • Scan all services in the device
- (void)scanningForServicesWithPeripheral:(CBPeripheral *)peripheral;

Communicate with device after scanning all services

  • Write data to device
- (NSError *)setValue:(NSData *) data forServiceUUID:(NSString *) serviceUUID andCharacteristicUUID:(NSString *) charUUID withPeripheral:(CBPeripheral *)peripheral;
  • Read data from device
- (NSData *)readValueForServiceUUID:(NSString *) serviceUUID andCharacteristicUUID:(NSString *) charUUID withPeripheral:(CBPeripheral *)peripheral;

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published