-
Notifications
You must be signed in to change notification settings - Fork 1k
Simplify code flow for broadcast requests #2720
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,19 +86,18 @@ def handle_later(self): | |
|
|
||
| async def handle_request(self): | ||
| """Handle request.""" | ||
| broadcast = False | ||
| if not self.last_pdu: | ||
| return | ||
| try: | ||
| if self.server.broadcast_enable and not self.last_pdu.dev_id: | ||
| broadcast = True | ||
| # if broadcasting then execute on all device contexts, | ||
| # note response will be ignored | ||
| for dev_id in self.server.context.device_id(): | ||
| response = await self.last_pdu.update_datastore(self.server.context[dev_id]) | ||
| else: | ||
| context = self.server.context[self.last_pdu.dev_id] | ||
| response = await self.last_pdu.update_datastore(context) | ||
| await self.last_pdu.update_datastore(self.server.context[dev_id]) | ||
| return | ||
|
|
||
| context = self.server.context[self.last_pdu.dev_id] | ||
| response = await self.last_pdu.update_datastore(context) | ||
|
|
||
| except NoSuchIdException: | ||
| Log.error("requested device id does not exist: {}", self.last_pdu.dev_id) | ||
|
|
@@ -112,11 +111,9 @@ async def handle_request(self): | |
| traceback.format_exc(), | ||
| ) | ||
| response = ExceptionResponse(self.last_pdu.function_code, ExceptionResponse.DEVICE_FAILURE) | ||
| # no response when broadcasting | ||
| if not broadcast: | ||
| response.transaction_id = self.last_pdu.transaction_id | ||
| response.dev_id = self.last_pdu.dev_id | ||
| self.server_send(response, self.last_addr) | ||
| response.transaction_id = self.last_pdu.transaction_id | ||
| response.dev_id = self.last_pdu.dev_id | ||
| self.server_send(response, self.last_addr) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmmm seems to me this change will send a response if we are in broadcast mode, that is not allowed.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, there is an early |
||
|
|
||
| def server_send(self, pdu, addr): | ||
| """Send message.""" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
broadcast mode returns here without responses