HeartBLEDriver.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // HeartBLEDriver.h
  3. // HeartTestDemo
  4. //
  5. // Created by 郭志奇 on 2019/8/7.
  6. // Copyright © 2019 郭志奇. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <CoreBluetooth/CoreBluetooth.h>
  10. NS_ASSUME_NONNULL_BEGIN
  11. @class HeartBLEDevice;
  12. @protocol BLEDriveDelegate <NSObject>
  13. @optional
  14. - (void)onDeviceFound:(NSArray *)deviceArray;
  15. - (void)isConnected:(BOOL)isConnected withDevice:(HeartBLEDevice *)device;
  16. - (void)disconnected:(HeartBLEDevice *)device;
  17. @end
  18. @class HeartBLEDevice;
  19. @interface HeartBLEDriver : NSObject{
  20. id __weak theDelegate;
  21. CBCentralManager* centralManager;
  22. NSMutableArray *discoverDevices;
  23. NSMutableArray *discoverPers;
  24. NSMutableArray *connectedPeripherals;
  25. NSMutableArray *theFliter;
  26. @public
  27. NSMutableArray *connectedDevices;
  28. }
  29. @property (nonatomic,assign)BOOL isBLEPoweredOn;
  30. + (HeartBLEDriver*)sharedInstance;
  31. - (void)setDelegate:(id)delegate;
  32. - (void)StartScanForDevice;
  33. - (void)stopScan;
  34. - (void)connectDevice: (CBPeripheral*)device;
  35. - (void)disConnectDevice:(CBPeripheral*)device;
  36. - (void)closelAllDevice;
  37. - (void)addDiscoverPers:(CBPeripheral *)peripheral;
  38. - (CBPeripheral *)getPeripheralWithDevice:(HeartBLEDevice *)device;
  39. - (HeartBLEDevice *)getDeviceWithPeripheral:(CBPeripheral *)peripheral;
  40. @end
  41. NS_ASSUME_NONNULL_END