Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ws_pae_nvm_store.h Source File

ws_pae_nvm_store.h

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 
00018 #ifndef WS_PAE_NVM_STORE_H_
00019 #define WS_PAE_NVM_STORE_H_
00020 
00021 /*
00022  * Port access entity non-volatile memory (NVM) storage module. Module is used
00023  * to write and read PAE NVM data TLVs to/from filesystem.
00024  *
00025  */
00026 
00027 // tag + length
00028 #define NVM_TLV_FIXED_LEN               4
00029 
00030 // file names
00031 #define NW_INFO_FILE_NAME               "pae_nw_info"
00032 #define KEYS_FILE_NAME                  "pae_keys"
00033 #define FRAME_COUNTER_FILE_NAME         "pae_frame_counter"
00034 
00035 typedef struct nvm_tlv_entry {
00036     ns_list_link_t link;                /**< Link */
00037     uint16_t tag;                       /**< Unique tag */
00038     uint16_t len;                       /**< Number of the bytes after the length field */
00039 } nvm_tlv_entry_t;
00040 
00041 typedef NS_LIST_HEAD (nvm_tlv_entry_t, link) nvm_tlv_list_t;
00042 
00043 #define PAE_NVM_FILE_SUCCESS            0
00044 #define PAE_NVM_FILE_READ_ERROR        -1
00045 #define PAE_NVM_FILE_WRITE_ERROR       -2
00046 #define PAE_NVM_FILE_VERSION_WRONG     -3
00047 #define PAE_NVM_FILE_CANNOT_OPEN       -4
00048 #define PAE_NVM_FILE_ROOT_PATH_INVALID -5
00049 #define PAE_NVM_FILE_PARAMETER_INVALID -6
00050 #define PAE_NVM_FILE_REMOVE_ERROR      -7
00051 
00052 /**
00053  * ws_pae_nvm_store_tlv_file_write write a list of TLVs to file
00054  *
00055  * \param file file name
00056  * \param tlv_list TLV list
00057  *
00058  * \return < 0 failure
00059  * \return >= 0 success
00060  *
00061  */
00062 int8_t ws_pae_nvm_store_tlv_file_write(const char *file, nvm_tlv_list_t *tlv_list);
00063 
00064 /**
00065  * ws_pae_nvm_store_tlv_file_read read a list of TLVs from file
00066  *
00067  * \param file file name
00068  * \param tlv_list TLV list
00069  *
00070  * \return < 0 failure
00071  * \return >= 0 success
00072  *
00073  */
00074 int8_t ws_pae_nvm_store_tlv_file_read(const char *file, nvm_tlv_list_t *tlv_list);
00075 
00076 #endif /* WS_PAE_NVM_STORE_H_ */