@@ -98,16 +98,7 @@ - (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
+ [delegate shouldDisplayAlertTitled: @" Bluetooth LE Support" messageBody: message];
111
102
112
103
return NO ;
113
104
}
@@ -193,16 +184,7 @@ - (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPe
193
184
if (error.code ) {
194
185
cancelBlock = block;
195
186
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
187
+ [delegate shouldDisplayAlertTitled: @" Peripheral Disconnected with Error" messageBody: error.description];
206
188
207
189
}
208
190
else
@@ -229,9 +211,9 @@ - (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeri
229
211
// NSLog(@"didDiscoverPeripheral");
230
212
231
213
NSString *uuid = NULL ;
232
- if (peripheral.UUID ) {
214
+ if ([ peripheral.identifier.UUIDString length ] > 0 ) {
233
215
// only returned if you have connected to the device before
234
- uuid = (__bridge_transfer NSString *) CFUUIDCreateString ( NULL , peripheral.UUID ) ;
216
+ uuid = peripheral.identifier . UUIDString ;
235
217
} else {
236
218
uuid = @" " ;
237
219
}
@@ -259,7 +241,7 @@ - (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeri
259
241
id manufacturerData = [advertisementData objectForKey: CBAdvertisementDataManufacturerDataKey];
260
242
if (manufacturerData) {
261
243
const uint8_t *bytes = [manufacturerData bytes ];
262
- int len = [manufacturerData length ];
244
+ NSUInteger len = [manufacturerData length ];
263
245
// skip manufacturer uuid
264
246
NSData *data = [NSData dataWithBytes: bytes+2 length: len-2 ];
265
247
rfduino.advertisementData = data;
@@ -283,17 +265,7 @@ - (void)centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(C
283
265
{
284
266
NSLog (@" didFailToConnectPeripheral" );
285
267
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
-
268
+ [delegate shouldDisplayAlertTitled: @" Connect Failed" messageBody: error.description];
297
269
}
298
270
299
271
- (void )centralManager : (CBCentralManager *)central didRetrieveConnectedPeripherals : (NSArray *)peripherals
@@ -302,27 +274,14 @@ - (void)centralManager:(CBCentralManager *)central didRetrieveConnectedPeriphera
302
274
303
275
- (void )centralManagerDidUpdateState : (CBCentralManager *)aCentral
304
276
{
305
- NSLog (@" central manager state = %d " , [central state ]);
277
+ NSLog (@" central manager state = %ld " , [central state ]);
306
278
307
279
bool success = [self isBluetoothLESupported ];
308
280
if (success) {
309
281
[self startScan ];
310
282
}
311
283
}
312
284
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
285
#pragma mark - Rfduino methods
327
286
328
287
- (bool )isScanning
0 commit comments