Skip to content

Commit a7f8ae3

Browse files
committed
upadte
1 parent 0558d7c commit a7f8ae3

File tree

416 files changed

+11587
-13598
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

416 files changed

+11587
-13598
lines changed

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
11
.DS_Store
2+
*.xcuserstate
3+
project.xcworkspace
4+
xcuserdata
5+
UserInterfaceState.xcuserstate
6+
project.xcworkspace/
7+
xcuserdata/
8+
UserInterface.xcuserstate

BlufiLibrary/BlufiClient.h

+255
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,255 @@
1+
//
2+
// BlufiClient.h
3+
// EspBlufi
4+
//
5+
// Created by AE on 2020/6/9.
6+
// Copyright © 2020 espressif. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
#import <CoreBluetooth/CoreBluetooth.h>
11+
#import "BlufiConstants.h"
12+
#import "BlufiStatusResponse.h"
13+
#import "BlufiScanResponse.h"
14+
#import "BlufiVersionResponse.h"
15+
#import "BlufiConfigureParams.h"
16+
17+
NS_ASSUME_NONNULL_BEGIN
18+
19+
#define BLUFI_VERSION @"2.1.0"
20+
21+
@protocol BlufiDelegate;
22+
23+
@interface BlufiClient : NSObject
24+
25+
/*!
26+
* @property delegate
27+
*
28+
* @discussion The delegate object that will receive Blufi events.
29+
*/
30+
@property(weak, nonatomic, nullable)id<BlufiDelegate> blufiDelegate;
31+
32+
/*!
33+
* @property delegate
34+
*
35+
* @discussion The delegate object that will receive central events.
36+
*/
37+
@property(weak, nonatomic, nullable)id<CBCentralManagerDelegate> centralManagerDelete;
38+
39+
/*!
40+
* @property peripheralDelegate
41+
*
42+
* @discussion The delegate object that will receive peripheral events.
43+
*/
44+
@property(weak, nonatomic, nullable)id<CBPeripheralDelegate> peripheralDelegate;
45+
46+
/*!
47+
* @property peripheralDelegate
48+
*
49+
* @discussion The maximum length of each Blufi packet, the excess part will be subcontracted.
50+
*/
51+
@property(assign, nonatomic)NSInteger postPackageLengthLimit;
52+
53+
/*!
54+
* @method connect:
55+
*
56+
* @param identifier CBPeripheral's identifier
57+
*
58+
* @discussion Establish a BLE connection with CBPeripheral
59+
*/
60+
- (void)connect:(NSString *)identifier;
61+
62+
/*!
63+
* @method close
64+
*
65+
* @discussion Close the client
66+
*/
67+
- (void)close;
68+
69+
/*!
70+
* @method negotiateSecurity
71+
*
72+
* @discussion Negotiate security with device.
73+
* The result will be notified in <link>blufi:didNegotiateSecurity:</link>
74+
*/
75+
- (void)negotiateSecurity;
76+
77+
/*!
78+
* @method requestCloseConnection
79+
*
80+
* @discussion Request device to disconnect the BLE connection
81+
*/
82+
- (void)requestCloseConnection;
83+
84+
/*!
85+
* @method requestDeviceVersion
86+
*
87+
* @discussion Request to get device version.
88+
* The result will notified in <link>blufi:didReceiveDeviceVersionResponse:status:</link>
89+
*/
90+
- (void)requestDeviceVersion;
91+
92+
/*!
93+
* @method requestDeviceStatus
94+
*
95+
* @discussion Request to get device current status.
96+
* The result will be notified in <link>blufi:didReceiveDeviceStatusResponse:status:</link>
97+
*/
98+
- (void)requestDeviceStatus;
99+
100+
/*!
101+
* @method requestDeviceScan
102+
*
103+
* @discussion Request to get wifi list that the device scanned.
104+
* The wifi list will be notified in <link>blufi:didReceiveDeviceScanResponse:status:</link>
105+
*/
106+
- (void)requestDeviceScan;
107+
108+
/*!
109+
* @method configure:
110+
*
111+
* @discussion Configure the device to a station or soft AP.
112+
* The posted result will be notified in <link>blufi:didPostConfigureParams:</link>
113+
*/
114+
- (void)configure:(BlufiConfigureParams *)params;
115+
116+
/*!
117+
* @method postCustomData:
118+
*
119+
* @discussion Request to post custom data to device.
120+
* The posted result will be notified in <link>blufi:didPostCustomData:status:</link>
121+
*/
122+
- (void)postCustomData:(NSData *)data;
123+
124+
@end
125+
126+
typedef enum {
127+
StatusSuccess = 0,
128+
StatusFailed = 100,
129+
StatusInvalidRequest,
130+
StatusWriteFailed,
131+
StatusInvalidData,
132+
StatusBLEStateDisable,
133+
StatusException,
134+
} BlufiStatusCode;
135+
136+
// Blufi Callback
137+
@protocol BlufiDelegate <NSObject>
138+
139+
@optional
140+
141+
/*!
142+
* @method blufi:gettPrepared:service:writeChar:notifyChar:
143+
*
144+
* @param client BlufiClient
145+
* @param status see <code>BlufiStatusCode</code>
146+
* @param service nil if discover Blufi service failed
147+
* @param writeChar nil if discover Blufi write characteristic failed
148+
* @param notifyChar nil if discover Blufi notify characteristic failed
149+
*
150+
* @discussion Invoked after client set notifyChar notification enable. User can post BluFi packet now.
151+
*/
152+
- (void)blufi:(BlufiClient *)client gattPrepared:(BlufiStatusCode)status service:(nullable CBService *)service writeChar:(nullable CBCharacteristic *)writeChar notifyChar:(nullable CBCharacteristic *)notifyChar;
153+
154+
/*!
155+
* @method blufi:gattNotification:packageType:subType:
156+
*
157+
* @param client BlufiClient
158+
* @param data Blufi data
159+
* @param pkgType Blufi package type
160+
* @param subType Blufi subtype
161+
*
162+
* @return true if the delegate consumed the notification, false otherwise.
163+
*
164+
* @discussion Invoked when receive Gatt notification
165+
*/
166+
- (BOOL)blufi:(BlufiClient *)client gattNotification:(NSData *)data packageType:(PackageType)pkgType subType:(SubType)subType;
167+
168+
/*!
169+
* @method blufi:didReceiveError:
170+
*
171+
* @param client BlufiClient
172+
* @param errCode error code
173+
*
174+
* @discussion Invoked when received error code from device
175+
*/
176+
- (void)blufi:(BlufiClient *)client didReceiveError:(NSInteger)errCode;
177+
178+
/*!
179+
* @method blufi:didNegotiateSecurity:
180+
*
181+
* @param client BlufiClient
182+
* @param status see <code>BlufiStatusCode</code>, StatusSuccess means negotiate security success.
183+
*
184+
* @discussion Invoked when negotiate security over with device
185+
*/
186+
- (void)blufi:(BlufiClient *)client didNegotiateSecurity:(BlufiStatusCode)status;
187+
188+
/*!
189+
* @method blufi:didPostConfigureParams:
190+
*
191+
* @param client BlufiClient
192+
* @param status see <code>BlufiStatusCode</code>, StatusSuccess means post data success.
193+
*
194+
* @discussion Invoked when post config data over
195+
*/
196+
- (void)blufi:(BlufiClient *)client didPostConfigureParams:(BlufiStatusCode)status;
197+
198+
/*!
199+
* @method blufi:didReceiveDeviceVersionResponse:status:
200+
*
201+
* @param client BlufiClient
202+
* @param response <code>BlufiVersionResponse</code>
203+
* @param status see <code>BlufiStatusCode</code>, StatusSuccess means response is valid.
204+
*
205+
* @discussion invoked when received device version
206+
*/
207+
- (void)blufi:(BlufiClient *)client didReceiveDeviceVersionResponse:(nullable BlufiVersionResponse *)response status:(BlufiStatusCode)status;
208+
209+
/*!
210+
* @method blufi:didReceiveDeviceStatusResponse:status:
211+
*
212+
* @param client BlufiClient
213+
* @param response <code>BlufiStatusResponse</code>
214+
* @param status see <code>BlufiStatusCode</code>, StatusSuccess means response is valid.
215+
*
216+
* @discussion Invoked when received device status.
217+
*/
218+
- (void)blufi:(BlufiClient *)client didReceiveDeviceStatusResponse:(nullable BlufiStatusResponse *)response status:(BlufiStatusCode)status;
219+
220+
/*!
221+
* @method blufi:didReceiveDeviceScanResponse:status:
222+
*
223+
* @param client BlufiClient
224+
* @param scanResults scan result array
225+
* @param status see <code>BlufiStatusCode</code>, StatusSuccess means response is valid.
226+
*
227+
* @discussion Invoked when received device scan results
228+
*/
229+
- (void)blufi:(BlufiClient *)client didReceiveDeviceScanResponse:(nullable NSArray<BlufiScanResponse *> *)scanResults status:(BlufiStatusCode)status;
230+
231+
232+
/*!
233+
* @method blufi:didPostCustomData:status:
234+
*
235+
* @param client BlufiClient
236+
* @param data posted
237+
* @param status see <code>BlufiStatusCode</code>, StatusSuccess means post data success
238+
*
239+
* @discussion Invokded when post custom data success
240+
*/
241+
- (void)blufi:(BlufiClient *)client didPostCustomData:(NSData *)data status:(BlufiStatusCode)status;
242+
243+
/*!
244+
* @method blufi:didReceiveCustomData:status:
245+
*
246+
*@param client BlufiClient
247+
*@param data received
248+
*@param status see <code>BlufiStatusCode</code>, StatusSuccess means receive data success
249+
*
250+
*/
251+
- (void)blufi:(BlufiClient *)client didReceiveCustomData:(NSData *)data status:(BlufiStatusCode)status;
252+
253+
@end
254+
255+
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)