Manual NanoService C Client 1.11-RC2 import
Dependents: Trenton_Doormat_FRDM-KL25Z_ETH
sn_grs.h@1:14a9b0f4b9d6, 2014-02-18 (annotated)
- Committer:
- zdshelby
- Date:
- Tue Feb 18 01:10:07 2014 +0000
- Revision:
- 1:14a9b0f4b9d6
- Added libnsdl import
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
zdshelby | 1:14a9b0f4b9d6 | 1 | /* |
zdshelby | 1:14a9b0f4b9d6 | 2 | * GRS.h |
zdshelby | 1:14a9b0f4b9d6 | 3 | * |
zdshelby | 1:14a9b0f4b9d6 | 4 | * Created on: 2.8.2011 |
zdshelby | 1:14a9b0f4b9d6 | 5 | * Author: Tero |
zdshelby | 1:14a9b0f4b9d6 | 6 | */ |
zdshelby | 1:14a9b0f4b9d6 | 7 | |
zdshelby | 1:14a9b0f4b9d6 | 8 | #ifdef __cplusplus |
zdshelby | 1:14a9b0f4b9d6 | 9 | extern "C" { |
zdshelby | 1:14a9b0f4b9d6 | 10 | #endif |
zdshelby | 1:14a9b0f4b9d6 | 11 | |
zdshelby | 1:14a9b0f4b9d6 | 12 | #ifndef GRS_H_ |
zdshelby | 1:14a9b0f4b9d6 | 13 | #define GRS_H_ |
zdshelby | 1:14a9b0f4b9d6 | 14 | |
zdshelby | 1:14a9b0f4b9d6 | 15 | |
zdshelby | 1:14a9b0f4b9d6 | 16 | #endif /* GRS_H_ */ |
zdshelby | 1:14a9b0f4b9d6 | 17 | |
zdshelby | 1:14a9b0f4b9d6 | 18 | #define SN_GRS_VERSION 0x0101 |
zdshelby | 1:14a9b0f4b9d6 | 19 | |
zdshelby | 1:14a9b0f4b9d6 | 20 | #ifndef SN_NSDL_HAVE_HTTP_CAPABILITY |
zdshelby | 1:14a9b0f4b9d6 | 21 | #define SN_NSDL_HAVE_HTTP_CAPABILITY 0 |
zdshelby | 1:14a9b0f4b9d6 | 22 | #endif |
zdshelby | 1:14a9b0f4b9d6 | 23 | |
zdshelby | 1:14a9b0f4b9d6 | 24 | #ifndef SN_NSDL_HAVE_HTTPS_CAPABILITY |
zdshelby | 1:14a9b0f4b9d6 | 25 | #define SN_NSDL_HAVE_HTTPS_CAPABILITY 0 |
zdshelby | 1:14a9b0f4b9d6 | 26 | #endif |
zdshelby | 1:14a9b0f4b9d6 | 27 | |
zdshelby | 1:14a9b0f4b9d6 | 28 | #ifndef SN_NSDL_HAVE_COAP_CAPABILITY |
zdshelby | 1:14a9b0f4b9d6 | 29 | #define SN_NSDL_HAVE_COAP_CAPABILITY 1 |
zdshelby | 1:14a9b0f4b9d6 | 30 | #endif |
zdshelby | 1:14a9b0f4b9d6 | 31 | |
zdshelby | 1:14a9b0f4b9d6 | 32 | #define SN_GRS_RESOURCE_ALREADY_EXISTS -2 |
zdshelby | 1:14a9b0f4b9d6 | 33 | #define SN_GRS_INVALID_PATH -3 |
zdshelby | 1:14a9b0f4b9d6 | 34 | #define SN_GRS_LIST_ADDING_FAILURE -4 |
zdshelby | 1:14a9b0f4b9d6 | 35 | #define SN_GRS_RESOURCE_UPDATED -5 |
zdshelby | 1:14a9b0f4b9d6 | 36 | |
zdshelby | 1:14a9b0f4b9d6 | 37 | #define ACCESS_DENIED -6 |
zdshelby | 1:14a9b0f4b9d6 | 38 | |
zdshelby | 1:14a9b0f4b9d6 | 39 | #define SN_GRS_DELETE_METHOD 0 |
zdshelby | 1:14a9b0f4b9d6 | 40 | #define SN_GRS_SEARCH_METHOD 1 |
zdshelby | 1:14a9b0f4b9d6 | 41 | |
zdshelby | 1:14a9b0f4b9d6 | 42 | #define SN_GRS_DEFAULT_ACCESS 0x0F |
zdshelby | 1:14a9b0f4b9d6 | 43 | |
zdshelby | 1:14a9b0f4b9d6 | 44 | #define SN_NDSL_RESOURCE_NOT_REGISTERED 0 |
zdshelby | 1:14a9b0f4b9d6 | 45 | #define SN_NDSL_RESOURCE_REGISTERING 1 |
zdshelby | 1:14a9b0f4b9d6 | 46 | #define SN_NDSL_RESOURCE_REGISTERED 2 |
zdshelby | 1:14a9b0f4b9d6 | 47 | |
zdshelby | 1:14a9b0f4b9d6 | 48 | /***** Structs *****/ |
zdshelby | 1:14a9b0f4b9d6 | 49 | |
zdshelby | 1:14a9b0f4b9d6 | 50 | typedef struct sn_grs_version_ |
zdshelby | 1:14a9b0f4b9d6 | 51 | { |
zdshelby | 1:14a9b0f4b9d6 | 52 | uint8_t major_version; |
zdshelby | 1:14a9b0f4b9d6 | 53 | uint8_t minor_version; |
zdshelby | 1:14a9b0f4b9d6 | 54 | uint8_t build; |
zdshelby | 1:14a9b0f4b9d6 | 55 | }sn_grs_version_s; |
zdshelby | 1:14a9b0f4b9d6 | 56 | |
zdshelby | 1:14a9b0f4b9d6 | 57 | |
zdshelby | 1:14a9b0f4b9d6 | 58 | |
zdshelby | 1:14a9b0f4b9d6 | 59 | /***** Function prototypes *****/ |
zdshelby | 1:14a9b0f4b9d6 | 60 | /** |
zdshelby | 1:14a9b0f4b9d6 | 61 | * \fn extern int8_t sn_grs_init (uint8_t (*sn_grs_tx_callback_ptr)(sn_nsdl_capab_e , uint8_t *, uint16_t, |
zdshelby | 1:14a9b0f4b9d6 | 62 | * sn_nsdl_addr_s *), uint8_t (*sn_grs_rx_callback_ptr)(sn_coap_hdr_s *, sn_nsdl_addr_s *), |
zdshelby | 1:14a9b0f4b9d6 | 63 | * sn_grs_mem_s *sn_memory) |
zdshelby | 1:14a9b0f4b9d6 | 64 | * |
zdshelby | 1:14a9b0f4b9d6 | 65 | * \brief GRS library initialize function. |
zdshelby | 1:14a9b0f4b9d6 | 66 | * |
zdshelby | 1:14a9b0f4b9d6 | 67 | * This function initializes GRS, CoAP and HTTP libraries. |
zdshelby | 1:14a9b0f4b9d6 | 68 | * |
zdshelby | 1:14a9b0f4b9d6 | 69 | * \param sn_grs_tx_callback A function pointer to a transmit callback function. Should return 1 when succeed, 0 when failed |
zdshelby | 1:14a9b0f4b9d6 | 70 | * \param *sn_grs_rx_callback_ptr A function pointer to a receiving callback function. If received packet is not for GRS, it will be passed to |
zdshelby | 1:14a9b0f4b9d6 | 71 | * upper level (NSDL) to be proceed. |
zdshelby | 1:14a9b0f4b9d6 | 72 | * \param sn_memory A pointer to a structure containing the platform specific functions for memory allocation and free. |
zdshelby | 1:14a9b0f4b9d6 | 73 | * |
zdshelby | 1:14a9b0f4b9d6 | 74 | * \return success = 0, failure = -1 |
zdshelby | 1:14a9b0f4b9d6 | 75 | * |
zdshelby | 1:14a9b0f4b9d6 | 76 | */ |
zdshelby | 1:14a9b0f4b9d6 | 77 | extern int8_t sn_grs_init (uint8_t (*sn_grs_tx_callback_ptr)(sn_nsdl_capab_e , uint8_t *, uint16_t, |
zdshelby | 1:14a9b0f4b9d6 | 78 | sn_nsdl_addr_s *), int8_t (*sn_grs_rx_callback_ptr)(sn_coap_hdr_s *, sn_nsdl_addr_s *), sn_nsdl_mem_s *sn_memory); |
zdshelby | 1:14a9b0f4b9d6 | 79 | extern int8_t sn_grs_exec(uint32_t time); |
zdshelby | 1:14a9b0f4b9d6 | 80 | extern sn_grs_resource_list_s *sn_grs_list_resource(uint16_t pathlen, uint8_t *path); |
zdshelby | 1:14a9b0f4b9d6 | 81 | extern sn_nsdl_resource_info_s *sn_grs_get_first_resource(void); |
zdshelby | 1:14a9b0f4b9d6 | 82 | extern sn_nsdl_resource_info_s *sn_grs_get_next_resource(void); |
zdshelby | 1:14a9b0f4b9d6 | 83 | extern sn_nsdl_resource_info_s *sn_grs_get_resource(uint16_t pathlen, uint8_t *path); |
zdshelby | 1:14a9b0f4b9d6 | 84 | extern int8_t sn_grs_delete_resource(uint16_t pathlen, uint8_t *path); |
zdshelby | 1:14a9b0f4b9d6 | 85 | extern int8_t sn_grs_update_resource(sn_nsdl_resource_info_s *res); |
zdshelby | 1:14a9b0f4b9d6 | 86 | /** |
zdshelby | 1:14a9b0f4b9d6 | 87 | * \fn extern int8_t sn_grs_create_resource(sn_grs_resource_info_t *res) |
zdshelby | 1:14a9b0f4b9d6 | 88 | * |
zdshelby | 1:14a9b0f4b9d6 | 89 | * \brief Resource creating function. |
zdshelby | 1:14a9b0f4b9d6 | 90 | * |
zdshelby | 1:14a9b0f4b9d6 | 91 | * Used to create a static or dynamic HTTP(S) or CoAP resource. |
zdshelby | 1:14a9b0f4b9d6 | 92 | * |
zdshelby | 1:14a9b0f4b9d6 | 93 | * \param *res Pointer to a structure of type sn_grs_resource_info_t that contains the information |
zdshelby | 1:14a9b0f4b9d6 | 94 | * about the resource. |
zdshelby | 1:14a9b0f4b9d6 | 95 | * |
zdshelby | 1:14a9b0f4b9d6 | 96 | * \return 0 success |
zdshelby | 1:14a9b0f4b9d6 | 97 | * -1 Resource already exists |
zdshelby | 1:14a9b0f4b9d6 | 98 | * -2 Invalid path |
zdshelby | 1:14a9b0f4b9d6 | 99 | * -3 List adding failure |
zdshelby | 1:14a9b0f4b9d6 | 100 | */ |
zdshelby | 1:14a9b0f4b9d6 | 101 | extern int8_t sn_grs_create_resource(sn_nsdl_resource_info_s *res); |
zdshelby | 1:14a9b0f4b9d6 | 102 | extern int8_t sn_grs_process_http(uint8_t *packet, uint16_t *packet_len, sn_nsdl_addr_s *src); |
zdshelby | 1:14a9b0f4b9d6 | 103 | extern int8_t sn_grs_process_coap(uint8_t *packet, uint16_t packet_len, sn_nsdl_addr_s *src); |
zdshelby | 1:14a9b0f4b9d6 | 104 | extern int16_t sn_grs_get_capability(void); |
zdshelby | 1:14a9b0f4b9d6 | 105 | extern uint32_t sn_grs_get_version(void); |
zdshelby | 1:14a9b0f4b9d6 | 106 | extern int8_t sn_grs_send_coap_message(sn_nsdl_addr_s *address_ptr, sn_coap_hdr_s *coap_hdr_ptr); |
zdshelby | 1:14a9b0f4b9d6 | 107 | |
zdshelby | 1:14a9b0f4b9d6 | 108 | extern int8_t sn_grs_destroy(void); |
zdshelby | 1:14a9b0f4b9d6 | 109 | |
zdshelby | 1:14a9b0f4b9d6 | 110 | #ifdef __cplusplus |
zdshelby | 1:14a9b0f4b9d6 | 111 | } |
zdshelby | 1:14a9b0f4b9d6 | 112 | #endif |
zdshelby | 1:14a9b0f4b9d6 | 113 | |
zdshelby | 1:14a9b0f4b9d6 | 114 | |
zdshelby | 1:14a9b0f4b9d6 | 115 | |
zdshelby | 1:14a9b0f4b9d6 | 116 | |
zdshelby | 1:14a9b0f4b9d6 | 117 |