terence zhang / Mbed OS mbed-os-example-wakaama

Dependencies:   C12832 LM75B

Committer:
terencez
Date:
Mon Apr 24 23:03:31 2017 +0000
Revision:
0:f9d13e09cf11
Child:
3:a280069151ac
Child:
9:279794541018
The first compiled submit.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
terencez 0:f9d13e09cf11 1 /*******************************************************************************
terencez 0:f9d13e09cf11 2 *
terencez 0:f9d13e09cf11 3 * Copyright (c) 2013, 2014 Intel Corporation and others.
terencez 0:f9d13e09cf11 4 * All rights reserved. This program and the accompanying materials
terencez 0:f9d13e09cf11 5 * are made available under the terms of the Eclipse Public License v1.0
terencez 0:f9d13e09cf11 6 * and Eclipse Distribution License v1.0 which accompany this distribution.
terencez 0:f9d13e09cf11 7 *
terencez 0:f9d13e09cf11 8 * The Eclipse Public License is available at
terencez 0:f9d13e09cf11 9 * http://www.eclipse.org/legal/epl-v10.html
terencez 0:f9d13e09cf11 10 * The Eclipse Distribution License is available at
terencez 0:f9d13e09cf11 11 * http://www.eclipse.org/org/documents/edl-v10.php.
terencez 0:f9d13e09cf11 12 *
terencez 0:f9d13e09cf11 13 * Contributors:
terencez 0:f9d13e09cf11 14 * David Navarro, Intel Corporation - initial API and implementation
terencez 0:f9d13e09cf11 15 * Fabien Fleutot - Please refer to git log
terencez 0:f9d13e09cf11 16 * Toby Jaffey - Please refer to git log
terencez 0:f9d13e09cf11 17 *
terencez 0:f9d13e09cf11 18 *******************************************************************************/
terencez 0:f9d13e09cf11 19 /*
terencez 0:f9d13e09cf11 20 Copyright (c) 2013, 2014 Intel Corporation
terencez 0:f9d13e09cf11 21
terencez 0:f9d13e09cf11 22 Redistribution and use in source and binary forms, with or without modification,
terencez 0:f9d13e09cf11 23 are permitted provided that the following conditions are met:
terencez 0:f9d13e09cf11 24
terencez 0:f9d13e09cf11 25 * Redistributions of source code must retain the above copyright notice,
terencez 0:f9d13e09cf11 26 this list of conditions and the following disclaimer.
terencez 0:f9d13e09cf11 27 * Redistributions in binary form must reproduce the above copyright notice,
terencez 0:f9d13e09cf11 28 this list of conditions and the following disclaimer in the documentation
terencez 0:f9d13e09cf11 29 and/or other materials provided with the distribution.
terencez 0:f9d13e09cf11 30 * Neither the name of Intel Corporation nor the names of its contributors
terencez 0:f9d13e09cf11 31 may be used to endorse or promote products derived from this software
terencez 0:f9d13e09cf11 32 without specific prior written permission.
terencez 0:f9d13e09cf11 33
terencez 0:f9d13e09cf11 34 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
terencez 0:f9d13e09cf11 35 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
terencez 0:f9d13e09cf11 36 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
terencez 0:f9d13e09cf11 37 IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
terencez 0:f9d13e09cf11 38 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
terencez 0:f9d13e09cf11 39 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
terencez 0:f9d13e09cf11 40 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
terencez 0:f9d13e09cf11 41 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
terencez 0:f9d13e09cf11 42 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
terencez 0:f9d13e09cf11 43 THE POSSIBILITY OF SUCH DAMAGE.
terencez 0:f9d13e09cf11 44
terencez 0:f9d13e09cf11 45 David Navarro <david.navarro@intel.com>
terencez 0:f9d13e09cf11 46
terencez 0:f9d13e09cf11 47 */
terencez 0:f9d13e09cf11 48
terencez 0:f9d13e09cf11 49 #ifndef _LWM2M_INTERNALS_H_
terencez 0:f9d13e09cf11 50 #define _LWM2M_INTERNALS_H_
terencez 0:f9d13e09cf11 51
terencez 0:f9d13e09cf11 52
terencez 0:f9d13e09cf11 53 #include "liblwm2m.h"
terencez 0:f9d13e09cf11 54
terencez 0:f9d13e09cf11 55 #include <stdlib.h>
terencez 0:f9d13e09cf11 56 #include <string.h>
terencez 0:f9d13e09cf11 57 #include <stdio.h>
terencez 0:f9d13e09cf11 58 #include <stdint.h>
terencez 0:f9d13e09cf11 59 #include <stddef.h>
terencez 0:f9d13e09cf11 60 #include <stdbool.h>
terencez 0:f9d13e09cf11 61
terencez 0:f9d13e09cf11 62 #include "er-coap-13/er-coap-13.h"
terencez 0:f9d13e09cf11 63
terencez 0:f9d13e09cf11 64 #ifdef WITH_LOGS
terencez 0:f9d13e09cf11 65 #define LOG(...) fprintf(stderr, __VA_ARGS__)
terencez 0:f9d13e09cf11 66 #else
terencez 0:f9d13e09cf11 67 #define LOG(...)
terencez 0:f9d13e09cf11 68 #endif
terencez 0:f9d13e09cf11 69
terencez 0:f9d13e09cf11 70 #define LWM2M_DEFAULT_LIFETIME 86400
terencez 0:f9d13e09cf11 71
terencez 0:f9d13e09cf11 72 #define LWM2M_MAX_PACKET_SIZE 198
terencez 0:f9d13e09cf11 73
terencez 0:f9d13e09cf11 74 #define LWM2M_SECURITY_OBJECT_ID 0
terencez 0:f9d13e09cf11 75 #define LWM2M_SERVER_OBJECT_ID 1
terencez 0:f9d13e09cf11 76 #define LWM2M_ACL_OBJECT_ID 2
terencez 0:f9d13e09cf11 77
terencez 0:f9d13e09cf11 78 #define URI_REGISTRATION_SEGMENT "rd"
terencez 0:f9d13e09cf11 79 #define URI_REGISTRATION_SEGMENT_LEN 2
terencez 0:f9d13e09cf11 80 #define URI_BOOTSTRAP_SEGMENT "bs"
terencez 0:f9d13e09cf11 81 #define URI_BOOTSTRAP_SEGMENT_LEN 2
terencez 0:f9d13e09cf11 82
terencez 0:f9d13e09cf11 83 #define LWM2M_URI_FLAG_DM (uint8_t)0x00
terencez 0:f9d13e09cf11 84 #define LWM2M_URI_FLAG_REGISTRATION (uint8_t)0x20
terencez 0:f9d13e09cf11 85 #define LWM2M_URI_FLAG_BOOTSTRAP (uint8_t)0x40
terencez 0:f9d13e09cf11 86
terencez 0:f9d13e09cf11 87 #define LWM2M_URI_MASK_TYPE (uint8_t)0x70
terencez 0:f9d13e09cf11 88 #define LWM2M_URI_MASK_ID (uint8_t)0x07
terencez 0:f9d13e09cf11 89
terencez 0:f9d13e09cf11 90 typedef struct
terencez 0:f9d13e09cf11 91 {
terencez 0:f9d13e09cf11 92 lwm2m_uri_t uri;
terencez 0:f9d13e09cf11 93 lwm2m_result_callback_t callback;
terencez 0:f9d13e09cf11 94 void * userData;
terencez 0:f9d13e09cf11 95 } dm_data_t;
terencez 0:f9d13e09cf11 96
terencez 0:f9d13e09cf11 97 typedef struct _obs_list_
terencez 0:f9d13e09cf11 98 {
terencez 0:f9d13e09cf11 99 struct _obs_list_ * next;
terencez 0:f9d13e09cf11 100 lwm2m_observed_t * item;
terencez 0:f9d13e09cf11 101 } obs_list_t;
terencez 0:f9d13e09cf11 102
terencez 0:f9d13e09cf11 103 // defined in uri.c
terencez 0:f9d13e09cf11 104 int prv_get_number(const char * uriString, size_t uriLength);
terencez 0:f9d13e09cf11 105 lwm2m_uri_t * lwm2m_decode_uri(multi_option_t *uriPath);
terencez 0:f9d13e09cf11 106
terencez 0:f9d13e09cf11 107 // defined in objects.c
terencez 0:f9d13e09cf11 108 coap_status_t object_read(lwm2m_context_t * contextP, lwm2m_uri_t * uriP, char ** bufferP, int * lengthP);
terencez 0:f9d13e09cf11 109 coap_status_t object_write(lwm2m_context_t * contextP, lwm2m_uri_t * uriP, char * buffer, int length);
terencez 0:f9d13e09cf11 110 coap_status_t object_create(lwm2m_context_t * contextP, lwm2m_uri_t * uriP, char * buffer, int length);
terencez 0:f9d13e09cf11 111 coap_status_t object_execute(lwm2m_context_t * contextP, lwm2m_uri_t * uriP, char * buffer, int length);
terencez 0:f9d13e09cf11 112 coap_status_t object_delete(lwm2m_context_t * contextP, lwm2m_uri_t * uriP);
terencez 0:f9d13e09cf11 113 bool object_isInstanceNew(lwm2m_context_t * contextP, uint16_t objectId, uint16_t instanceId);
terencez 0:f9d13e09cf11 114 int prv_getRegisterPayload(lwm2m_context_t * contextP, char * buffer, size_t length);
terencez 0:f9d13e09cf11 115
terencez 0:f9d13e09cf11 116 // defined in object_server.c
terencez 0:f9d13e09cf11 117 coap_status_t object_server_read(lwm2m_context_t * contextP, lwm2m_uri_t * uriP, char ** bufferP, int * lengthP);
terencez 0:f9d13e09cf11 118 coap_status_t object_server_write(lwm2m_context_t * contextP, lwm2m_uri_t * uriP, char * buffer, int length);
terencez 0:f9d13e09cf11 119 coap_status_t object_server_execute(lwm2m_context_t * contextP, lwm2m_uri_t * uriP, char * buffer, int length);
terencez 0:f9d13e09cf11 120 coap_status_t object_server_create(lwm2m_context_t * contextP, lwm2m_uri_t * uriP, char * buffer, int length);
terencez 0:f9d13e09cf11 121 coap_status_t object_server_delete(lwm2m_context_t * contextP, lwm2m_uri_t * uriP);
terencez 0:f9d13e09cf11 122 coap_status_t object_security_create(lwm2m_context_t * contextP, lwm2m_uri_t * uriP, char * buffer, int length);
terencez 0:f9d13e09cf11 123 coap_status_t object_security_delete(lwm2m_context_t * contextP, lwm2m_uri_t * uriP);
terencez 0:f9d13e09cf11 124
terencez 0:f9d13e09cf11 125 // defined in transaction.c
terencez 0:f9d13e09cf11 126 lwm2m_transaction_t * transaction_new(coap_method_t method, lwm2m_uri_t * uriP, uint16_t mID, lwm2m_endpoint_type_t peerType, void * peerP);
terencez 0:f9d13e09cf11 127 int transaction_send(lwm2m_context_t * contextP, lwm2m_transaction_t * transacP);
terencez 0:f9d13e09cf11 128 void transaction_free(lwm2m_transaction_t * transacP);
terencez 0:f9d13e09cf11 129 void transaction_remove(lwm2m_context_t * contextP, lwm2m_transaction_t * transacP);
terencez 0:f9d13e09cf11 130 void transaction_handle_response(lwm2m_context_t * contextP, void * fromSessionH, coap_packet_t * message);
terencez 0:f9d13e09cf11 131
terencez 0:f9d13e09cf11 132 // defined in management.c
terencez 0:f9d13e09cf11 133 coap_status_t handle_dm_request(lwm2m_context_t * contextP, lwm2m_uri_t * uriP, void * fromSessionH, coap_packet_t * message, coap_packet_t * response);
terencez 0:f9d13e09cf11 134
terencez 0:f9d13e09cf11 135 // defined in observe.c
terencez 0:f9d13e09cf11 136 coap_status_t handle_observe_request(lwm2m_context_t * contextP, lwm2m_uri_t * uriP, void * fromSessionH, coap_packet_t * message, coap_packet_t * response);
terencez 0:f9d13e09cf11 137 void cancel_observe(lwm2m_context_t * contextP, uint16_t mid, void * fromSessionH);
terencez 0:f9d13e09cf11 138
terencez 0:f9d13e09cf11 139 // defined in registration.c
terencez 0:f9d13e09cf11 140 coap_status_t handle_registration_request(lwm2m_context_t * contextP, lwm2m_uri_t * uriP, void * fromSessionH, coap_packet_t * message, coap_packet_t * response);
terencez 0:f9d13e09cf11 141 void registration_deregister(lwm2m_context_t * contextP, lwm2m_server_t * serverP);
terencez 0:f9d13e09cf11 142 void prv_freeClient(lwm2m_client_t * clientP);
terencez 0:f9d13e09cf11 143
terencez 0:f9d13e09cf11 144 // defined in packet.c
terencez 0:f9d13e09cf11 145 coap_status_t message_send(lwm2m_context_t * contextP, coap_packet_t * message, void * sessionH);
terencez 0:f9d13e09cf11 146
terencez 0:f9d13e09cf11 147 // defined in observe.c
terencez 0:f9d13e09cf11 148 void handle_observe_notify(lwm2m_context_t * contextP, void * fromSessionH, coap_packet_t * message);
terencez 0:f9d13e09cf11 149 void observation_remove(lwm2m_client_t * clientP, lwm2m_observation_t * observationP);
terencez 0:f9d13e09cf11 150
terencez 0:f9d13e09cf11 151 #endif