-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSerialGATT.h
executable file
·76 lines (57 loc) · 2.6 KB
/
SerialGATT.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//
// SerialGATT.h
// BLKSoft
//
// Created by BLKSofts on 7/13/12.
// Copyright (c) 2012 jnhuamao.cn. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
//#define SERIAL_PERIPHERAL_SERVICE_UUID @"FFF0"//@"FFF0" //可以看做是主服务,不干活的,就是标志
//#define SERIAL_PERIPHERAL_CHAR_RECV_UUID @"FFF1"//@"FFF1"
//#define SERIAL_PERIPHERAL_NOTIFY_SERVICE_UUID @"FFE0"
//#define SERIAL_PERIPHERAL_CHAR_NOTIFY_UUID @"FFE1"
/*#define mainService 0xFFA0
#define mainSub1 0xFFA1
#define mainSub2 0xFFA2
#define mainSub3 0xFFA3
#define mainSub4 0xFFA4
#define mainSub5 0xFFA5*/
#define fileService 0xFFE0
#define fileSub 0xFFE1
@protocol BTSmartSensorDelegate
@optional
- (void) peripheralFound:(CBPeripheral *)peripheral;
- (void) serialGATTCharValueUpdated: (NSString *)UUID value: (NSString *)str;
- (void) setConnect;
- (void) setDisconnect;
@end
@interface SerialGATT : NSObject<CBCentralManagerDelegate, CBPeripheralDelegate> {
}
@property (nonatomic, assign) id <BTSmartSensorDelegate> delegate;
@property (strong, nonatomic) NSMutableArray *peripherals;
@property (strong, nonatomic) CBCentralManager *manager;
@property (strong, nonatomic) CBPeripheral *activePeripheral;
@property (strong, nonatomic) NSMutableDictionary *peripheralDic;
#pragma mark - Methods for controlling the BLKSoft Sensor
-(void) setup; //controller setup
-(int) findBLKSoftPeripherals:(int)timeout;
-(void) scanTimer: (NSTimer *)timer;
-(void) connect: (CBPeripheral *)peripheral;
-(void) disconnect: (CBPeripheral *)peripheral;
-(void) write:(CBPeripheral *)peripheral data:(NSData *)data;
-(void) read:(CBPeripheral *)peripheral;
-(void) notify:(CBPeripheral *)peripheral on:(BOOL)on;
- (void) printPeripheralInfo:(CBPeripheral*)peripheral;
-(void) notification:(int)serviceUUID characteristicUUID:(int)characteristicUUID p:(CBPeripheral *)p on:(BOOL)on;
-(UInt16) swap:(UInt16)s;
-(CBService *) findServiceFromUUIDEx:(CBUUID *)UUID p:(CBPeripheral *)p;
-(CBCharacteristic *) findCharacteristicFromUUIDEx:(CBUUID *)UUID service:(CBService*)service;
-(const char *) UUIDToString:(CFUUIDRef) UUID;
-(const char *) CBUUIDToString:(CBUUID *) UUID;
-(int) compareCBUUID:(CBUUID *) UUID1 UUID2:(CBUUID *)UUID2;
-(int) compareCBUUIDToInt:(CBUUID *) UUID1 UUID2:(UInt16)UUID2;
-(UInt16) CBUUIDToInt:(CBUUID *) UUID;
-(void) writeValue:(int)serviceUUID characteristicUUID:(int)characteristicUUID p:(CBPeripheral *)p data:(NSData *)data;
-(void) readValue: (int)serviceUUID characteristicUUID:(int)characteristicUUID p:(CBPeripheral *)p;
@end