Skip to content

Commit

Permalink
Correctly set the relay index and handle empty source routes
Browse files Browse the repository at this point in the history
  • Loading branch information
puddly committed Aug 14, 2024
1 parent 6d44880 commit d508f6e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/ncp-uart-hw/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,22 @@ void nc_zigbee_override_append_source_route(EmberNodeId destination,
return;
}

uint8_t relay_index = 0;

*consumed = true;

// Empty source routes are not permitted
if (route->num_relays == 0) {
return;
}

uint8_t relay_index = route->num_relays - 1;

route->active = false; // Disable the route after a single use

emberAppendToLinkedBuffers(*header, &route->num_relays, 1);
emberAppendToLinkedBuffers(*header, &relay_index, 1);

for (uint8_t i = 0; i < route->num_relays; i++) {
emberAppendToLinkedBuffers(*header, (uint8_t*)&route->relays[i], 2);
emberAppendToLinkedBuffers(*header, (uint8_t*)&route->relays[route->num_relays - i - 1], 2);
}

return;
Expand Down

0 comments on commit d508f6e

Please sign in to comment.