forked from Rightpoint/RZBluetooth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RZBMockPeripheralManager.h
78 lines (57 loc) · 3.54 KB
/
RZBMockPeripheralManager.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
77
78
//
// RZBSimulatedDevice.h
// UMTSDK
//
// Created by Brian King on 7/30/15.
// Copyright (c) 2015 Raizlabs. All rights reserved.
//
@import CoreBluetooth;
@protocol RZBMockPeripheralManagerDelegate;
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 100000 || __TV_OS_VERSION_MAX_ALLOWED >= 100000
#define RZBPeripheralManagerState CBManagerState
#define RZBPeripheralManagerStatePoweredOn CBManagerStatePoweredOn
#else
#define RZBPeripheralManagerState CBPeripheralManagerState
#define RZBPeripheralManagerStatePoweredOn CBPeripheralManagerStatePoweredOn
#endif
NS_ASSUME_NONNULL_BEGIN
/**
* Mock API for CBPeripheralManager. This is not a direct subclass of CBPeripheralManager
* because not all of the things can be controlled (like peripheralManagerDidUpdateState: signaling)
*/
@interface RZBMockPeripheralManager : NSObject
- (instancetype)initWithDelegate:(id<CBPeripheralManagerDelegate>)delegate queue:(dispatch_queue_t)queue;
- (instancetype)initWithDelegate:(id<CBPeripheralManagerDelegate>)delegate queue:(dispatch_queue_t)queue options:(NSDictionary *)options;
@property (weak, nonatomic, readonly) id<CBPeripheralManagerDelegate>delegate;
@property () RZBPeripheralManagerState state;
@property (readonly) BOOL isAdvertising;
- (void)startAdvertising:(NSDictionary *)advertisementData;
- (void)stopAdvertising;
- (void)setDesiredConnectionLatency:(CBPeripheralManagerConnectionLatency)latency forCentral:(CBCentral *)central;
- (void)addService:(CBMutableService *)service;
- (void)removeService:(CBMutableService *)service;
- (void)removeAllServices;
@property (weak, nonatomic) id<RZBMockPeripheralManagerDelegate> mockDelegate;
@property (copy, nonatomic) NSDictionary *advInfo;
@property (strong, nonatomic, readonly) NSMutableArray *services;
@property (copy, nonatomic, readonly) NSDictionary *options;
@property (copy, nonatomic, readonly) dispatch_queue_t queue;
@property(assign) NSUInteger fakeActionCount;
- (void)respondToRequest:(CBATTRequest *)request withResult:(CBATTError)result;
- (BOOL)updateValue:(NSData *)value forCharacteristic:(CBMutableCharacteristic *)characteristic onSubscribedCentrals:(NSArray *)centrals;
- (void)fakeStateChange:(RZBPeripheralManagerState)state;
- (void)fakeReadRequest:(CBATTRequest *)request;
- (void)fakeWriteRequest:(CBATTRequest *)request;
- (void)fakeNotifyState:(BOOL)enabled central:(CBCentral *)central characteristic:(CBMutableCharacteristic *)characteristic;
@end
@protocol RZBMockPeripheralManagerDelegate <NSObject>
- (void)mockPeripheralManager:(RZBMockPeripheralManager *)peripheralManager startAdvertising:(NSDictionary *)advertisementData;
- (void)mockPeripheralManagerStopAdvertising:(RZBMockPeripheralManager *)peripheralManager;
- (void)mockPeripheralManager:(RZBMockPeripheralManager *)peripheralManager setDesiredConnectionLatency:(CBPeripheralManagerConnectionLatency)latency forCentral:(CBCentral *)central;
- (void)mockPeripheralManager:(RZBMockPeripheralManager *)peripheralManager addService:(CBMutableService *)service;
- (void)mockPeripheralManager:(RZBMockPeripheralManager *)peripheralManager removeService:(CBMutableService *)service;
- (void)mockPeripheralManagerRemoveAllServices:(RZBMockPeripheralManager *)peripheralManager;
- (void)mockPeripheralManager:(RZBMockPeripheralManager *)peripheralManager respondToRequest:(CBATTRequest *)request withResult:(CBATTError)result;
- (BOOL)mockPeripheralManager:(RZBMockPeripheralManager *)peripheralManager updateValue:(NSData *)value forCharacteristic:(CBMutableCharacteristic *)characteristic onSubscribedCentrals:(NSArray *)centrals;
@end
NS_ASSUME_NONNULL_END