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: cobaLCDJoyMotor_Thread odometry_omni_3roda_v3 odometry_omni_3roda_v1 odometry_omni_3roda_v2 ... more
thread_nvm_store.h
00001 /* 00002 * Copyright (c) 2017, Arm Limited and affiliates. 00003 * SPDX-License-Identifier: BSD-3-Clause 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions are met: 00007 * 00008 * 1. Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * 2. Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * 3. Neither the name of the copyright holder nor the 00014 * names of its contributors may be used to endorse or promote products 00015 * derived from this software without specific prior written permission. 00016 * 00017 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00018 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00019 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00020 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 00021 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00022 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00023 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00024 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00025 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00026 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00027 * POSSIBILITY OF SUCH DAMAGE. 00028 */ 00029 #ifndef THREAD_NVM_STORE_H_ 00030 #define THREAD_NVM_STORE_H_ 00031 00032 #include <stdio.h> 00033 #include <errno.h> 00034 #include <stdint.h> 00035 00036 /* 00037 * \file thread_nvm_store.h 00038 * \brief This API is for storing Thread related values to NVM file system. 00039 * The Posix API is used for file storing/reading (file fopen, fread, fwrite). 00040 * The get functions should only be used when the device is booted up, because read functions 00041 * are slow and can cause packet dropping. 00042 * The storing functions do some filtering (see below) in order to avoid excess writing to NVM. 00043 */ 00044 00045 00046 #ifdef __cplusplus 00047 extern "C" { 00048 #endif 00049 00050 #define THREAD_NVM_FILE_SUCCESS 0 00051 #define THREAD_NVM_FILE_READ_ERROR -1 00052 #define THREAD_NVM_FILE_WRITE_ERROR -2 00053 #define THREAD_NVM_FILE_VERSION_WRONG -3 00054 #define THREAD_NVM_FILE_CANNOT_OPEN -4 00055 #define THREAD_NVM_FILE_ROOT_PATH_INVALID -5 00056 00057 typedef struct { 00058 uint32_t version; 00059 uint32_t mle_frame_counter; 00060 uint32_t mac_frame_counter; 00061 uint32_t seq_counter; 00062 } thread_nvm_fast_data_t; 00063 00064 /* Creates nvm files if they don't exist. Checks file versions */ 00065 int thread_nvm_store_init(void); 00066 /* reads all fast data from nvm */ 00067 int thread_nvm_store_fast_data_read(thread_nvm_fast_data_t* fast_data); 00068 /* stores all fast data to nvm */ 00069 int thread_nvm_store_fast_data_store(thread_nvm_fast_data_t* fast_data); 00070 /* stores new frame counters to nvm only if the any frame counter threshold is passed*/ 00071 int thread_nvm_store_frame_counters_check_and_store(uint32_t mac_frame_counter, uint32_t mle_frame_counter); 00072 /* stores the frame counter and seq counter to nvm only if any threshold is passed*/ 00073 int thread_nvm_store_fast_data_check_and_store(uint32_t mac_frame_counter, uint32_t mle_frame_counter, uint32_t network_seq_counter); 00074 /* stores the value to nvm only if it has changed */ 00075 int thread_nvm_store_seq_counter_store(uint32_t network_seq_counter); 00076 00077 #ifdef __cplusplus 00078 } 00079 #endif 00080 00081 #endif //THREAD_NVM_STORE_H_
Generated on Tue Jul 12 2022 13:03:21 by
