-
Notifications
You must be signed in to change notification settings - Fork 276
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
Software caused connection to abort error #802
Comments
Can you share code for a minimal reproducible example? |
I cannot directly post the code due to the company policy, but I can provide you with the skeleton code of how things are structured at the moment. I apologize for not being able to provide the full code. Basically, my code uses BLE to connect to a bluetooth door, then sends commands to either open/close/query the door. The code errors at the My class BLEDoorTool:
...
async def open(self):
await self.client.connect()
await self.client.start_notify(self.char_uuid, self.on_message)
await self.authenticate()
await asyncio.sleep(0.5)
await self.sendOpen()
await asyncio.sleep(12.0) # estimated time to open the door
await self.sendQuery()
await self.client.stop_notify(self.char_uuid)
await self.client.disconnect()
async def close(self):
await self.client.connect()
await self.client.start_notify(self.char_uuid, self.on_message)
await self.authenticate()
await self.sendClose()
await asyncio.sleep(12.0) # estimated time to close the door
await self.sendQuery()
await self.client.stop_notify(self.char_uuid)
await self.client.disconnect()
async def check_door_status(self):
await self.client.connect()
await self.client.start_notify(self.char_uuid, self.on_message)
await self.authenticate()
await self.sendQuery()
await self.client.stop_notify(self.char_uuid)
await self.client.disconnect()
def teardown(self):
global messageConcatBuffer
global messageCountToExpect
global api_session_key
global lastActionId
global waitingForAuthenticationQueryActionResponse
messageConcatBuffer = ''
messageCountToExpect = 1
api_session_key = None
lastActionId = 0
waitingForAuthenticationQueryActionResponse = False
def open_bluetooth_door(self, session_id, exit_ret_val, inputs):
global door_state
# Step 1: Check waypoint and obtain the associated target bluetooth MAC address
self.get_robot_id()
self.check_waypoint_id_and_obtain_MAC_addr()
# Step 2: Create BLE Client using the MAC address obtained in step 1
self.client = BleakClient(self.target_address)
# Step 3: Open door
run = asyncio.run(self.check_door_status())
self.teardown()
if door_state == 'open':
_LOGGER.info("Mission successful. Door is already open.")
exit_ret_val[session_id] = remote_pb2.TickResponse.STATUS_SUCCESS
else:
while door_state == 'closed':
_LOGGER.info("Door is currently closed. Sending request to open the door.")
run = asyncio.run(self.open())
self.teardown()
exit_ret_val[session_id] = remote_pb2.TickResponse.STATUS_SUCCESS
return exit_ret_val[session_id]
def close_bluetooth_door(self, session_id, exit_ret_val, inputs):
global door_state
# Step 1: Check waypoint and obtain the associated target bluetooth MAC address
self.get_robot_id()
self.check_waypoint_id_and_obtain_MAC_addr()
# Step 2: Create BLE Client using the MAC address obtained in step 1
self.client = BleakClient(self.target_address)
# Step 3: Close door
run = asyncio.run(self.check_door_status())
self.teardown()
if door_state == 'closed':
_LOGGER.info("Mission successful. Door is already closed.")
exit_ret_val[session_id] = remote_pb2.TickResponse.STATUS_SUCCESS
else:
while door_state == 'open':
_LOGGER.info("Door is currently open. Sending request to close the door.")
run = asyncio.run(self.close())
self.teardown()
exit_ret_val[session_id] = remote_pb2.TickResponse.STATUS_SUCCESS
return exit_ret_val[session_id]
... In the same
In the separate
Currrently, my workaround has been attempting the |
I don't know if it will fix the problem, but there are know issues with reusing the same async def open(self):
async with BleakClient(self.device) as client:
await client.start_notify(self.char_uuid, self.on_message)
await self.authenticate(client)
await asyncio.sleep(0.5)
await self.sendOpen(client)
await asyncio.sleep(12.0) # estimated time to open the door
await self.sendQuery(client) |
Thank you for your response. I will try this today and let you know. |
It turns out that although the Do you have any other recommendations on how to get around this issue? |
bluetoothctl -v
) in case of Linux: 5.48Description
I am running the BLE client within the python thread that utilizes behavior tree for robotics application. What's interesting is that it will run about 10% of the time (upon keep trying), but most of times, it gives me
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Software caused connection abort
error. Can someone explain how to address this issue and why this issue gets resolved upon just trying again?P.S. It seems that getting rid of the thread is not a viable solution as already shown from: #666.
The text was updated successfully, but these errors were encountered: