mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
152 lines
4.3 KiB
Diff
152 lines
4.3 KiB
Diff
|
*** stock_iot-lab_M3/openwsn/07-App/rex/rex.c Thu Apr 24 11:01:37 2014
|
||
|
--- riot-openwsn-wip/openwsn/07-App/rex/rex.c Thu Apr 24 16:55:54 2014
|
||
|
***************
|
||
|
*** 8,13 ****
|
||
|
--- 8,15 ----
|
||
|
#include "openrandom.h"
|
||
|
#include "scheduler.h"
|
||
|
//#include "ADC_Channel.h"
|
||
|
+ #include "idmanager.h"
|
||
|
+ #include "IEEE802154E.h"
|
||
|
|
||
|
//=========================== defines =========================================
|
||
|
|
||
|
***************
|
||
|
*** 28,40 ****
|
||
|
|
||
|
//=========================== prototypes ======================================
|
||
|
|
||
|
! error_t rex_receive(OpenQueueEntry_t* msg,
|
||
|
coap_header_iht* coap_header,
|
||
|
coap_option_iht* coap_options);
|
||
|
void rex_timer_cb();
|
||
|
void rex_task_cb();
|
||
|
void rex_sendDone(OpenQueueEntry_t* msg,
|
||
|
! error_t error);
|
||
|
|
||
|
//=========================== public ==========================================
|
||
|
|
||
|
--- 30,42 ----
|
||
|
|
||
|
//=========================== prototypes ======================================
|
||
|
|
||
|
! owerror_t rex_receive(OpenQueueEntry_t* msg,
|
||
|
coap_header_iht* coap_header,
|
||
|
coap_option_iht* coap_options);
|
||
|
void rex_timer_cb();
|
||
|
void rex_task_cb();
|
||
|
void rex_sendDone(OpenQueueEntry_t* msg,
|
||
|
! owerror_t error);
|
||
|
|
||
|
//=========================== public ==========================================
|
||
|
|
||
|
***************
|
||
|
*** 58,64 ****
|
||
|
|
||
|
//=========================== private =========================================
|
||
|
|
||
|
! error_t rex_receive(OpenQueueEntry_t* msg,
|
||
|
coap_header_iht* coap_header,
|
||
|
coap_option_iht* coap_options) {
|
||
|
return E_FAIL;
|
||
|
--- 60,66 ----
|
||
|
|
||
|
//=========================== private =========================================
|
||
|
|
||
|
! owerror_t rex_receive(OpenQueueEntry_t* msg,
|
||
|
coap_header_iht* coap_header,
|
||
|
coap_option_iht* coap_options) {
|
||
|
return E_FAIL;
|
||
|
***************
|
||
|
*** 72,78 ****
|
||
|
|
||
|
void rex_task_cb() {
|
||
|
OpenQueueEntry_t* pkt;
|
||
|
! error_t outcome;
|
||
|
uint8_t numOptions;
|
||
|
uint8_t i;
|
||
|
|
||
|
--- 74,80 ----
|
||
|
|
||
|
void rex_task_cb() {
|
||
|
OpenQueueEntry_t* pkt;
|
||
|
! owerror_t outcome;
|
||
|
uint8_t numOptions;
|
||
|
uint8_t i;
|
||
|
|
||
|
***************
|
||
|
*** 82,92 ****
|
||
|
uint16_t avg = 0;
|
||
|
uint8_t N_avg = 10;
|
||
|
|
||
|
! for (int i = 0; i < N_avg; i++)
|
||
|
! {
|
||
|
! //ADC_getvoltage(p_x_int);
|
||
|
!
|
||
|
! sum += x_int;
|
||
|
}
|
||
|
avg = sum/N_avg;
|
||
|
|
||
|
--- 84,102 ----
|
||
|
uint16_t avg = 0;
|
||
|
uint8_t N_avg = 10;
|
||
|
|
||
|
! // don't run if not synch
|
||
|
! if (ieee154e_isSynch() == FALSE) return;
|
||
|
!
|
||
|
! // don't run on dagroot
|
||
|
! if (idmanager_getIsDAGroot()) {
|
||
|
! opentimers_stop(rex_vars.timerId);
|
||
|
! return;
|
||
|
! }
|
||
|
!
|
||
|
!
|
||
|
! for (i = 0; i < N_avg; i++) {
|
||
|
! //ADC_getvoltage(p_x_int);
|
||
|
! sum += x_int;
|
||
|
}
|
||
|
avg = sum/N_avg;
|
||
|
|
||
|
***************
|
||
|
*** 117,128 ****
|
||
|
packetfunctions_reserveHeaderSize(pkt,sizeof(rex_path0)-1);
|
||
|
memcpy(&pkt->payload[0],&rex_path0,sizeof(rex_path0)-1);
|
||
|
packetfunctions_reserveHeaderSize(pkt,1);
|
||
|
! pkt->payload[0] = (COAP_OPTION_LOCATIONPATH-COAP_OPTION_CONTENTTYPE) << 4 |
|
||
|
sizeof(rex_path0)-1;
|
||
|
numOptions++;
|
||
|
// content-type option
|
||
|
packetfunctions_reserveHeaderSize(pkt,2);
|
||
|
! pkt->payload[0] = COAP_OPTION_CONTENTTYPE << 4 |
|
||
|
1;
|
||
|
pkt->payload[1] = COAP_MEDTYPE_APPOCTETSTREAM;
|
||
|
numOptions++;
|
||
|
--- 127,138 ----
|
||
|
packetfunctions_reserveHeaderSize(pkt,sizeof(rex_path0)-1);
|
||
|
memcpy(&pkt->payload[0],&rex_path0,sizeof(rex_path0)-1);
|
||
|
packetfunctions_reserveHeaderSize(pkt,1);
|
||
|
! pkt->payload[0] = (COAP_OPTION_NUM_URIPATH) << 4 |
|
||
|
sizeof(rex_path0)-1;
|
||
|
numOptions++;
|
||
|
// content-type option
|
||
|
packetfunctions_reserveHeaderSize(pkt,2);
|
||
|
! pkt->payload[0] = COAP_OPTION_NUM_CONTENTFORMAT << 4 |
|
||
|
1;
|
||
|
pkt->payload[1] = COAP_MEDTYPE_APPOCTETSTREAM;
|
||
|
numOptions++;
|
||
|
***************
|
||
|
*** 144,149 ****
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
! void rex_sendDone(OpenQueueEntry_t* msg, error_t error) {
|
||
|
openqueue_freePacketBuffer(msg);
|
||
|
}
|
||
|
--- 154,159 ----
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
! void rex_sendDone(OpenQueueEntry_t* msg, owerror_t error) {
|
||
|
openqueue_freePacketBuffer(msg);
|
||
|
}
|