iOS ailink secret tool
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ELBluetoothManager.h 3.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //
  2. // ELBluetoothManager.h
  3. // Elink
  4. //
  5. // Created by iot_user on 2019/4/22.
  6. // Copyright © 2019 iot_iMac. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "ELPeripheralModel.h"
  10. #import <AILinkSecretTool/ELSDKHeader.h>
  11. //MARK:蓝牙通用协议
  12. @protocol ELBluetoothManagerDelegate <NSObject>
  13. @optional
  14. //Callback Bluetooth status(回调蓝牙状态)
  15. -(void)bluetoothManagerUpdateBleState:(ELBluetoothState)state;
  16. //Callback to scanned device(回调扫描到的设备)
  17. -(void)bluetoothManagerScanedPeripherals:(NSArray<ELPeripheralModel *> *_Nonnull)peripherals;
  18. //Callback decrypted transparent data (A7 decrypted payload data)(回调解密后的数据(A7解密后payload数据))
  19. -(void)bluetoothManagerReceiveData:(NSData *_Nonnull)data deviceType:(ELSupportDeviceType)type;
  20. /**
  21. Callback transparent transmission data(回调透传数据)
  22. @param data Transparent data transmission (this data cannot start with A6 or A7)(透传数据(此数据不能以A6或A7开头))
  23. */
  24. -(void)bluetoothManagerReceivePassData:(NSData *_Nullable)data;
  25. @end
  26. NS_ASSUME_NONNULL_BEGIN
  27. @interface ELBluetoothManager : NSObject
  28. @property (nonatomic, assign, readonly) BOOL isOn;
  29. //Bluetooth status(蓝牙状态)
  30. @property (nonatomic, assign, readonly) ELBluetoothState state;
  31. //version number(版本号)
  32. @property (nonatomic, copy, readonly) NSString *bmVersion;
  33. /**
  34. Save the model corresponding to the currently connected device
  35. 保存当前连接的设备对应的模型
  36. */
  37. @property (nonatomic, strong, readonly) ELPeripheralModel *peripheralModel;
  38. //Bluetooth proxy(蓝牙代理)
  39. @property (nonatomic, weak) id<ELBluetoothManagerDelegate> delegate;
  40. /** 需要搜索与系统绑定的蓝牙设备 */
  41. @property (nonatomic, assign) BOOL needScanBindSysDevice;
  42. //设置appkey和secret
  43. +(void)setAppKey:(NSString *)key appSecret:(NSString *)secret;
  44. //
  45. +(__kindof ELBluetoothManager * _Nonnull)shareManager;
  46. //Start scanning(开始扫描)
  47. -(void)startScan;
  48. //Start scanning all (开始扫描附近所有设备)
  49. - (void)startScanAll;
  50. //Stop scanning(停止扫描)
  51. -(void)stopScan;
  52. //Connecting device(连接设备)
  53. -(void)connectPeripheral:(ELPeripheralModel *)peripheralModel;
  54. //Disconnect device(断开设备)
  55. -(void)disconnectPeripheral;
  56. #pragma mark ============ 发送指令的3种方法 ==============
  57. /**
  58. Shortcut method to send A6 data to BLE(发送A6数据给BLE的快捷方法)
  59. @param data The stitched payload part(拼接好的payload部分)
  60. */
  61. -(void)sendCmdToMCUWithA6PayloadData:(NSData *)data;
  62. /**
  63. Shortcut method of sending A7 data to MCU(发送A7数据给MCU的快捷方法)
  64. @param data The stitched payload part(拼接好的payload部分)
  65. @param type Equipment type(设备类型)
  66. */
  67. -(void)sendCmdToMCUWithA7PayloadData:(NSData *)data deviceType:(ELSupportDeviceType)type;
  68. /**
  69. General method of sending data (support data transparent transmission)(发送数据通用方法(支持数据透传))
  70. @param data 数据
  71. */
  72. -(void)sendData:(NSData *)data;
  73. @end
  74. NS_ASSUME_NONNULL_END