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.
Dependencies: Beep C12832_lcd EthernetInterface LM75B MMA7660 mbed-rtos mbed nsdl_lib
Fork of LWM2M_NanoService_Ethernet by
resource_generation_help.h@0:2edbfea18d23, 2013-10-09 (annotated)
- Committer:
- terohoo
- Date:
- Wed Oct 09 09:31:17 2013 +0000
- Revision:
- 0:2edbfea18d23
Adding nsdl example app
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| terohoo | 0:2edbfea18d23 | 1 | /* |
| terohoo | 0:2edbfea18d23 | 2 | * resource_generation_help.h |
| terohoo | 0:2edbfea18d23 | 3 | * |
| terohoo | 0:2edbfea18d23 | 4 | * Created on: 6.3.2012 |
| terohoo | 0:2edbfea18d23 | 5 | * Author: Sensinode |
| terohoo | 0:2edbfea18d23 | 6 | */ |
| terohoo | 0:2edbfea18d23 | 7 | |
| terohoo | 0:2edbfea18d23 | 8 | #ifndef RESOURCE_GENERATION_HELP_H_ |
| terohoo | 0:2edbfea18d23 | 9 | #define RESOURCE_GENERATION_HELP_H_ |
| terohoo | 0:2edbfea18d23 | 10 | |
| terohoo | 0:2edbfea18d23 | 11 | /* |
| terohoo | 0:2edbfea18d23 | 12 | * A helper macro to create a static resoure |
| terohoo | 0:2edbfea18d23 | 13 | * Only get is allowed |
| terohoo | 0:2edbfea18d23 | 14 | */ |
| terohoo | 0:2edbfea18d23 | 15 | #define CREATE_STATIC_RESOURCE(resource_structure, pt_len, pt, rpp_len, rpp_ptr, rsc, rsc_len) \ |
| terohoo | 0:2edbfea18d23 | 16 | { \ |
| terohoo | 0:2edbfea18d23 | 17 | resource_structure->access = SN_GRS_GET_ALLOWED; \ |
| terohoo | 0:2edbfea18d23 | 18 | resource_structure->mode = SN_GRS_STATIC; \ |
| terohoo | 0:2edbfea18d23 | 19 | resource_structure->pathlen = pt_len; \ |
| terohoo | 0:2edbfea18d23 | 20 | resource_structure->path = pt; \ |
| terohoo | 0:2edbfea18d23 | 21 | resource_structure->resource_parameters_ptr->resource_type_len = rpp_len; \ |
| terohoo | 0:2edbfea18d23 | 22 | resource_structure->resource_parameters_ptr->resource_type_ptr = rpp_ptr; \ |
| terohoo | 0:2edbfea18d23 | 23 | resource_structure->resource = rsc; \ |
| terohoo | 0:2edbfea18d23 | 24 | resource_structure->resourcelen = rsc_len; \ |
| terohoo | 0:2edbfea18d23 | 25 | sn_nsdl_create_resource(resource_structure); \ |
| terohoo | 0:2edbfea18d23 | 26 | } |
| terohoo | 0:2edbfea18d23 | 27 | |
| terohoo | 0:2edbfea18d23 | 28 | |
| terohoo | 0:2edbfea18d23 | 29 | /* |
| terohoo | 0:2edbfea18d23 | 30 | * A helper macro to create a dynamic resoure |
| terohoo | 0:2edbfea18d23 | 31 | */ |
| terohoo | 0:2edbfea18d23 | 32 | #define CREATE_DYNAMIC_RESOURCE(resource_structure, pt_len, pt, rpp_len, rpp_ptr, is_observable, callback_ptr, access_right) \ |
| terohoo | 0:2edbfea18d23 | 33 | { \ |
| terohoo | 0:2edbfea18d23 | 34 | resource_structure->access = (sn_grs_resource_acl_e)access_right; \ |
| terohoo | 0:2edbfea18d23 | 35 | resource_structure->resource = 0; \ |
| terohoo | 0:2edbfea18d23 | 36 | resource_structure->resourcelen = 0; \ |
| terohoo | 0:2edbfea18d23 | 37 | resource_structure->sn_grs_dyn_res_callback = callback_ptr; \ |
| terohoo | 0:2edbfea18d23 | 38 | resource_structure->mode = SN_GRS_DYNAMIC; \ |
| terohoo | 0:2edbfea18d23 | 39 | resource_structure->pathlen = pt_len; \ |
| terohoo | 0:2edbfea18d23 | 40 | resource_structure->path = pt; \ |
| terohoo | 0:2edbfea18d23 | 41 | resource_structure->resource_parameters_ptr->resource_type_len = rpp_len; \ |
| terohoo | 0:2edbfea18d23 | 42 | resource_structure->resource_parameters_ptr->resource_type_ptr = rpp_ptr; \ |
| terohoo | 0:2edbfea18d23 | 43 | resource_structure->resource_parameters_ptr->observable = is_observable; \ |
| terohoo | 0:2edbfea18d23 | 44 | sn_nsdl_create_resource(resource_structure); \ |
| terohoo | 0:2edbfea18d23 | 45 | } |
| terohoo | 0:2edbfea18d23 | 46 | |
| terohoo | 0:2edbfea18d23 | 47 | #define INIT_REGISTER_NSDL_ENDPOINT(endpoint_structure, name, typename_ptr, lifetime_ptr) \ |
| terohoo | 0:2edbfea18d23 | 48 | { \ |
| terohoo | 0:2edbfea18d23 | 49 | if(!endpoint_structure) \ |
| terohoo | 0:2edbfea18d23 | 50 | { \ |
| terohoo | 0:2edbfea18d23 | 51 | endpoint_structure = (sn_nsdl_ep_parameters_s*)own_alloc(sizeof(sn_nsdl_ep_parameters_s)); \ |
| terohoo | 0:2edbfea18d23 | 52 | } \ |
| terohoo | 0:2edbfea18d23 | 53 | if(endpoint_structure) \ |
| terohoo | 0:2edbfea18d23 | 54 | { \ |
| terohoo | 0:2edbfea18d23 | 55 | memset(endpoint_structure, 0, sizeof(sn_nsdl_ep_parameters_s)); \ |
| terohoo | 0:2edbfea18d23 | 56 | endpoint_structure->endpoint_name_ptr = name; \ |
| terohoo | 0:2edbfea18d23 | 57 | endpoint_structure->endpoint_name_len = 15; \ |
| terohoo | 0:2edbfea18d23 | 58 | endpoint_structure->type_ptr = typename_ptr; \ |
| terohoo | 0:2edbfea18d23 | 59 | endpoint_structure->type_len = sizeof(typename_ptr)-1; \ |
| terohoo | 0:2edbfea18d23 | 60 | endpoint_structure->lifetime_ptr = lifetime_ptr; \ |
| terohoo | 0:2edbfea18d23 | 61 | endpoint_structure->lifetime_len = sizeof(lifetime_ptr)-1; \ |
| terohoo | 0:2edbfea18d23 | 62 | } \ |
| terohoo | 0:2edbfea18d23 | 63 | } |
| terohoo | 0:2edbfea18d23 | 64 | |
| terohoo | 0:2edbfea18d23 | 65 | #define CLEAN_REGISTER_NSDL_ENDPOINT(endpoint_structure) \ |
| terohoo | 0:2edbfea18d23 | 66 | { \ |
| terohoo | 0:2edbfea18d23 | 67 | if(endpoint_structure) \ |
| terohoo | 0:2edbfea18d23 | 68 | { \ |
| terohoo | 0:2edbfea18d23 | 69 | own_free(endpoint_structure); \ |
| terohoo | 0:2edbfea18d23 | 70 | endpoint_structure = 0; \ |
| terohoo | 0:2edbfea18d23 | 71 | } \ |
| terohoo | 0:2edbfea18d23 | 72 | } \ |
| terohoo | 0:2edbfea18d23 | 73 | |
| terohoo | 0:2edbfea18d23 | 74 | #endif /* RESOURCE_GENERATION_HELP_H_ */ |
