Skip to content

Commit

Permalink
Add initialisation for non & mt, improve updating existing table entries
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankZRS committed Mar 4, 2024
1 parent d2f8f41 commit 6aa0c45
Showing 1 changed file with 24 additions and 30 deletions.
54 changes: 24 additions & 30 deletions api/oc_knx_fp.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,7 @@ find_empty_slot_in_group_object_table(int id)
/* should be a positive number */
return index;
}
index = oc_core_find_index_in_group_object_table_from_id(id);
if (index > -1) {
/* overwrite existing index */
return index;
}

/* empty slot */
for (int i = 0; i < GOT_MAX_ENTRIES; i++) {
if (g_got[i].id == -1) {
Expand Down Expand Up @@ -562,12 +558,12 @@ oc_core_fp_g_post_handler(oc_request_t *request, oc_interface_mask_t iface_mask,
} else {
// no index, so we will create one
return_status = OC_STATUS_CREATED;
}
index = find_empty_slot_in_group_object_table(id);
if (index == -1) {
OC_ERR(" ERROR index %d", index);
oc_send_response_no_format(request, OC_STATUS_BAD_REQUEST);
return;
index = find_empty_slot_in_group_object_table(id);
if (index == -1) {
OC_ERR(" ERROR index %d", index);
oc_send_response_no_format(request, OC_STATUS_BAD_REQUEST);
return;
}
}

bool id_only = true;
Expand Down Expand Up @@ -974,13 +970,13 @@ oc_core_fp_p_post_handler(oc_request_t *request, oc_interface_mask_t iface_mask,
} else {
// no index, so we will create one
return_status = OC_STATUS_CREATED;
}
index = find_empty_slot_in_rp_table(id, g_gpt,
oc_core_get_publisher_table_size());
if (index == -1) {
PRINT(" ERROR index %d\n", index);
oc_send_response_no_format(request, OC_STATUS_BAD_REQUEST);
return;
index = find_empty_slot_in_rp_table(id, g_gpt,
oc_core_get_publisher_table_size());
if (index == -1) {
PRINT(" ERROR index %d\n", index);
oc_send_response_no_format(request, OC_STATUS_BAD_REQUEST);
return;
}
}
g_gpt[index].id = id;

Expand Down Expand Up @@ -1408,13 +1404,16 @@ oc_core_fp_r_post_handler(oc_request_t *request, oc_interface_mask_t iface_mask,
} else {
// no index, so we will create one
return_status = OC_STATUS_CREATED;
}
index = find_empty_slot_in_rp_table(id, g_grt,
oc_core_get_recipient_table_size());
if (index == -1) {
OC_ERR(" ERROR index %d", index);
oc_send_response_no_format(request, OC_STATUS_BAD_REQUEST);
return;
index = find_empty_slot_in_rp_table(id, g_grt,
oc_core_get_recipient_table_size());
if (index == -1) {
OC_ERR(" ERROR index %d", index);
oc_send_response_no_format(request, OC_STATUS_BAD_REQUEST);
return;
}
// Initialise non & mt for new entry
g_grt[index].non = false;
g_grt[index].mt = 4;
}
g_grt[index].id = id;

Expand Down Expand Up @@ -2318,11 +2317,6 @@ find_empty_slot_in_rp_table(int id, oc_group_rp_table_t *rp_table, int max_size)
// should be a positive number
return index;
}
index = oc_core_find_index_in_rp_table_from_id(id, rp_table, max_size);
if (index > -1) {
// overwrite existing index
return index;
}

// empty slot
for (int i = 0; i < max_size; i++) {
Expand Down

0 comments on commit 6aa0c45

Please sign in to comment.