iphone - how to search BLE device after logout in iOS? -


in case search view 1 controller , logout in viewcontroller ,how can disconnect bluetooth , logout.once logout device not forget , keeping connected device.how can search blue devices in app afterlogout?please me .thanks in advance

    - (void)centralmanagerdidupdatestate:(cbcentralmanager *)central {      nslog(@"%s \n",__pretty_function__);     // determine state of peripheral     if ([central state] == cbcentralmanagerstatepoweredoff) {         nslog(@"corebluetooth ble hardware powered off");       }     else if ([central state] == cbcentralmanagerstatepoweredon) {         nslog(@"corebluetooth ble hardware powered on , ready");         [mgr scanforperipheralswithservices:nil options:@{ cbcentralmanagerscanoptionallowduplicateskey: @yes }];          return;     }     else if ([central state] == cbcentralmanagerstateunauthorized) {         nslog(@"corebluetooth ble state unauthorized");      }     else if ([central state] == cbcentralmanagerstateunknown) {         nslog(@"corebluetooth ble state unknown");       }     else if ([central state] == cbcentralmanagerstateunsupported) {         nslog(@"corebluetooth ble hardware unsupported on platform");      }  }      - (void)centralmanager:(cbcentralmanager *)central diddiscoverperipheral:(cbperipheral *)peripheral advertisementdata:(nsdictionary *)advertisementdata rssi:(nsnumber *)rssi     {          nslog(@"i see advertisement identifer: %@, state: %ld name: %@, services: %@, description: %@",[peripheral identifier],(long)[peripheral state],[peripheral name],[peripheral services],[advertisementdata description]);         // name of device         nsstring *localname = [advertisementdata objectforkey:cbadvertisementdatalocalnamekey];          nslog(@"the name direct periperal --> %@",localname);          if (![localname length] > 0) {             nslog(@"localname null ");          }         else         {         if (peripheral != (id)[nsnull null] && peripheral.name != (id)[nsnull null])         {             nslog(@"-----> clear check point 1 <------");             if (localname==nil )             {                 nslog(@"-----> clear check point 2 <------");                 localname=peripheral.name;                 nslog(@"the name if nil periperal name --> %@",localname);             }               if (peripheral == nil || peripheral.name == (id)[nsnull null])             {                 nslog(@"-----> clear check point 3 <------");             }                   [peripheralsarray addobject:peripheral];                 [peripheralnamesarray addobject:localname];                   nsorderedset *myset = [[nsorderedset alloc] initwitharray:peripheralnamesarray];                 peripheralnamesarray = [[nsmutablearray alloc] initwitharray:[myset array]];                  nsorderedset *myset2 = [[nsorderedset alloc] initwitharray:peripheralsarray];                 peripheralsarray = [[nsmutablearray alloc] initwitharray:[myset2 array]];                 [mgr stopscan];               }         }     } }    - (void)centralmanager:(cbcentralmanager *)central diddisconnectperipheral:(cbperipheral *)peripheral error:(nserror *)error {      nslog(@"%s \n",pretty_function);      appdelegate *appdelegate = (appdelegate *)[[uiapplication sharedapplication]delegate];      appdelegate.isble_connected = false;      [mgr cancelperipheralconnection:activeperipheral];      uialertview *disconnalert = [[uialertview alloc] initwithtitle:@"" message:@"no device paired" delegate:self cancelbuttontitle:@"cancel" otherbuttontitles: nil];      [disconnalert show];  } 


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -