Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bsp/boards/python/openwsnmodule_obj.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
// applications
#include "c6t_obj.h"
#include "cexample_obj.h"
#include "cauthz_obj.h"
#include "cjoin_obj.h"
#include "cprotected_obj.h"
#include "cinfo_obj.h"
#include "cleds_obj.h"
#include "cstorm_obj.h"
Expand Down Expand Up @@ -227,6 +229,8 @@ struct OpenMote {
openoscoap_vars_t openoscoap_vars;
c6t_vars_t c6t_vars;
cexample_vars_t cexample_vars;
cauthz_vars_t cauthz_vars;
cprotected_vars_t cprotected_vars;
cinfo_vars_t cinfo_vars;
cleds_vars_t cleds_vars;
cstorm_vars_t cstorm_vars;
Expand Down
2 changes: 2 additions & 0 deletions inc/opendefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ enum {
COMPONENT_CJOIN = 0x27,
COMPONENT_OPENOSCOAP = 0x28,
COMPONENT_CINFRARED = 0x29,
COMPONENT_CAUTHZ = 0x2a,
COMPONENT_CPROTECTED = 0x2b,
};

/**
Expand Down
6 changes: 4 additions & 2 deletions openapps/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ if localEnv['board']=='python':
defaultApps += [
'c6t',
'cinfo',
'cauthz',
'cprotected',
'cleds',
'cwellknown',
'uecho',
Expand All @@ -31,7 +33,7 @@ additionalSourceFiles = [
os.path.join('opencoap','hkdf.c'),
os.path.join('opencoap','hmac.c'),
os.path.join('opencoap','sha224-256.c'),
os.path.join('opencoap','cborencoder.c'),
os.path.join('opencoap','cbor.c'),
os.path.join('cjoin','cojp_cbor.c'),
]

Expand All @@ -40,7 +42,7 @@ additionalSourceFiles = [
additionalHeaderFiles = [
os.path.join('opencoap','openoscoap.h'),
os.path.join('opencoap','sha.h'),
os.path.join('opencoap','cborencoder.h'),
os.path.join('opencoap','cbor.h'),
os.path.join('cjoin','cojp_cbor.h'),
]

Expand Down
38 changes: 20 additions & 18 deletions openapps/c6t/c6t.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ owerror_t c6t_receive(OpenQueueEntry_t* msg,
coap_header_iht* coap_header,
coap_option_iht* coap_incomingOptions,
coap_option_iht* coap_outgoingOptions,
uint8_t* coap_outgoingOptionsLen
uint8_t* coap_outgoingOptionsLen,
bool security
);
void c6t_sendDone(
OpenQueueEntry_t* msg,
Expand All @@ -37,8 +38,8 @@ void c6t_sendDone(
//=========================== public ==========================================

void c6t_init(void) {
if(idmanager_getIsDAGroot()==TRUE) return;
if(idmanager_getIsDAGroot()==TRUE) return;

// prepare the resource descriptor for the /6t path
c6t_vars.desc.path0len = sizeof(c6t_path0)-1;
c6t_vars.desc.path0val = (uint8_t*)(&c6t_path0);
Expand All @@ -49,7 +50,7 @@ void c6t_init(void) {
c6t_vars.desc.discoverable = TRUE;
c6t_vars.desc.callbackRx = &c6t_receive;
c6t_vars.desc.callbackSendDone = &c6t_sendDone;

opencoap_register(&c6t_vars.desc);
}

Expand All @@ -69,31 +70,32 @@ owerror_t c6t_receive(OpenQueueEntry_t* msg,
coap_header_iht* coap_header,
coap_option_iht* coap_incomingOptions,
coap_option_iht* coap_outgoingOptions,
uint8_t* coap_outgoingOptionsLen
uint8_t* coap_outgoingOptionsLen,
bool security
) {
owerror_t outcome;
open_addr_t neighbor;
bool foundNeighbor;
cellInfo_ht celllist_add[CELLLIST_MAX_LEN];
cellInfo_ht celllist_delete[CELLLIST_MAX_LEN];

switch (coap_header->Code) {

case COAP_CODE_REQ_PUT:
// add a slot

// reset packet payload
msg->payload = &(msg->packet[127]);
msg->length = 0;

// get preferred parent
foundNeighbor = icmpv6rpl_getPreferredParentEui64(&neighbor);
if (foundNeighbor==FALSE) {
outcome = E_FAIL;
coap_header->Code = COAP_CODE_RESP_PRECONDFAILED;
break;
}

if (msf_candidateAddCellList(celllist_add,1)==FALSE){
// set the CoAP header
outcome = E_FAIL;
Expand All @@ -112,27 +114,27 @@ owerror_t c6t_receive(OpenQueueEntry_t* msg,
0, // list command offset (not used)
0 // list command maximum celllist (not used)
);

// set the CoAP header
coap_header->Code = COAP_CODE_RESP_CHANGED;

break;

case COAP_CODE_REQ_DELETE:
// delete a slot

// reset packet payload
msg->payload = &(msg->packet[127]);
msg->length = 0;

// get preferred parent
foundNeighbor = icmpv6rpl_getPreferredParentEui64(&neighbor);
if (foundNeighbor==FALSE) {
outcome = E_FAIL;
coap_header->Code = COAP_CODE_RESP_PRECONDFAILED;
break;
}

// call sixtop
if (msf_candidateRemoveCellList(celllist_delete,&neighbor,1)==FALSE){
// set the CoAP header
Expand All @@ -152,16 +154,16 @@ owerror_t c6t_receive(OpenQueueEntry_t* msg,
0, // list command offset (not used)
0 // list command maximum celllist (not used)
);

// set the CoAP header
coap_header->Code = COAP_CODE_RESP_CHANGED;
break;

default:
outcome = E_FAIL;
break;
}

return outcome;
}

Expand Down
Loading