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.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
ws_stats.c
00001 /* 00002 * Copyright (c) 2018-2019, 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 "ns_types.h" 00019 #include "ns_trace.h" 00020 #include "NWK_INTERFACE/Include/protocol.h" 00021 #include "6LoWPAN/ws/ws_stats.h" 00022 #include "6LoWPAN/ws/ws_common.h" 00023 #include "ws_management_api.h" 00024 00025 #define TRACE_GROUP "wsst" 00026 00027 #ifdef HAVE_WS 00028 00029 int ws_statistics_start(int8_t interface_id, ws_statistics_t *stats_ptr) 00030 { 00031 if (!stats_ptr) { 00032 return -1; 00033 } 00034 protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(interface_id); 00035 if (!cur || !ws_info(cur)) { 00036 return -1; 00037 } 00038 cur->ws_info->stored_stats_ptr = stats_ptr; 00039 return 0; 00040 } 00041 00042 int ws_statistics_stop(int8_t interface_id) 00043 { 00044 protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(interface_id); 00045 if (!cur || !ws_info(cur)) { 00046 return -1; 00047 } 00048 cur->ws_info->stored_stats_ptr = NULL; 00049 return 0; 00050 } 00051 00052 void ws_stats_update(protocol_interface_info_entry_t *cur, ws_stats_type_t type, uint32_t update_val) 00053 { 00054 if (!cur || !ws_info(cur)) { 00055 return; 00056 } 00057 ws_statistics_t *stored_stats = cur->ws_info->stored_stats_ptr; 00058 00059 if (stored_stats) { 00060 switch (type) { 00061 case STATS_WS_ASYNCH_TX: 00062 stored_stats->asynch_tx_count += update_val; 00063 break; 00064 case STATS_WS_ASYNCH_RX: 00065 stored_stats->asynch_rx_count += update_val; 00066 break; 00067 } 00068 } 00069 } 00070 #endif // HAVE_WS
Generated on Tue Jul 12 2022 13:55:04 by
1.7.2