Skip to content

Commit

Permalink
Merge pull request #267 from openwsn-berkeley/develop_FW-492
Browse files Browse the repository at this point in the history
FW-492. SF0 implementation.
  • Loading branch information
changtengfei authored Jul 4, 2016
2 parents ecc7277 + b58b441 commit c9d1698
Show file tree
Hide file tree
Showing 24 changed files with 261 additions and 113 deletions.
6 changes: 6 additions & 0 deletions bsp/boards/python/openwsnmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ static PyObject* OpenMote_getState(OpenMote* self) {
PyObject* tcp_vars;
PyObject* neighbors_vars;
PyObject* sixtop_vars;
PyObject* sf0_vars;
PyObject* schedule_vars;
PyObject* schedule_dbg;
PyObject* ieee154e_vars;
Expand Down Expand Up @@ -135,6 +136,11 @@ static PyObject* OpenMote_getState(OpenMote* self) {
// TODO
PyDict_SetItemString(returnVal, "sixtop_vars", sixtop_vars);

// sf0_vars
sf0_vars = PyDict_New();
// TODO
PyDict_SetItemString(returnVal, "sf0_vars", sf0_vars);

// schedule_vars
schedule_vars = PyDict_New();
// TODO
Expand Down
2 changes: 2 additions & 0 deletions bsp/boards/python/openwsnmodule_obj.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "neighbors_obj.h"
#include "processIE_obj.h"
#include "sixtop_obj.h"
#include "sf0_obj.h"
#include "schedule_obj.h"
#include "icmpv6echo_obj.h"
#include "icmpv6rpl_obj.h"
Expand Down Expand Up @@ -222,6 +223,7 @@ struct OpenMote {
sixtop_vars_t sixtop_vars;
neighbors_vars_t neighbors_vars;
schedule_vars_t schedule_vars;
sf0_vars_t sf0_vars;
// l2a
adaptive_sync_vars_t adaptive_sync_vars;
ieee802154_security_vars_t ieee802154_security_vars;
Expand Down
6 changes: 5 additions & 1 deletion drivers/common/openserial.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "openhdlc.h"
#include "schedule.h"
#include "icmpv6rpl.h"
#include "sf0.h"

//=========================== variables =======================================

Expand Down Expand Up @@ -580,7 +581,7 @@ void openserial_goldenImageCommands(void){
break;
}

sixtop_setHandler(SIX_HANDLER_OTF);
sixtop_setHandler(SIX_HANDLER_SF0);
if (
(
commandId != COMMAND_SET_6P_ADD &&
Expand Down Expand Up @@ -620,6 +621,9 @@ void openserial_goldenImageCommands(void){
}
}
break;
case COMMAND_SET_SF0BANDWIDTH:
sf0_setSelfBandwidth(comandParam_8);
break;
default:
// wrong command ID
break;
Expand Down
3 changes: 2 additions & 1 deletion drivers/common/openserial.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ enum {
COMMAND_SET_6P_CLEAR = 13,
COMMAND_SET_SLOTDURATION = 14,
COMMAND_SET_6PRESPONSE_STATUS = 15,
COMMAND_MAX = 16,
COMMAND_SET_SF0BANDWIDTH = 16,
COMMAND_MAX = 17,
};

//=========================== module variables ================================
Expand Down
2 changes: 1 addition & 1 deletion kernel/scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ typedef enum {
TASKPRIO_TCP_TIMEOUT = 0x05,
TASKPRIO_COAP = 0x06,
TASKPRIO_ADAPTIVE_SYNC = 0x07,
TASKPRIO_OTF = 0x08,
TASKPRIO_SF0 = 0x08,
// tasks trigger by other interrupts
TASKPRIO_BUTTON = 0x09,
TASKPRIO_SIXTOP_TIMEOUT = 0x0a,
Expand Down
1 change: 1 addition & 0 deletions openapps/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ defaultAppsInit = [
'techo',
'uecho',
'rrt',
'uinject',
]

# additional apps the user wants to build
Expand Down
4 changes: 2 additions & 2 deletions openapps/c6t/c6t.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ owerror_t c6t_receive(
break;
}

sixtop_setHandler(SIX_HANDLER_OTF);
sixtop_setHandler(SIX_HANDLER_SF0);
// call sixtop
sixtop_request(
IANA_6TOP_CMD_ADD,
Expand Down Expand Up @@ -118,7 +118,7 @@ owerror_t c6t_receive(
break;
}

sixtop_setHandler(SIX_HANDLER_OTF);
sixtop_setHandler(SIX_HANDLER_SF0);
// call sixtop
sixtop_request(
IANA_6TOP_CMD_DELETE,
Expand Down
5 changes: 2 additions & 3 deletions openapps/openapps.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,5 @@ void openapps_init(void) {
// TCP
techo_init();
// UDP
uecho_init();
//uinject_init();
}
// uecho_init();
}
7 changes: 6 additions & 1 deletion openapps/uinject/uinject.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#include "IEEE802154E.h"
#include "idmanager.h"

#ifdef GOLDEN_IMAGE_ROOT
#define SLOTDURATION 10 // ms
#endif
//=========================== variables =======================================

uinject_vars_t uinject_vars;
Expand All @@ -30,9 +33,11 @@ void uinject_init() {
// clear local variables
memset(&uinject_vars,0,sizeof(uinject_vars_t));

uinject_vars.period = UINJECT_PERIOD_MS;

// start periodic timer
uinject_vars.timerId = opentimers_start(
UINJECT_PERIOD_MS,
uinject_vars.period,
TIMER_PERIODIC,TIME_MS,
uinject_timer_cb
);
Expand Down
2 changes: 1 addition & 1 deletion openapps/uinject/uinject.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
typedef struct {
opentimer_id_t timerId; ///< periodic timer which triggers transmission
uint16_t counter; ///< incrementing counter which is written into the packet
uint16_t period; ///< uinject packet sending period>
} uinject_vars_t;

//=========================== prototypes ======================================

void uinject_init(void);
void uinject_sendDone(OpenQueueEntry_t* msg, owerror_t error);
void uinject_receive(OpenQueueEntry_t* msg);

/**
\}
\}
Expand Down
65 changes: 0 additions & 65 deletions openstack/02b-MAChigh/otf.c

This file was deleted.

10 changes: 0 additions & 10 deletions openstack/02b-MAChigh/otf.dox

This file was deleted.

31 changes: 30 additions & 1 deletion openstack/02b-MAChigh/schedule.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "packetfunctions.h"
#include "sixtop.h"
#include "idmanager.h"
#include "sf0.h"

//=========================== variables =======================================

Expand Down Expand Up @@ -534,6 +535,28 @@ scheduleEntry_t* schedule_getCurrentScheduleEntry(){
return schedule_vars.currentScheduleEntry;
}

//=== from otf
uint8_t schedule_getNumOfSlotsByType(cellType_t type){
uint8_t returnVal;
scheduleEntry_t* scheduleWalker;

INTERRUPT_DECLARATION();
DISABLE_INTERRUPTS();

returnVal = 0;
scheduleWalker = schedule_vars.currentScheduleEntry;
do {
if(type == scheduleWalker->type){
returnVal += 1;
}
scheduleWalker = scheduleWalker->next;
}while(scheduleWalker!=schedule_vars.currentScheduleEntry);

ENABLE_INTERRUPTS();

return returnVal;
}

//=== from IEEE802154E: reading the schedule and updating statistics

void schedule_syncSlotOffset(slotOffset_t targetSlotOffset) {
Expand All @@ -555,7 +578,13 @@ void schedule_advanceSlot() {

INTERRUPT_DECLARATION();
DISABLE_INTERRUPTS();

#ifdef GOLDEN_IMAGE_ROOT
if (schedule_vars.currentScheduleEntry->slotOffset >= ((scheduleEntry_t*)schedule_vars.currentScheduleEntry->next)->slotOffset
) {
// one slotframe has elapsed
sf0_notifyNewSlotframe();
}
#endif
schedule_vars.currentScheduleEntry = schedule_vars.currentScheduleEntry->next;

ENABLE_INTERRUPTS();
Expand Down
5 changes: 3 additions & 2 deletions openstack/02b-MAChigh/schedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
The superframe repears over time and can be arbitrarly long.
*/
#define SLOTFRAME_LENGTH 11 //should be 101
#define SLOTFRAME_LENGTH 101 //should be 101

//draft-ietf-6tisch-minimal-06
#define SCHEDULE_MINIMAL_6TISCH_ACTIVE_CELLS 1
Expand All @@ -39,7 +39,7 @@ The superframe repears over time and can be arbitrarly long.
for seiral port to tranmit data to dagroot.
*/

#define NUMSLOTSOFF 3
#define NUMSLOTSOFF 5

/**
\brief Maximum number of active slots in a superframe.
Expand Down Expand Up @@ -185,6 +185,7 @@ void schedule_removeAllCells(
open_addr_t* previousHop
);
scheduleEntry_t* schedule_getCurrentScheduleEntry(void);
uint8_t schedule_getNumOfSlotsByType(cellType_t type);

// from IEEE802154E
void schedule_syncSlotOffset(slotOffset_t targetSlotOffset);
Expand Down
Loading

0 comments on commit c9d1698

Please sign in to comment.