1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/pkg/openwsn/patches/07-App_rreg_rreg.c.patch
2014-05-14 15:06:50 +02:00

182 lines
5.9 KiB
Diff

*** stock_iot-lab_M3/openwsn/07-App/rreg/rreg.c Thu Apr 24 11:01:37 2014
--- riot-openwsn-wip/openwsn/07-App/rreg/rreg.c Thu Apr 24 16:55:54 2014
***************
*** 24,41 ****
//=========================== prototypes ======================================
! error_t rreg_receive(OpenQueueEntry_t* msg,
coap_header_iht* coap_header,
coap_option_iht* coap_options);
void rreg_timer();
void rreg_sendDone(OpenQueueEntry_t* msg,
! error_t error);
uint8_t hexToAscii(uint8_t hex);
//=========================== public ==========================================
void rreg_init() {
! // prepare the resource descriptor for the /.well-known/core path
rreg_vars.desc.path0len = sizeof(rreg_path0)-1;
rreg_vars.desc.path0val = (uint8_t*)(&rreg_path0);
rreg_vars.desc.path1len = 0;
--- 24,44 ----
//=========================== prototypes ======================================
! owerror_t rreg_receive(OpenQueueEntry_t* msg,
coap_header_iht* coap_header,
coap_option_iht* coap_options);
void rreg_timer();
void rreg_sendDone(OpenQueueEntry_t* msg,
! owerror_t error);
uint8_t hexToAscii(uint8_t hex);
//=========================== public ==========================================
void rreg_init() {
! //dagroot does not run upper layers.
! if(idmanager_getIsDAGroot()==TRUE) return;
!
! // prepare the resource descriptor for the /.well-known/core path
rreg_vars.desc.path0len = sizeof(rreg_path0)-1;
rreg_vars.desc.path0val = (uint8_t*)(&rreg_path0);
rreg_vars.desc.path1len = 0;
***************
*** 55,65 ****
//=========================== private =========================================
! error_t rreg_receive(OpenQueueEntry_t* msg,
coap_header_iht* coap_header,
coap_option_iht* coap_options) {
! error_t outcome;
if (coap_header->Code==COAP_CODE_REQ_POST) {
// request to register received
--- 58,68 ----
//=========================== private =========================================
! owerror_t rreg_receive(OpenQueueEntry_t* msg,
coap_header_iht* coap_header,
coap_option_iht* coap_options) {
! owerror_t outcome;
if (coap_header->Code==COAP_CODE_REQ_POST) {
// request to register received
***************
*** 74,81 ****
msg->length = 0;
// set the CoAP header
! coap_header->OC = 0;
! coap_header->Code = COAP_CODE_RESP_VALID;
outcome = E_SUCCESS;
} else if (coap_header->T==COAP_TYPE_ACK) {
--- 77,83 ----
msg->length = 0;
// set the CoAP header
! coap_header->Code = COAP_CODE_RESP_VALID;
outcome = E_SUCCESS;
} else if (coap_header->T==COAP_TYPE_ACK) {
***************
*** 90,96 ****
void rreg_timer() {
OpenQueueEntry_t* pkt;
uint8_t temp8b;
! error_t outcome;
uint8_t numOptions;
--- 92,98 ----
void rreg_timer() {
OpenQueueEntry_t* pkt;
uint8_t temp8b;
! owerror_t outcome;
uint8_t numOptions;
***************
*** 100,106 ****
openserial_printError(COMPONENT_RREG,ERR_NO_FREE_PACKET_BUFFER,
(errorparameter_t)0,
(errorparameter_t)0);
! openqueue_freePacketBuffer(pkt);
return;
}
// take ownership over that packet
--- 102,108 ----
openserial_printError(COMPONENT_RREG,ERR_NO_FREE_PACKET_BUFFER,
(errorparameter_t)0,
(errorparameter_t)0);
! //openqueue_freePacketBuffer(pkt);
return;
}
// take ownership over that packet
***************
*** 116,122 ****
pkt->payload[sizeof(rreg_uriquery)-1] = hexToAscii((temp8b>>4) & 0x0f);
pkt->payload[sizeof(rreg_uriquery)-0] = hexToAscii((temp8b>>0) & 0x0f);
packetfunctions_reserveHeaderSize(pkt,1);
! pkt->payload[0] = (COAP_OPTION_URIQUERY-COAP_OPTION_URIPATH) << 4 |
sizeof(rreg_uriquery)-1+2;
numOptions++;
// URI-path
--- 118,124 ----
pkt->payload[sizeof(rreg_uriquery)-1] = hexToAscii((temp8b>>4) & 0x0f);
pkt->payload[sizeof(rreg_uriquery)-0] = hexToAscii((temp8b>>0) & 0x0f);
packetfunctions_reserveHeaderSize(pkt,1);
! pkt->payload[0] = (COAP_OPTION_NUM_URIQUERY-COAP_OPTION_NUM_URIPATH) << 4 |
sizeof(rreg_uriquery)-1+2;
numOptions++;
// URI-path
***************
*** 124,135 ****
pkt->payload[0] = 'r';
pkt->payload[1] = 'd';
packetfunctions_reserveHeaderSize(pkt,1);
! pkt->payload[0] = (COAP_OPTION_URIPATH-COAP_OPTION_CONTENTTYPE) << 4 |
2;
numOptions++;
// add content-type option
packetfunctions_reserveHeaderSize(pkt,2);
! pkt->payload[0] = COAP_OPTION_CONTENTTYPE << 4 |
1;
pkt->payload[1] = COAP_MEDTYPE_APPLINKFORMAT;
numOptions++;
--- 126,137 ----
pkt->payload[0] = 'r';
pkt->payload[1] = 'd';
packetfunctions_reserveHeaderSize(pkt,1);
! pkt->payload[0] = (COAP_OPTION_NUM_URIPATH) << 4 |
2;
numOptions++;
// add content-type option
packetfunctions_reserveHeaderSize(pkt,2);
! pkt->payload[0] = COAP_OPTION_NUM_CONTENTFORMAT << 4 |
1;
pkt->payload[1] = COAP_MEDTYPE_APPLINKFORMAT;
numOptions++;
***************
*** 151,157 ****
return;
}
! void rreg_sendDone(OpenQueueEntry_t* msg, error_t error) {
openqueue_freePacketBuffer(msg);
}
--- 153,159 ----
return;
}
! void rreg_sendDone(OpenQueueEntry_t* msg, owerror_t error) {
openqueue_freePacketBuffer(msg);
}