Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

大神,我设置autoConnectAfterDisconnect这个值没有效果 #3

Open
ganjmeng opened this issue Oct 19, 2017 · 5 comments
Open

Comments

@ganjmeng
Copy link

ganjmeng commented Oct 19, 2017

image

autoConnectAfterDisconnect 我设置断线重连为NO,回调的错误码是bluetoothErrorStateDisconnect重新开启设备还是能自动重连,设置YES回调的是bluetoothErrorStateDisconnectTring,
我看源代码逻辑有没看出问题
image

重开设备有时一直回调这个方法,已经连接成功隔几秒又走一次又提示连接成功,无限循环了,根本停不下来
#pragma mark - connect peripheral

  • (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral
    {
    EasyLog_R(@"蓝牙连接上一个设备:%@ , %@",peripheral,peripheral.identifier);

    EasyPeripheral *existedP = nil ;
    for (NSString *tempIden in [self.connectedDeviceDict allKeys]) {
    if ([tempIden isEqualToString:peripheral.identifier.UUIDString]) {
    existedP = self.connectedDeviceDict[tempIden] ;
    break ;
    }
    }

    if (!existedP) {
    for (NSString *tempIden in [self.foundDeviceDict allKeys]) {
    if ([tempIden isEqualToString:peripheral.identifier.UUIDString]) {
    existedP = self.foundDeviceDict[tempIden] ;
    break ;
    }
    }

      if (existedP) {
          [self.connectedDeviceDict setObject:existedP forKey:peripheral.identifier.UUIDString];
      }
      else{
          existedP = [[EasyPeripheral alloc]initWithPeripheral:peripheral central:self];
          [self.connectedDeviceDict setObject:existedP forKey:peripheral.identifier.UUIDString];
          if (_blueToothSearchDeviceCallback) {
              _blueToothSearchDeviceCallback(existedP,searchFlagTypeAdded);
          }
          [self.foundDeviceDict setObject:existedP forKey:peripheral.identifier.UUIDString];
      }
    

    }
    [existedP dealDeviceConnectWithError:nil];

}

图片上传一直失败

有空能看看吗

@ganjmeng
Copy link
Author

谢谢!

@chenliangloveyou
Copy link
Owner

好的。我明天去公司了看看,家里没有设备。你加我qq(455158249)好沟通点。

@ganjmeng
Copy link
Author

好的,多谢

@ganjmeng
Copy link
Author

这个是无限连接的视频
在这里打断点就会重现
image

我录了两个屏您先看看
自动连接设置为NO还是能自动重连.zip

无限连接视频.zip

@ganjmeng
Copy link
Author

大神太给力了,以上问题全部解决,可以放心使用

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants