*** stock_iot-lab_M3/openwsn/openwsn.h Thu Apr 24 11:01:37 2014 --- riot-openwsn-wip/openwsn/openwsn.h Thu Apr 24 16:55:54 2014 *************** *** 12,27 **** #include // needed for uin8_t, uint16_t #include "board_info.h" //=========================== define ========================================== static const uint8_t infoStackName[] = "OpenWSN "; #define OPENWSN_VERSION_MAJOR 1 ! #define OPENWSN_VERSION_MINOR 2 #define OPENWSN_VERSION_PATCH 1 - // enter the last byte of your mote's address if you want it to be an LBR - #define DEBUG_MOTEID_MASTER 0xe8 - #ifndef TRUE #define TRUE 1 #endif --- 12,31 ---- #include // needed for uin8_t, uint16_t #include "board_info.h" + #include + #include "kernel.h" + //========================= prototypes ======================================== + void openwsn_start_thread(void); + //=========================== define ========================================== + #define PRIORITY_OPENWSN PRIORITY_MAIN-1 + static const uint8_t infoStackName[] = "OpenWSN "; #define OPENWSN_VERSION_MAJOR 1 ! #define OPENWSN_VERSION_MINOR 4 #define OPENWSN_VERSION_PATCH 1 #ifndef TRUE #define TRUE 1 #endif *************** *** 51,66 **** }; enum { ! LITTLE_ENDIAN = TRUE, ! BIG_ENDIAN = FALSE, }; // protocol numbers, as defined by the IANA enum { ! IANA_UNDEFINED = 0x00, IANA_TCP = 0x06, IANA_UDP = 0x11, ! IANA_IPv6ROUTE = 43, IANA_ICMPv6 = 0x3a, IANA_ICMPv6_ECHO_REQUEST = 128, IANA_ICMPv6_ECHO_REPLY = 129, --- 55,70 ---- }; enum { ! OW_LITTLE_ENDIAN = TRUE, ! OW_BIG_ENDIAN = FALSE, }; // protocol numbers, as defined by the IANA enum { ! IANA_IPv6HOPOPT = 0x00, IANA_TCP = 0x06, IANA_UDP = 0x11, ! IANA_IPv6ROUTE = 0x2b, IANA_ICMPv6 = 0x3a, IANA_ICMPv6_ECHO_REQUEST = 128, IANA_ICMPv6_ECHO_REPLY = 129, *************** *** 69,79 **** IANA_ICMPv6_RA_PREFIX_INFORMATION = 3, IANA_ICMPv6_RPL = 155, IANA_ICMPv6_RPL_DIO = 0x01, ! IANA_ICMPv6_RPL_DAO = 0x04, IANA_RSVP = 46, }; // well known ports (which we define) enum { //TCP WKP_TCP_HTTP = 80, --- 73,85 ---- IANA_ICMPv6_RA_PREFIX_INFORMATION = 3, IANA_ICMPv6_RPL = 155, IANA_ICMPv6_RPL_DIO = 0x01, ! IANA_ICMPv6_RPL_DAO = 0x02, IANA_RSVP = 46, + IANA_UNDEFINED = 250, //use an unassigned }; // well known ports (which we define) + // warning: first 4 MSB of 2° octect may coincide with previous protocol number enum { //TCP WKP_TCP_HTTP = 80, *************** *** 144,150 **** COMPONENT_ICMPv6ROUTER = 0x14, COMPONENT_ICMPv6RPL = 0x15, //TRAN ! COMPONENT_OPENTCP = 0x16, COMPONENT_OPENUDP = 0x17, COMPONENT_OPENCOAP = 0x18, //App test --- 150,156 ---- COMPONENT_ICMPv6ROUTER = 0x14, COMPONENT_ICMPv6RPL = 0x15, //TRAN ! COMPONENT_OPENTCP = 0x16, COMPONENT_OPENUDP = 0x17, COMPONENT_OPENCOAP = 0x18, //App test *************** *** 173,178 **** --- 179,185 ---- COMPONENT_UDPSTORM = 0x2e, COMPONENT_UDPLATENCY = 0x2f, COMPONENT_TEST = 0x30, + COMPONENT_R6T = 0x31, }; /** *************** *** 188,246 **** ERR_RCVD_ECHO_REPLY = 0x02, // received an echo reply ERR_GETDATA_ASKS_TOO_FEW_BYTES = 0x03, // getData asks for too few bytes, maxNumBytes={0}, fill level={1} ERR_INPUT_BUFFER_OVERFLOW = 0x04, // the input buffer has overflown // l4 ! ERR_WRONG_TRAN_PROTOCOL = 0x05, // unknown transport protocol {0} (code location {1}) ! ERR_WRONG_TCP_STATE = 0x06, // wrong TCP state {0} (code location {1}) ! ERR_TCP_RESET = 0x07, // TCP reset while in state {0} (code location {1}) ! ERR_UNSUPPORTED_PORT_NUMBER = 0x08, // unsupported port number {0} (code location {1}) // l3 ! ERR_UNEXPECTED_DAO = 0x09, // unexpected DAO (code location {0}) ! ERR_UNSUPPORTED_ICMPV6_TYPE = 0x0a, // unsupported ICMPv6 type {0} (code location {1}) ! ERR_6LOWPAN_UNSUPPORTED = 0x0b, // unsupported 6LoWPAN parameter {1} at location {0} ! ERR_NO_NEXTHOP = 0x0c, // no next hop ! ERR_INVALID_PARAM = 0x0d, // invalid parameter ! ERR_INVALID_FWDMODE = 0x0e, // invalid forward mode ! ERR_LARGE_DAGRANK = 0x0f, // large DAGrank {0}, set to {1} ! ERR_HOP_LIMIT_REACHED = 0x10, // packet discarded hop limit reached // l2b ! ERR_NEIGHBORS_FULL = 0x11, // neighbors table is full (max number of neighbor is {0}) ! ERR_NO_SENT_PACKET = 0x12, // there is no sent packet in queue ! ERR_NO_RECEIVED_PACKET = 0x13, // there is no received packet in queue ! ERR_SCHEDULE_OVERFLOWN = 0x14, // schedule overflown // l2a ! ERR_WRONG_CELLTYPE = 0x15, // wrong celltype {0} at slotOffset {1} ! ERR_IEEE154_UNSUPPORTED = 0x16, // unsupported IEEE802.15.4 parameter {1} at location {0} ! ERR_DESYNCHRONIZED = 0x17, // got desynchronized at slotOffset {0} ! ERR_SYNCHRONIZED = 0x18, // synchronized at slotOffset {0} ! ERR_LARGE_TIMECORRECTION = 0x19, // large timeCorr.: {0} ticks (code loc. {1}) ! ERR_WRONG_STATE_IN_ENDFRAME_SYNC = 0x1a, // wrong state {0} in end of frame+sync ! ERR_WRONG_STATE_IN_STARTSLOT = 0x1b, // wrong state {0} in startSlot, at slotOffset {1} ! ERR_WRONG_STATE_IN_TIMERFIRES = 0x1c, // wrong state {0} in timer fires, at slotOffset {1} ! ERR_WRONG_STATE_IN_NEWSLOT = 0x1d, // wrong state {0} in start of frame, at slotOffset {1} ! ERR_WRONG_STATE_IN_ENDOFFRAME = 0x1e, // wrong state {0} in end of frame, at slotOffset {1} ! ERR_MAXTXDATAPREPARE_OVERFLOW = 0x1f, // maxTxDataPrepare overflows while at state {0} in slotOffset {1} ! ERR_MAXRXACKPREPARE_OVERFLOWS = 0x20, // maxRxAckPrepapare overflows while at state {0} in slotOffset {1} ! ERR_MAXRXDATAPREPARE_OVERFLOWS = 0x21, // maxRxDataPrepapre overflows while at state {0} in slotOffset {1} ! ERR_MAXTXACKPREPARE_OVERFLOWS = 0x22, // maxTxAckPrepapre overflows while at state {0} in slotOffset {1} ! ERR_WDDATADURATION_OVERFLOWS = 0x23, // wdDataDuration overflows while at state {0} in slotOffset {1} ! ERR_WDRADIO_OVERFLOWS = 0x24, // wdRadio overflows while at state {0} in slotOffset {1} ! ERR_WDRADIOTX_OVERFLOWS = 0x25, // wdRadioTx overflows while at state {0} in slotOffset {1} ! ERR_WDACKDURATION_OVERFLOWS = 0x26, // wdAckDuration overflows while at state {0} in slotOffset {1} // general ! ERR_BUSY_SENDING = 0x27, // busy sending ! ERR_UNEXPECTED_SENDDONE = 0x28, // sendDone for packet I didn't send ! ERR_NO_FREE_PACKET_BUFFER = 0x29, // no free packet buffer (code location {0}) ! ERR_FREEING_UNUSED = 0x2a, // freeing unused memory ! ERR_FREEING_ERROR = 0x2b, // freeing memory unsupported memory ! ERR_UNSUPPORTED_COMMAND = 0x2c, // unsupported command {0} ! ERR_MSG_UNKNOWN_TYPE = 0x2d, // unknown message type {0} ! ERR_WRONG_ADDR_TYPE = 0x2e, // wrong address type {0} (code location {1}) ! ERR_BRIDGE_MISMATCH = 0x2f, // isBridge mismatch (code location {0}) ! ERR_HEADER_TOO_LONG = 0x30, // header too long, length {1} (code location {0}) ! ERR_INPUTBUFFER_LENGTH = 0x31, // input length problem, length={0} ! ERR_BOOTED = 0x32, // booted ! ERR_INVALIDSERIALFRAME = 0x33, // invalid serial frame ! ERR_INVALIDPACKETFROMRADIO = 0x34, // invalid packet from radio, length {1} (code location {0}) }; //=========================== typedef ========================================= --- 195,258 ---- ERR_RCVD_ECHO_REPLY = 0x02, // received an echo reply ERR_GETDATA_ASKS_TOO_FEW_BYTES = 0x03, // getData asks for too few bytes, maxNumBytes={0}, fill level={1} ERR_INPUT_BUFFER_OVERFLOW = 0x04, // the input buffer has overflown + ERR_COMMAND_NOT_ALLOWED = 0x05, // the command is not allowerd, command = {0} // l4 ! ERR_WRONG_TRAN_PROTOCOL = 0x06, // unknown transport protocol {0} (code location {1}) ! ERR_WRONG_TCP_STATE = 0x07, // wrong TCP state {0} (code location {1}) ! ERR_TCP_RESET = 0x08, // TCP reset while in state {0} (code location {1}) ! ERR_UNSUPPORTED_PORT_NUMBER = 0x09, // unsupported port number {0} (code location {1}) // l3 ! ERR_UNEXPECTED_DAO = 0x0a, // unexpected DAO (code location {0}) ! ERR_UNSUPPORTED_ICMPV6_TYPE = 0x0b, // unsupported ICMPv6 type {0} (code location {1}) ! ERR_6LOWPAN_UNSUPPORTED = 0x0c, // unsupported 6LoWPAN parameter {1} at location {0} ! ERR_NO_NEXTHOP = 0x0d, // no next hop ! ERR_INVALID_PARAM = 0x0e, // invalid parameter ! ERR_INVALID_FWDMODE = 0x0f, // invalid forward mode ! ERR_LARGE_DAGRANK = 0x10, // large DAGrank {0}, set to {1} ! ERR_HOP_LIMIT_REACHED = 0x11, // packet discarded hop limit reached ! ERR_LOOP_DETECTED = 0x12, // loop detected due to previous rank {0} lower than current node rank {1} ! ERR_WRONG_DIRECTION = 0x13, // upstream packet set to be downstream, possible loop. // l2b ! ERR_NEIGHBORS_FULL = 0x14, // neighbors table is full (max number of neighbor is {0}) ! ERR_NO_SENT_PACKET = 0x15, // there is no sent packet in queue ! ERR_NO_RECEIVED_PACKET = 0x16, // there is no received packet in queue ! ERR_SCHEDULE_OVERFLOWN = 0x17, // schedule overflown // l2a ! ERR_WRONG_CELLTYPE = 0x18, // wrong celltype {0} at slotOffset {1} ! ERR_IEEE154_UNSUPPORTED = 0x19, // unsupported IEEE802.15.4 parameter {1} at location {0} ! ERR_DESYNCHRONIZED = 0x1a, // got desynchronized at slotOffset {0} ! ERR_SYNCHRONIZED = 0x1b, // synchronized at slotOffset {0} ! ERR_LARGE_TIMECORRECTION = 0x1c, // large timeCorr.: {0} ticks (code loc. {1}) ! ERR_WRONG_STATE_IN_ENDFRAME_SYNC = 0x1d, // wrong state {0} in end of frame+sync ! ERR_WRONG_STATE_IN_STARTSLOT = 0x1e, // wrong state {0} in startSlot, at slotOffset {1} ! ERR_WRONG_STATE_IN_TIMERFIRES = 0x1f, // wrong state {0} in timer fires, at slotOffset {1} ! ERR_WRONG_STATE_IN_NEWSLOT = 0x20, // wrong state {0} in start of frame, at slotOffset {1} ! ERR_WRONG_STATE_IN_ENDOFFRAME = 0x21, // wrong state {0} in end of frame, at slotOffset {1} ! ERR_MAXTXDATAPREPARE_OVERFLOW = 0x22, // maxTxDataPrepare overflows while at state {0} in slotOffset {1} ! ERR_MAXRXACKPREPARE_OVERFLOWS = 0x23, // maxRxAckPrepapare overflows while at state {0} in slotOffset {1} ! ERR_MAXRXDATAPREPARE_OVERFLOWS = 0x24, // maxRxDataPrepapre overflows while at state {0} in slotOffset {1} ! ERR_MAXTXACKPREPARE_OVERFLOWS = 0x25, // maxTxAckPrepapre overflows while at state {0} in slotOffset {1} ! ERR_WDDATADURATION_OVERFLOWS = 0x26, // wdDataDuration overflows while at state {0} in slotOffset {1} ! ERR_WDRADIO_OVERFLOWS = 0x27, // wdRadio overflows while at state {0} in slotOffset {1} ! ERR_WDRADIOTX_OVERFLOWS = 0x28, // wdRadioTx overflows while at state {0} in slotOffset {1} ! ERR_WDACKDURATION_OVERFLOWS = 0x29, // wdAckDuration overflows while at state {0} in slotOffset {1} // general ! ERR_BUSY_SENDING = 0x2a, // busy sending ! ERR_UNEXPECTED_SENDDONE = 0x2b, // sendDone for packet I didn't send ! ERR_NO_FREE_PACKET_BUFFER = 0x2c, // no free packet buffer (code location {0}) ! ERR_FREEING_UNUSED = 0x2d, // freeing unused memory ! ERR_FREEING_ERROR = 0x2e, // freeing memory unsupported memory ! ERR_UNSUPPORTED_COMMAND = 0x2f, // unsupported command {0} ! ERR_MSG_UNKNOWN_TYPE = 0x30, // unknown message type {0} ! ERR_WRONG_ADDR_TYPE = 0x31, // wrong address type {0} (code location {1}) ! ERR_BRIDGE_MISMATCH = 0x32, // isBridge mismatch (code location {0}) ! ERR_HEADER_TOO_LONG = 0x33, // header too long, length {1} (code location {0}) ! ERR_INPUTBUFFER_LENGTH = 0x34, // input length problem, length={0} ! ERR_BOOTED = 0x35, // booted ! ERR_INVALIDSERIALFRAME = 0x36, // invalid serial frame ! ERR_INVALIDPACKETFROMRADIO = 0x37, // invalid packet frome radio, length {1} (code location {0}) ! ERR_BUSY_RECEIVING = 0x38, // busy receiving when stop of serial activity, buffer input length {1} (code location {0}) ! ERR_WRONG_CRC_INPUT = 0x39, // wrong CRC in input Buffer (input length {0}) }; //=========================== typedef ========================================= *************** *** 245,254 **** //=========================== typedef ========================================= typedef uint16_t errorparameter_t; typedef uint16_t dagrank_t; ! typedef uint8_t error_t; ! #define bool uint8_t PRAGMA(pack(1)); typedef struct { --- 257,267 ---- //=========================== typedef ========================================= + typedef uint16_t errorparameter_t; typedef uint16_t dagrank_t; ! typedef uint8_t owerror_t; ! //#define bool uint8_t PRAGMA(pack(1)); typedef struct { *************** *** 288,294 **** open_addr_t l3_destinationAdd; // 128b IPv6 destination (down stack) open_addr_t l3_sourceAdd; // 128b IPv6 source address //l2 ! error_t l2_sendDoneError; // outcome of trying to send this packet open_addr_t l2_nextORpreviousHop; // 64b IEEE802.15.4 next (down stack) or previous (up) hop address uint8_t l2_frameType; // beacon, data, ack, cmd uint8_t l2_dsn; // sequence number of the received frame --- 301,307 ---- open_addr_t l3_destinationAdd; // 128b IPv6 destination (down stack) open_addr_t l3_sourceAdd; // 128b IPv6 source address //l2 ! owerror_t l2_sendDoneError; // outcome of trying to send this packet open_addr_t l2_nextORpreviousHop; // 64b IEEE802.15.4 next (down stack) or previous (up) hop address uint8_t l2_frameType; // beacon, data, ack, cmd uint8_t l2_dsn; // sequence number of the received frame *************** *** 296,301 **** --- 309,317 ---- uint8_t l2_numTxAttempts; // number Tx attempts asn_t l2_asn; // at what ASN the packet was Tx'ed or Rx'ed uint8_t* l2_payload; // pointer to the start of the payload of l2 (used for MAC to fill in ASN in ADV) + uint8_t* l2_ASNpayload; // pointer to the ASN in EB + uint8_t l2_joinPriority; // the join priority received in EB + bool l2_joinPriorityPresent; //l1 (drivers) uint8_t l1_txPower; // power for packet to Tx at int8_t l1_rssi; // RSSI of received packet *************** *** 309,314 **** //=========================== prototypes ====================================== ! void openwsn_init(); #endif --- 325,330 ---- //=========================== prototypes ====================================== ! extern void openwsn_init(void); #endif