bluetooth lowenergy - ios scanning different device by counting bits -
i working on ble scanning modules scanning devices if bit 0x00 shown 10 times or more. when more 1 identical device scanned, console shows alternate 0x00 , 0x01 in nslog . since use 1 integer counter count presence of 0x00 bits, override-ed . please tell me way implement key/value data structure save uuid , count storing scannedperipheral ?
the below working
for(nsuinteger = 0 ; < [ _ble.scannedperipheral count ] ; ++){ deviceperiperal *device; nsstring *uuid = [_ble.scannedperipheralkey objectatindex:i]; if (uuid) { device = [_ble.scannedperipheral objectforkey:uuid]; if([self isemptyarrayornil:[_dbman getdevicerecord:device.uuid ] ]){ nslog(@"pair bit %@ ," , device.pairbit ); const unsigned char ssss[1] = {0x00}; nsdata* pairbi = [nsdata datawithbytes:(const void *)ssss length:(sizeof(unsigned char) * 1)]; const unsigned char sslow[1] = {0x01}; nsdata* pairx = [nsdata datawithbytes:(const void *)sslow length:(sizeof(unsigned char) * 1)]; if ([device.pairbit isequaltodata:pairbi ]){ pcount++; if(pcount > 9){ nslog(@"pair bit paired " ); nslog (@"device = %@", device.uuid); } }else if([device.pairbit isequaltodata:pairx ]){ nslog(@"pair bit not matched " ); pcount=0; } }else{ // others nslog(@"pair bit paired before" ); nslog (@"device = %@", device.uuid); } }
Comments
Post a Comment