Skip to content
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

erase functions for iot router: #757

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion api/oc_knx_dev.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
// Copyright (c) 2021-2023 Cascoda Ltd
// Copyright (c) 2021-2024 Cascoda Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -22,6 +22,9 @@
#include "api/oc_knx_helpers.h"
#include "api/oc_main.h"
#include "port/dns-sd.h"
#ifdef OC_IOT_ROUTER
#include "api/oc_knx_gm.h"
#endif

#include "oc_core_res.h"
#include "oc_discovery.h"
Expand Down Expand Up @@ -1451,6 +1454,9 @@ oc_knx_device_storage_reset(size_t device_index, int reset_mode)
oc_delete_group_rp_table();
oc_delete_group_mapping_table();
oc_delete_at_table(device_index);
#ifdef OC_IOT_ROUTER
oc_delete_group_mapping_table();
#endif
oc_knx_device_set_programming_mode(device_index, false);

} else if (reset_mode == 3) {
Expand Down Expand Up @@ -1479,6 +1485,9 @@ oc_knx_device_storage_reset(size_t device_index, int reset_mode)
oc_delete_group_rp_table();
oc_delete_group_mapping_table();
oc_reset_at_table(device_index, reset_mode);
#ifdef OC_IOT_ROUTER
oc_delete_group_mapping_table();
#endif

oc_knx_device_set_programming_mode(device_index, false);
// load state: unloaded
Expand Down
40 changes: 39 additions & 1 deletion api/oc_knx_gm.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
// Copyright (c) 2021-2023 Cascoda Ltd
// Copyright (c) 2021-2024 Cascoda Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -831,6 +831,12 @@ load_fra(void)
// }
}

void
erase_fra(void)
{
oc_storage_erase(GM_STORE_FRA);
}

static void
oc_core_f_netip_fra_get_handler(oc_request_t *request,
oc_interface_mask_t iface_mask, void *data)
Expand Down Expand Up @@ -952,6 +958,12 @@ load_tol(void)
//}
}

void
erase_tol(void)
{
oc_storage_erase(GM_STORE_TOL);
}

static void
oc_core_f_netip_tol_get_handler(oc_request_t *request,
oc_interface_mask_t iface_mask, void *data)
Expand Down Expand Up @@ -1078,6 +1090,12 @@ load_key(void)
}
}

void
erase_key(void)
{
oc_storage_erase(GM_STORE_KEY);
}

static void
oc_core_f_netip_key_put_handler(oc_request_t *request,
oc_interface_mask_t iface_mask, void *data)
Expand Down Expand Up @@ -1169,6 +1187,12 @@ load_ttl(void)
//}
}

void
erase_ttl(void)
{
oc_storage_erase(GM_STORE_TTL);
}

static void
oc_core_f_netip_ttl_get_handler(oc_request_t *request,
oc_interface_mask_t iface_mask, void *data)
Expand Down Expand Up @@ -1287,6 +1311,12 @@ load_mcast(void)
oc_storage_read(GM_STORE_MCAST, (uint8_t *)&g_mcast, sizeof(g_mcast));
}

void
erase_mcast(void)
{
oc_storage_erase(GM_STORE_MCAST);
}

static void
oc_core_f_netip_mcast_get_handler(oc_request_t *request,
oc_interface_mask_t iface_mask, void *data)
Expand Down Expand Up @@ -1546,6 +1576,14 @@ oc_delete_group_mapping_table()
oc_delete_group_mapping_table_entry(i);
oc_print_group_mapping_table_entry(i);
}
// delete all data of netip

erase_ttl();
erase_tol();
erase_fra();
erase_mcast();
erase_key();

#endif /* OC_IOT_ROUTER */
}

Expand Down