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: mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510
resource_generation_help.h
00001 /* 00002 * Copyright (c) 2015 ARM Limited. All rights reserved. 00003 * SPDX-License-Identifier: Apache-2.0 00004 * Licensed under the Apache License, Version 2.0 (the License); you may 00005 * not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an AS IS BASIS, WITHOUT 00012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef RESOURCE_GENERATION_HELP_H_ 00018 #define RESOURCE_GENERATION_HELP_H_ 00019 00020 /* 00021 * A helper macro to create a static resoure 00022 */ 00023 #define CREATE_STATIC_RESOURCE(resource_structure, pt_len, pt, rpp_len, rpp_ptr, rsc, rsc_len, handle) \ 00024 { \ 00025 resource_structure->access = (sn_grs_resource_acl_e)0xff; \ 00026 resource_structure->mode = SN_GRS_STATIC; \ 00027 resource_structure->pathlen = pt_len; \ 00028 resource_structure->path = pt; \ 00029 resource_structure->resource_parameters_ptr->resource_type_len = rpp_len; \ 00030 resource_structure->resource_parameters_ptr->resource_type_ptr = rpp_ptr; \ 00031 resource_structure->resource = rsc; \ 00032 resource_structure->resourcelen = rsc_len; \ 00033 sn_nsdl_create_resource(handle,resource_structure); \ 00034 } 00035 00036 00037 /* 00038 * A helper macro to create a dynamic resoure 00039 */ 00040 #define CREATE_DYNAMIC_RESOURCE(resource_structure, pt_len, pt, rpp_len, rpp_ptr, is_observable, callback_ptr, handle) \ 00041 { \ 00042 resource_structure->access = (sn_grs_resource_acl_e)0xff; \ 00043 resource_structure->resource = 0; \ 00044 resource_structure->resourcelen = 0; \ 00045 resource_structure->sn_grs_dyn_res_callback = callback_ptr; \ 00046 resource_structure->mode = SN_GRS_DYNAMIC; \ 00047 resource_structure->pathlen = pt_len; \ 00048 resource_structure->path = pt; \ 00049 resource_structure->resource_parameters_ptr->resource_type_len = rpp_len; \ 00050 resource_structure->resource_parameters_ptr->resource_type_ptr = rpp_ptr; \ 00051 resource_structure->resource_parameters_ptr->observable = is_observable; \ 00052 sn_nsdl_create_resource(handle,resource_structure); \ 00053 } 00054 00055 #define INIT_REGISTER_NSDL_ENDPOINT(endpoint_structure, name, typename_ptr, lifetime_ptr) \ 00056 { \ 00057 if(!endpoint_structure) \ 00058 { \ 00059 endpoint_structure = own_alloc(sizeof(sn_nsdl_ep_parameters_s)); \ 00060 } \ 00061 if(endpoint_structure) \ 00062 { \ 00063 memset(endpoint_structure, 0, sizeof(sn_nsdl_ep_parameters_s)); \ 00064 endpoint_structure->endpoint_name_ptr = name; \ 00065 endpoint_structure->endpoint_name_len = sizeof(name)-1; \ 00066 endpoint_structure->type_ptr = typename_ptr; \ 00067 endpoint_structure->type_len = sizeof(typename_ptr)-1; \ 00068 endpoint_structure->lifetime_ptr = lifetime_ptr; \ 00069 endpoint_structure->lifetime_len = sizeof(lifetime_ptr)-1; \ 00070 } \ 00071 } 00072 00073 #define CLEAN_REGISTER_NSDL_ENDPOINT(endpoint_structure) \ 00074 { \ 00075 if(endpoint_structure) \ 00076 { \ 00077 own_free(endpoint_structure); \ 00078 endpoint_structure = 0; \ 00079 } \ 00080 } \ 00081 00082 #endif /* RESOURCE_GENERATION_HELP_H_ */
Generated on Tue Jul 12 2022 11:02:50 by
