Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
fhss_configuration_interface.c
00001 /* 00002 * Copyright (c) 2016-2018, Arm Limited and affiliates. 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 #include "nsconfig.h" 00018 #include <string.h> 00019 #include "ns_types.h" 00020 #include "fhss_api.h " 00021 #include "fhss_config.h " 00022 #include "net_fhss.h" 00023 #include "nsdynmemLIB.h" 00024 #include "Service_Libs/fhss/fhss.h" 00025 #include "Service_Libs/fhss/fhss_common.h" 00026 #include "Service_Libs/fhss/fhss_ws.h" 00027 #include "ns_trace.h" 00028 00029 #define TRACE_GROUP "fhss" 00030 00031 fhss_api_t *ns_fhss_create(const fhss_configuration_t *fhss_configuration, const fhss_timer_t *fhss_timer, fhss_statistics_t *fhss_statistics) 00032 { 00033 fhss_api_t *this = ns_dyn_mem_alloc(sizeof(fhss_api_t)); 00034 if (!this) { 00035 return NULL; 00036 } 00037 // Create FHSS object 00038 fhss_structure_t *fhss_struct = fhss_enable(this, fhss_configuration, fhss_timer, fhss_statistics); 00039 if (!fhss_struct) { 00040 tr_err("Failed to enable FHSS"); 00041 ns_dyn_mem_free(this); 00042 return NULL; 00043 } 00044 fhss_set_callbacks(fhss_struct); 00045 return this; 00046 } 00047 00048 fhss_api_t *ns_fhss_ws_create(const fhss_ws_configuration_t *fhss_configuration, const fhss_timer_t *fhss_timer) 00049 { 00050 fhss_api_t *this = ns_dyn_mem_alloc(sizeof(fhss_api_t)); 00051 if (!this) { 00052 return NULL; 00053 } 00054 // Create FHSS object 00055 fhss_structure_t *fhss_struct = fhss_ws_enable(this, fhss_configuration, fhss_timer); 00056 if (!fhss_struct) { 00057 tr_err("Failed to enable FHSS"); 00058 ns_dyn_mem_free(this); 00059 return NULL; 00060 } 00061 fhss_ws_set_callbacks(fhss_struct); 00062 return this; 00063 } 00064 00065 int ns_fhss_ws_set_parent(const fhss_api_t *fhss_api, const uint8_t eui64[8], const broadcast_timing_info_t *bc_timing_info) 00066 { 00067 fhss_structure_t *fhss_structure = fhss_get_object_with_api(fhss_api); 00068 if (!fhss_structure || !eui64 || !bc_timing_info) { 00069 return -1; 00070 } 00071 return fhss_ws_set_parent(fhss_structure, eui64, bc_timing_info); 00072 } 00073 00074 int ns_fhss_ws_remove_parent(const fhss_api_t *fhss_api, const uint8_t eui64[8]) 00075 { 00076 fhss_structure_t *fhss_structure = fhss_get_object_with_api(fhss_api); 00077 if (!fhss_structure || !eui64) { 00078 return -1; 00079 } 00080 return fhss_ws_remove_parent(fhss_structure, eui64); 00081 } 00082 00083 int ns_fhss_delete(fhss_api_t *fhss_api) 00084 { 00085 fhss_structure_t *fhss_structure = fhss_get_object_with_api(fhss_api); 00086 if (!fhss_structure) { 00087 return -1; 00088 } 00089 if (fhss_disable(fhss_structure)) { 00090 return -1; 00091 } 00092 ns_dyn_mem_free(fhss_api); 00093 return 0; 00094 } 00095 00096 int ns_fhss_configuration_set(fhss_api_t *fhss_api, const fhss_synch_configuration_t *fhss_synch_configuration) 00097 { 00098 fhss_structure_t *fhss_structure = fhss_get_object_with_api(fhss_api); 00099 if (!fhss_structure) { 00100 return -1; 00101 } 00102 return fhss_set_synch_configuration(fhss_structure, fhss_synch_configuration); 00103 } 00104 00105 int ns_fhss_set_neighbor_info_fp(const fhss_api_t *fhss_api, fhss_get_neighbor_info *get_neighbor_info) 00106 { 00107 fhss_structure_t *fhss_structure = fhss_get_object_with_api(fhss_api); 00108 if (!fhss_structure || !fhss_structure->ws) { 00109 return -1; 00110 } 00111 fhss_structure->ws->get_neighbor_info = get_neighbor_info; 00112 return 0; 00113 } 00114 00115 const fhss_ws_configuration_t *ns_fhss_ws_configuration_get(const fhss_api_t *fhss_api) 00116 { 00117 fhss_structure_t *fhss_structure = fhss_get_object_with_api(fhss_api); 00118 if (!fhss_structure || !fhss_structure->ws) { 00119 return NULL; 00120 } 00121 return &fhss_structure->ws->fhss_configuration; 00122 } 00123 00124 int ns_fhss_ws_configuration_set(const fhss_api_t *fhss_api, const fhss_ws_configuration_t *fhss_configuration) 00125 { 00126 fhss_structure_t *fhss_structure = fhss_get_object_with_api(fhss_api); 00127 if (!fhss_structure || !fhss_structure->ws) { 00128 return -1; 00129 } 00130 return fhss_ws_configuration_set(fhss_structure, fhss_configuration); 00131 } 00132 00133 int ns_fhss_ws_set_hop_count(const fhss_api_t *fhss_api, const uint8_t hop_count) 00134 { 00135 fhss_structure_t *fhss_structure = fhss_get_object_with_api(fhss_api); 00136 if (!fhss_structure || !fhss_structure->ws) { 00137 return -1; 00138 } 00139 return fhss_ws_set_hop_count(fhss_structure, hop_count); 00140 }
Generated on Tue Jul 12 2022 20:52:42 by
