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 LM75B MMA7660 WiflyInterface mbed-rtos mbed nsdl_lib
Fork of NSDL_HelloWorld by
Diff: resource_generation_help.h
- Revision:
- 0:2edbfea18d23
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/resource_generation_help.h Wed Oct 09 09:31:17 2013 +0000
@@ -0,0 +1,74 @@
+/*
+ * resource_generation_help.h
+ *
+ * Created on: 6.3.2012
+ * Author: Sensinode
+ */
+
+#ifndef RESOURCE_GENERATION_HELP_H_
+#define RESOURCE_GENERATION_HELP_H_
+
+/*
+ * A helper macro to create a static resoure
+ * Only get is allowed
+ */
+#define CREATE_STATIC_RESOURCE(resource_structure, pt_len, pt, rpp_len, rpp_ptr, rsc, rsc_len) \
+{ \
+ resource_structure->access = SN_GRS_GET_ALLOWED; \
+ resource_structure->mode = SN_GRS_STATIC; \
+ resource_structure->pathlen = pt_len; \
+ resource_structure->path = pt; \
+ resource_structure->resource_parameters_ptr->resource_type_len = rpp_len; \
+ resource_structure->resource_parameters_ptr->resource_type_ptr = rpp_ptr; \
+ resource_structure->resource = rsc; \
+ resource_structure->resourcelen = rsc_len; \
+ sn_nsdl_create_resource(resource_structure); \
+}
+
+
+/*
+ * A helper macro to create a dynamic resoure
+ */
+#define CREATE_DYNAMIC_RESOURCE(resource_structure, pt_len, pt, rpp_len, rpp_ptr, is_observable, callback_ptr, access_right) \
+{ \
+ resource_structure->access = (sn_grs_resource_acl_e)access_right; \
+ resource_structure->resource = 0; \
+ resource_structure->resourcelen = 0; \
+ resource_structure->sn_grs_dyn_res_callback = callback_ptr; \
+ resource_structure->mode = SN_GRS_DYNAMIC; \
+ resource_structure->pathlen = pt_len; \
+ resource_structure->path = pt; \
+ resource_structure->resource_parameters_ptr->resource_type_len = rpp_len; \
+ resource_structure->resource_parameters_ptr->resource_type_ptr = rpp_ptr; \
+ resource_structure->resource_parameters_ptr->observable = is_observable; \
+ sn_nsdl_create_resource(resource_structure); \
+}
+
+#define INIT_REGISTER_NSDL_ENDPOINT(endpoint_structure, name, typename_ptr, lifetime_ptr) \
+{ \
+ if(!endpoint_structure) \
+ { \
+ endpoint_structure = (sn_nsdl_ep_parameters_s*)own_alloc(sizeof(sn_nsdl_ep_parameters_s)); \
+ } \
+ if(endpoint_structure) \
+ { \
+ memset(endpoint_structure, 0, sizeof(sn_nsdl_ep_parameters_s)); \
+ endpoint_structure->endpoint_name_ptr = name; \
+ endpoint_structure->endpoint_name_len = 15; \
+ endpoint_structure->type_ptr = typename_ptr; \
+ endpoint_structure->type_len = sizeof(typename_ptr)-1; \
+ endpoint_structure->lifetime_ptr = lifetime_ptr; \
+ endpoint_structure->lifetime_len = sizeof(lifetime_ptr)-1; \
+ } \
+}
+
+#define CLEAN_REGISTER_NSDL_ENDPOINT(endpoint_structure) \
+{ \
+ if(endpoint_structure) \
+ { \
+ own_free(endpoint_structure); \
+ endpoint_structure = 0; \
+ } \
+} \
+
+#endif /* RESOURCE_GENERATION_HELP_H_ */
