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
ndef.h
00001 /* 00002 * Copyright (c) 2013-2018, ARM Limited, All Rights Reserved 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00006 * 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, WITHOUT 00013 * 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 * \file ndef.h 00019 * \copyright Copyright (c) ARM Ltd 2013 00020 * \author Donatien Garnier 00021 */ 00022 00023 /** \addtogroup NDEF 00024 * @{ 00025 * \name Generic NDEF Tag 00026 * @{ 00027 */ 00028 00029 #ifndef NDEF_H_ 00030 #define NDEF_H_ 00031 00032 #include "stack/nfc_common.h" 00033 00034 #ifdef __cplusplus 00035 extern "C" { 00036 #endif 00037 00038 //Generic interface for NDEF messages 00039 typedef struct __ndef_msg ndef_msg_t; 00040 00041 /** Function called to generate the tag's content on read (target mode) 00042 * \param pTag pointer to ndef_tag_t instance 00043 * \param type pMem buffer in which to store the generated content 00044 */ 00045 typedef nfc_err_t (*ndef_encode_fn_t)(ndef_msg_t *pTag, ac_buffer_builder_t *pBufferBldr, void *pUserData); 00046 00047 /** Function called to decode the tag's content on write (target mode) or read (reader mode) 00048 * \param pTag pointer to ndef_tag_t instance 00049 * \param type pMem buffer containing the tag's content 00050 */ 00051 typedef nfc_err_t (*ndef_decode_fn_t)(ndef_msg_t *pTag, ac_buffer_t *pBuffer, void *pUserData); 00052 00053 struct __ndef_msg { 00054 ndef_encode_fn_t encode; 00055 ndef_decode_fn_t decode; 00056 ac_buffer_builder_t bufferBldr; 00057 void *pUserData; 00058 }; 00059 00060 void ndef_msg_init(ndef_msg_t *pNdef, ndef_encode_fn_t encode, ndef_decode_fn_t decode, uint8_t *data, size_t size, void *pUserData); 00061 00062 static inline nfc_err_t ndef_msg_encode(ndef_msg_t *pNdef) 00063 { 00064 if (pNdef->encode == NULL) { 00065 return NFC_OK; 00066 } 00067 return pNdef->encode(pNdef, &pNdef->bufferBldr, pNdef->pUserData); 00068 } 00069 00070 static inline nfc_err_t ndef_msg_decode(ndef_msg_t *pNdef) 00071 { 00072 if (pNdef->decode == NULL) { 00073 return NFC_OK; 00074 } 00075 return pNdef->decode(pNdef, ac_buffer_builder_buffer(&pNdef->bufferBldr), pNdef->pUserData); 00076 } 00077 00078 static inline ac_buffer_builder_t *ndef_msg_buffer_builder(ndef_msg_t *pNdef) 00079 { 00080 return &pNdef->bufferBldr; 00081 } 00082 00083 //void* ndef_tag_impl(ndef_tag_t* pNdefTag); 00084 00085 #ifdef __cplusplus 00086 } 00087 #endif 00088 00089 #endif /* NDEF_H_ */ 00090 00091 /** 00092 * @} 00093 * @} 00094 * */ 00095
Generated on Tue Jul 12 2022 13:54:37 by
