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