@@ -98,16 +98,9 @@ - (bool)isBluetoothLESupported
98
98
99
99
}
100
100
101
- #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
102
-
103
- UIAlertView *alert = [[UIAlertView alloc ] initWithTitle: @" Bluetooth LE Support"
104
- message: message
105
- delegate: nil
106
- cancelButtonTitle: @" OK"
107
- otherButtonTitles: nil ];
108
- [alert show ];
109
-
110
- #endif
101
+ if ([delegate respondsToSelector: @selector (shouldDisplayAlertTitled:messageBody: )]) {
102
+ [delegate shouldDisplayAlertTitled: @" Bluetooth LE Support" messageBody: message];
103
+ }
111
104
112
105
return NO ;
113
106
}
@@ -193,16 +186,9 @@ - (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPe
193
186
if (error.code ) {
194
187
cancelBlock = block;
195
188
196
- #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
197
-
198
- UIAlertView *alert = [[UIAlertView alloc ] initWithTitle: @" Peripheral Disconnected with Error"
199
- message: error.description
200
- delegate: self
201
- cancelButtonTitle: @" OK"
202
- otherButtonTitles: nil ];
203
- [alert show ];
204
-
205
- #endif
189
+ if ([delegate respondsToSelector: @selector (shouldDisplayAlertTitled:messageBody: )]) {
190
+ [delegate shouldDisplayAlertTitled: @" Peripheral Disconnected with Error" messageBody: error.description];
191
+ }
206
192
207
193
}
208
194
else
@@ -229,9 +215,9 @@ - (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeri
229
215
// NSLog(@"didDiscoverPeripheral");
230
216
231
217
NSString *uuid = NULL ;
232
- if (peripheral.UUID ) {
218
+ if ([ peripheral.identifier.UUIDString length ] > 0 ) {
233
219
// only returned if you have connected to the device before
234
- uuid = (__bridge_transfer NSString *) CFUUIDCreateString ( NULL , peripheral.UUID ) ;
220
+ uuid = peripheral.identifier . UUIDString ;
235
221
} else {
236
222
uuid = @" " ;
237
223
}
@@ -259,7 +245,7 @@ - (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeri
259
245
id manufacturerData = [advertisementData objectForKey: CBAdvertisementDataManufacturerDataKey];
260
246
if (manufacturerData) {
261
247
const uint8_t *bytes = [manufacturerData bytes ];
262
- int len = [manufacturerData length ];
248
+ NSUInteger len = [manufacturerData length ];
263
249
// skip manufacturer uuid
264
250
NSData *data = [NSData dataWithBytes: bytes+2 length: len-2 ];
265
251
rfduino.advertisementData = data;
@@ -283,17 +269,9 @@ - (void)centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(C
283
269
{
284
270
NSLog (@" didFailToConnectPeripheral" );
285
271
286
- #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
287
-
288
- UIAlertView *alert = [[UIAlertView alloc ] initWithTitle: @" Connect Failed"
289
- message: error.description
290
- delegate: nil
291
- cancelButtonTitle: @" OK"
292
- otherButtonTitles: nil ];
293
- [alert show ];
294
-
295
- #endif
296
-
272
+ if ([delegate respondsToSelector: @selector (shouldDisplayAlertTitled:messageBody: )]) {
273
+ [delegate shouldDisplayAlertTitled: @" Connect Failed" messageBody: error.description];
274
+ }
297
275
}
298
276
299
277
- (void )centralManager : (CBCentralManager *)central didRetrieveConnectedPeripherals : (NSArray *)peripherals
@@ -302,27 +280,14 @@ - (void)centralManager:(CBCentralManager *)central didRetrieveConnectedPeriphera
302
280
303
281
- (void )centralManagerDidUpdateState : (CBCentralManager *)aCentral
304
282
{
305
- NSLog (@" central manager state = %d " , [central state ]);
283
+ NSLog (@" central manager state = %ld " , [central state ]);
306
284
307
285
bool success = [self isBluetoothLESupported ];
308
286
if (success) {
309
287
[self startScan ];
310
288
}
311
289
}
312
290
313
- #pragma mark - UIAlertViewDelegate methods
314
-
315
- #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
316
-
317
- - (void )alertView : (UIAlertView *)alertView didDismissWithButtonIndex : (NSInteger ) buttonIndex
318
- {
319
- if (buttonIndex == 0 ) {
320
- cancelBlock ();
321
- }
322
- }
323
-
324
- #endif
325
-
326
291
#pragma mark - Rfduino methods
327
292
328
293
- (bool )isScanning
0 commit comments