Author Topic: Connecting to multiple clients, sometimes getting 0X00030008 and 0X0005105C  (Read 1090 times)

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3520
  • Karma: 1000
    • Wireless Communication Libraries
Hi,

I have updated the code by adding some delay (2 seconds) aftr device disconnected. So it will not connect immediately and gives device 2 seconds to restore its state after disconnection. I think that was a problem with your device.

Offline Leo1986

  • Newbie
  • *
  • Posts: 16
  • Karma: 0
Hi Mike,

sadly, I still get the same error. Our junior dev debugged his firmware and they said that the service tries to connect to the device, then after connected immediately disconnects and then tries to connect again. As if it is stuck inside a loop.

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3520
  • Karma: 1000
    • Wireless Communication Libraries
Hi,

Unfortunately I have no idea how your device works but I tested it here with Lego (2 WeDo Hubs and 2 BOOST hubs), Raspberry pi running bleno and Android cells running BLE Emulator and smart bracellet. Total with 10 devices running at the same time. No one issue.

Offline Leo1986

  • Newbie
  • *
  • Posts: 16
  • Karma: 0
Yes, I can confirm that. Just to check, did you also try connecting and disconnecting then connecting again? I tested it with an android app where I can open a GATT server and the service has no problems connecting and disconnecting, even if I do it over and over rapidly. So, the problem lies either with the BT chip or the firmware.

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3520
  • Karma: 1000
    • Wireless Communication Libraries
Yes, just tested it also. No problem. Try to increase delay between reconnect. I used 2 seconds but may be device needs more.

Offline Leo1986

  • Newbie
  • *
  • Posts: 16
  • Karma: 0
I tried it with a delay of 10 seconds, I also tried using a different bluetooth adapter and screwing around with drivers. All yielded the same results. I sent the service to my colleagues because they also have some of our devices lying around, they also get the same error. We use a Microchip RN4871 and I told our junior dev to post on their forums, maybe he configured the firmware incorrectly. Hopefully, that will yield some results as I have no ideas left on what to do.

Very strange issue.

Offline Leo1986

  • Newbie
  • *
  • Posts: 16
  • Karma: 0
Hi Mike,

Our junior dev made a few changes to their firmware and I also made some changes in the service. Before, when I received a value in OnCharacteristicChanged, I sent the shutdown signal to the device inside that event. I think the service didn't like that. So I refactored a bit and now I unsubscribe the characteristic and send the shutdown signal immediately after subscribing. I also brought home a high-quality bluetooth dongle instead of using the onboard adapter of my 2015-ish laptop.

I don't get 0X00030008 errors anymore, just 0X0005105C and I think this has to do with interference from other devices because the fewer devices I see when scanning in Windows (at night, early morning), the more rare the 0X0005105C errors become. But these errors aren't game-breaking because the next scan cycle picks up the device again and connects to it successfully.

Anyway, now I have another problem. I do not receive any values anymore because obviously I unsub immediately (on line 154 in the file attached file) from the characteristic. Is there any way to wait for the first value to come into OnCharacteristicChanged event before doing this?

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3520
  • Karma: 1000
    • Wireless Communication Libraries
Hi,

That is correct that you do not receive notifications because you unsubscribed.

There should no be any issue with writing inside value changed event handler (we do it in our WeDo framework without any problem: https://github.com/btframework/WeDo)

Also it looks like your device has random MAC or you did not filter device's correctly. That is why you got 0X0005105C  error.

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3520
  • Karma: 1000
    • Wireless Communication Libraries
By the way, I have been thinking about the issue with your device and: Is your device still advertising when you connect to it?

Offline Leo1986

  • Newbie
  • *
  • Posts: 16
  • Karma: 0
Hi Mike,

The workflow of our service and devices looks like this:

  • Service scans
  • User presses button/s on the devices
  • After 5 seconds of no button being pressed, the devices turn on BLE and start advertising
  • Service sees the devices that are advertising and does the following for each of them:
  • Service connects to button
  • Service subscribes to characteristic
  • Service writes client configuration with true to characteristic
  • Service receives first value from device
  • Service writes client configuration with false
  • Service unsubscribes from characteristic
  • Service send shutdown signal to device
  • Device receives signal, stops advertising and turns off bluetooth, thus firing OnDisconnect event in service
  • After all devices have disconnected, service waits 5 seconds and returns to #1

So in other words, the device should not advertise when the service tries to connect to it again. The 5 second delay should ensure that all devices have turned off and stopped advertising.

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3520
  • Karma: 1000
    • Wireless Communication Libraries
For me (I can guess) it looks like device keeps advertising when your service connects to it. As my code stores connected MAC even advertising received again it does not try to connect after first connection attempt. However, once you disconnects from device and device keeps advertising (and probably changes it MAC) the code sees the device is available and tries to connect to it again. However device may be in "disconnecting" state and rejects new connection immediately so you got hte connection error.

Usually BLE device stops advertising right after connection established and starts advertising again only when it "completly" disconnected.

So make sure your device is not advertising when your service connected to it first. Then we can think what to do with it.

Offline Leo1986

  • Newbie
  • *
  • Posts: 16
  • Karma: 0
Hi Mike,

we still haven't managed to solve the problem. We will now try to debug the firmware of our devices to see what is happening when exactly. Independently, I wanted to ask you if your library supports transparent UART?

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3520
  • Karma: 1000
    • Wireless Communication Libraries
Bluetooth Framework supports any GATT service. It does not matter how it is implemented on device's side if it follows BLE GATT service specification.

 

Sitemap 1 2 3 4 5 6 7 8 9 10 11 12 13 14