mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
ba3088c4bd
into separate patch files
216 lines
8.1 KiB
Diff
216 lines
8.1 KiB
Diff
*** stock_iot-lab_M3/openwsn/04-TRAN/opencoap.h Thu Apr 24 11:01:36 2014
|
|
--- riot-openwsn-wip/openwsn/04-TRAN/opencoap.h Thu Apr 24 16:55:54 2014
|
|
***************
|
|
*** 8,13 ****
|
|
--- 8,15 ----
|
|
\{
|
|
*/
|
|
|
|
+ #include "opentimers.h"
|
|
+
|
|
//=========================== define ==========================================
|
|
|
|
// IPv6 addresses of servers on the Internet
|
|
***************
|
|
*** 15,26 ****
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x29};
|
|
static const uint8_t ipAddr_motesEecs[] = {0x20, 0x01, 0x04, 0x70, 0x00, 0x66, 0x00, 0x19, \
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02};
|
|
! //static const uint8_t ipAddr_local[] = {0x20, 0x02, 0x80, 0x20, 0x21, 0x47, 0x00, 0x0c, \
|
|
0x10, 0xcb, 0xc6, 0x52, 0x44, 0x17, 0xd4, 0x18};
|
|
// 2607:f140:400:1036:688e:fa3b:444:6211
|
|
//static const uint8_t ipAddr_local[] = {0x26, 0x07, 0xf1, 0x40, 0x04, 0x00, 0x10, 0x36, \
|
|
// 0x68, 0x8e, 0xfa, 0x3b, 0x04, 0x44, 0x62, 0x11};
|
|
!
|
|
static const uint8_t ipAddr_local[] = {0x26, 0x07, 0xf1, 0x40, 0x04, 0x00, 0x10, 0x36, \
|
|
0x4d, 0xcd, 0xab, 0x54, 0x81, 0x99, 0xc1, 0xf7};
|
|
|
|
--- 17,28 ----
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x29};
|
|
static const uint8_t ipAddr_motesEecs[] = {0x20, 0x01, 0x04, 0x70, 0x00, 0x66, 0x00, 0x19, \
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02};
|
|
! /*static const uint8_t ipAddr_local[] = {0x20, 0x02, 0x80, 0x20, 0x21, 0x47, 0x00, 0x0c, \
|
|
0x10, 0xcb, 0xc6, 0x52, 0x44, 0x17, 0xd4, 0x18};
|
|
// 2607:f140:400:1036:688e:fa3b:444:6211
|
|
//static const uint8_t ipAddr_local[] = {0x26, 0x07, 0xf1, 0x40, 0x04, 0x00, 0x10, 0x36, \
|
|
// 0x68, 0x8e, 0xfa, 0x3b, 0x04, 0x44, 0x62, 0x11};
|
|
! */
|
|
static const uint8_t ipAddr_local[] = {0x26, 0x07, 0xf1, 0x40, 0x04, 0x00, 0x10, 0x36, \
|
|
0x4d, 0xcd, 0xab, 0x54, 0x81, 0x99, 0xc1, 0xf7};
|
|
|
|
***************
|
|
*** 28,34 ****
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02};
|
|
|
|
/// the maximum number of options in a RX'ed CoAP message
|
|
! #define MAX_COAP_OPTIONS 3
|
|
|
|
#define COAP_VERSION 1
|
|
|
|
--- 30,36 ----
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02};
|
|
|
|
/// the maximum number of options in a RX'ed CoAP message
|
|
! #define MAX_COAP_OPTIONS 10 //3 before but we want gets with more options
|
|
|
|
#define COAP_VERSION 1
|
|
|
|
***************
|
|
*** 73,95 ****
|
|
} coap_code_t;
|
|
|
|
typedef enum {
|
|
! COAP_OPTION_NONE = 0,
|
|
! COAP_OPTION_CONTENTTYPE = 1,
|
|
! COAP_OPTION_MAXAGE = 2,
|
|
! COAP_OPTION_PROXYURI = 3,
|
|
! COAP_OPTION_ETAG = 4,
|
|
! COAP_OPTION_URIHOST = 5,
|
|
! COAP_OPTION_LOCATIONPATH = 6,
|
|
! COAP_OPTION_URIPORT = 7,
|
|
! COAP_OPTION_LOCATIONQUERY = 8,
|
|
! COAP_OPTION_URIPATH = 9,
|
|
! COAP_OPTION_TOKEN = 11,
|
|
! COAP_OPTION_ACCEPT = 12,
|
|
! COAP_OPTION_IFMATCH = 13,
|
|
! COAP_OPTION_URIQUERY = 15,
|
|
! COAP_OPTION_IFNONEMATCH = 21,
|
|
} coap_option_t;
|
|
|
|
typedef enum {
|
|
COAP_MEDTYPE_TEXTPLAIN = 0,
|
|
COAP_MEDTYPE_APPLINKFORMAT = 40,
|
|
--- 75,99 ----
|
|
} coap_code_t;
|
|
|
|
typedef enum {
|
|
! COAP_OPTION_NONE = 0,
|
|
! COAP_OPTION_NUM_IFMATCH = 1,
|
|
! COAP_OPTION_NUM_URIHOST = 3,
|
|
! COAP_OPTION_NUM_ETAG = 4,
|
|
! COAP_OPTION_NUM_IFNONEMATCH = 5,
|
|
! COAP_OPTION_NUM_URIPORT = 7,
|
|
! COAP_OPTION_NUM_LOCATIONPATH = 8,
|
|
! COAP_OPTION_NUM_URIPATH = 11,
|
|
! COAP_OPTION_NUM_CONTENTFORMAT = 12,
|
|
! COAP_OPTION_NUM_MAXAGE = 14,
|
|
! COAP_OPTION_NUM_URIQUERY = 15,
|
|
! COAP_OPTION_NUM_ACCEPT = 16,
|
|
! COAP_OPTION_NUM_LOCATIONQUERY = 20,
|
|
! COAP_OPTION_NUM_PROXYURI = 35,
|
|
! COAP_OPTION_NUM_PROXYSCHEME = 39,
|
|
} coap_option_t;
|
|
|
|
+
|
|
+
|
|
typedef enum {
|
|
COAP_MEDTYPE_TEXTPLAIN = 0,
|
|
COAP_MEDTYPE_APPLINKFORMAT = 40,
|
|
***************
|
|
*** 104,112 ****
|
|
typedef struct {
|
|
uint8_t Ver;
|
|
coap_type_t T;
|
|
! uint8_t OC;
|
|
coap_code_t Code;
|
|
uint16_t messageID;
|
|
} coap_header_iht;
|
|
|
|
typedef struct {
|
|
--- 108,117 ----
|
|
typedef struct {
|
|
uint8_t Ver;
|
|
coap_type_t T;
|
|
! uint8_t TKL;
|
|
coap_code_t Code;
|
|
uint16_t messageID;
|
|
+ uint8_t token; //this might be an array of 8 as tkl can be 8
|
|
} coap_header_iht;
|
|
|
|
typedef struct {
|
|
***************
|
|
*** 115,125 ****
|
|
uint8_t* pValue;
|
|
} coap_option_iht;
|
|
|
|
! typedef error_t (*callbackRx_t)(OpenQueueEntry_t* msg,
|
|
coap_header_iht* coap_header,
|
|
coap_option_iht* coap_options);
|
|
! typedef void (*callbackTimer_t)(void);
|
|
! typedef void (*callbackSendDone_t)(OpenQueueEntry_t* msg, error_t error);
|
|
|
|
typedef struct coap_resource_desc_t coap_resource_desc_t;
|
|
|
|
--- 120,130 ----
|
|
uint8_t* pValue;
|
|
} coap_option_iht;
|
|
|
|
! typedef owerror_t (*callbackRx_cbt)(OpenQueueEntry_t* msg,
|
|
coap_header_iht* coap_header,
|
|
coap_option_iht* coap_options);
|
|
! typedef void (*callbackSendDone_cbt)(OpenQueueEntry_t* msg,
|
|
! owerror_t error);
|
|
|
|
typedef struct coap_resource_desc_t coap_resource_desc_t;
|
|
|
|
***************
|
|
*** 130,153 ****
|
|
uint8_t* path1val;
|
|
uint8_t componentID;
|
|
uint16_t messageID;
|
|
! callbackRx_t callbackRx;
|
|
! callbackSendDone_t callbackSendDone;
|
|
coap_resource_desc_t* next;
|
|
};
|
|
|
|
! //=========================== variables =======================================
|
|
|
|
//=========================== prototypes ======================================
|
|
|
|
// from stack
|
|
! void opencoap_init();
|
|
void opencoap_receive(OpenQueueEntry_t* msg);
|
|
! void opencoap_sendDone(OpenQueueEntry_t* msg, error_t error);
|
|
|
|
// from CoAP resources
|
|
void opencoap_writeLinks(OpenQueueEntry_t* msg);
|
|
void opencoap_register(coap_resource_desc_t* desc);
|
|
! error_t opencoap_send(OpenQueueEntry_t* msg,
|
|
coap_type_t type,
|
|
coap_code_t code,
|
|
uint8_t numOptions,
|
|
--- 135,167 ----
|
|
uint8_t* path1val;
|
|
uint8_t componentID;
|
|
uint16_t messageID;
|
|
! uint8_t token; //should be 8bytes
|
|
! callbackRx_cbt callbackRx;
|
|
! callbackSendDone_cbt callbackSendDone;
|
|
coap_resource_desc_t* next;
|
|
};
|
|
|
|
! //=========================== module variables ================================
|
|
!
|
|
! typedef struct {
|
|
! coap_resource_desc_t* resources;
|
|
! bool busySending;
|
|
! uint8_t delayCounter;
|
|
! uint16_t messageID;
|
|
! opentimer_id_t timerId;
|
|
! } opencoap_vars_t;
|
|
|
|
//=========================== prototypes ======================================
|
|
|
|
// from stack
|
|
! void opencoap_init(void);
|
|
void opencoap_receive(OpenQueueEntry_t* msg);
|
|
! void opencoap_sendDone(OpenQueueEntry_t* msg, owerror_t error);
|
|
|
|
// from CoAP resources
|
|
void opencoap_writeLinks(OpenQueueEntry_t* msg);
|
|
void opencoap_register(coap_resource_desc_t* desc);
|
|
! owerror_t opencoap_send(OpenQueueEntry_t* msg,
|
|
coap_type_t type,
|
|
coap_code_t code,
|
|
uint8_t numOptions,
|