This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF UART app (iOS) - Selecting Device

Hi there,

I'm currently using the nRF UART app for iOS (v1.0.1), and I noticed it doesn't work the same as the Android app (v2). The key difference is the ability to select which BLE device to connect to. On the iPhone, upon hitting 'Connect', the app would just scan and connect to the strongest RSSI device around? I would like to modify the iOS source-code so that which hitting 'Connect', I'm able to select which device to connect to first before establishing a connection. I'm unfamiliar to objective-C, thus any help or leads would be great (I have the source-code for iOS v1.0.1)

Thanks!

  • Hello. The nRF uart app for iOS is old (2013). I recommend that you use either the nrf toolbox, or the nRF master control panel. You can find the source for nrf toolbox here.

    If you still want to modify the old uart app (I do not recommend this):

    In the file ViewController.m, we find the function - (IBAction)connectButtonPressed:(id)sender at line 55. Inside it, we find a switch case:

    switch (self.state) {
            case IDLE:
                self.state = SCANNING;
                
                NSLog(@"Started scan ...");
                [self.connectButton setTitle:@"Scanning ..." forState:UIControlStateNormal];
                
                [self.cm scanForPeripheralsWithServices:@[UARTPeripheral.uartServiceUUID] options:@{CBCentralManagerScanOptionAllowDuplicatesKey: [NSNumber numberWithBool:NO]}];
                break;
    

    This tells iOS to scan for just one UUID. If you want to scan for all UUID, leave the UUID array empty. See the iOS documentation.

    The callback function on line 167

    (void) centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
    

    Is called when a suitable device has been found. If you want to create a list over device, this is where you must do it.

    -Anders

  • Anders,

    Thanks for the info. I'm trying to design an iOS app that has the functionality of UART-BLE data transmission (connect, select from list, send uart string, disconnect). From the nRF toolbox app, what are the minimum code/modules that I would require (minus the UI) for this functionality?

    Best, Lee-Hong

  • I do not really know iOS code myself, but i can see if I can find someone who does. You can also try iOS code forums or stack overflow for help on this. You should be able to use any BLE template or example project instead of the nrf toolbox project. In either case, i guess it requires you to learn how to program apps for iOS.

Related