LETransceiver.h 1.36 KB
//
//  LETransceiver.h
//  ActsBluetoothSpeed
//
//  Created by inidhu on 2019/3/15.
//  Copyright © 2019 Actions. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>

NS_ASSUME_NONNULL_BEGIN

#define KeyWriteServiceUUID             @"kWriteServiceUUID"
#define KeyIndicateServiceUUID          @"kIndicateServiceUUID"
#define KeyWriteCharacteristicUUID      @"kWriteCharacteristicUUID"
#define KeyIndicateCharacteristicUUID   @"kIndicateCharacteristicUUID"

@protocol LEConnctionDelegate <NSObject>

@required
- (void)onFoundPeripheral:(CBPeripheral *) peripheral advertisementData:(NSDictionary *) advertisementData;

@optional
- (void)onConnectedPeripheral:(CBPeripheral *) peripheral;
- (void)onDisconnectedPeripheral:(CBPeripheral *) peripheral;

@end

@protocol LEDataDelegate <NSObject>

@optional

- (void)onDataReceive:(NSData *) data;

@end

@interface LETransceiver : NSObject<CBPeripheralDelegate, CBCentralManagerDelegate>

@property (weak, nonatomic) id<LEConnctionDelegate> connectionDelegate;
@property (weak, nonatomic) id<LEDataDelegate> dataDelegate;

- (void)setUUIDs:(NSDictionary *) uuids;

- (void)scanStart;
- (void)scanStop;

- (void)connect:(CBPeripheral *)peripheral;
- (void)disconnect:(CBPeripheral *)peripheral;

- (void)write:(NSData *) data;
- (void)write:(NSData *) data index:(int) i;

@end

NS_ASSUME_NONNULL_END