From 7aa9f4c0d02a4af51e2bdd168bdc3151931717c4 Mon Sep 17 00:00:00 2001 From: sd Date: Tue, 8 Jan 2013 10:26:12 +0100 Subject: [PATCH 1/3] RF230 Blip2.0 patch --- tos/chips/rf212/RF212RadioP.nc | 23 +- tos/chips/rf230/BareMessageC.nc | 25 ++ tos/chips/rf230/RF230BarePacketP.nc | 37 ++ tos/chips/rf230/RF230RadioC.nc | 14 + tos/chips/rf230/RF230RadioP.nc | 21 +- tos/lib/net/blip/IPAddressP.nc | 8 + tos/lib/net/blip/IPDispatchC.nc | 18 + tos/lib/net/blip/IPDispatchP.nc | 320 +++++++++++++++++- tos/lib/net/blip/Ieee154AddressC.nc | 17 + tos/lib/net/blip/Ieee154AddressP.nc | 27 +- .../net/blip/interfaces/ShortAddressConfig.nc | 6 + tos/platforms/iris/chips/rf230/RadioConfig.h | 4 +- .../chips/bluetooth/RovingNetworksP.nc | 6 +- 13 files changed, 501 insertions(+), 25 deletions(-) create mode 100644 tos/chips/rf230/BareMessageC.nc create mode 100644 tos/chips/rf230/RF230BarePacketP.nc create mode 100644 tos/lib/net/blip/interfaces/ShortAddressConfig.nc diff --git a/tos/chips/rf212/RF212RadioP.nc b/tos/chips/rf212/RF212RadioP.nc index 33da2970e7..951acff101 100644 --- a/tos/chips/rf212/RF212RadioP.nc +++ b/tos/chips/rf212/RF212RadioP.nc @@ -176,7 +176,6 @@ implementation // SHR: BPSK: 40; OQPSK: 10 // phySymbolsPerOctet: BPSK: 8; OQPSK: 2 // plus we add a constant for safety -//TODO: this const seems way too high. I think we can even go with 0... #ifndef SOFTWAREACK_TIMEOUT_PLUS #define SOFTWAREACK_TIMEOUT_PLUS 1000 #endif @@ -282,32 +281,24 @@ implementation /*----------------- RandomCollisionConfig -----------------*/ - -#ifndef RF212_BACKOFF_MIN -#define RF212_BACKOFF_MIN 20 -#endif +// 802.15.4 constants: +// aUnitBackoffPeriod: 20 symbol +// macMinBE:0..5 (8), default 3 +// but we don't care about the standard yet, just converted the rf230 lpl timeouts to SymbolTime base async command uint16_t RandomCollisionConfig.getMinimumBackoff() { - return (uint16_t)(RF212_BACKOFF_MIN * getSymbolTime() * RADIO_ALARM_MICROSEC); + return (uint16_t)(10 * 8 * getSymbolTime() * RADIO_ALARM_MICROSEC); } -#ifndef RF212_BACKOFF_INIT -#define RF212_BACKOFF_INIT 310 -#endif - async command uint16_t RandomCollisionConfig.getInitialBackoff(message_t* msg) { - return (uint16_t)(RF212_BACKOFF_INIT * getSymbolTime() * RADIO_ALARM_MICROSEC); + return (uint16_t)(50 * 8 * getSymbolTime() * RADIO_ALARM_MICROSEC); } - -#ifndef RF212_BACKOFF_CONG -#define RF212_BACKOFF_CONG 140 -#endif async command uint16_t RandomCollisionConfig.getCongestionBackoff(message_t* msg) { - return (uint16_t)(RF212_BACKOFF_CONG * getSymbolTime() * RADIO_ALARM_MICROSEC); + return (uint16_t)(100 * 8 * getSymbolTime() * RADIO_ALARM_MICROSEC); } // 802.15.4 standard: SIFS (no ack requested): 12 symbol; LIFS (ack requested): 40 symbol diff --git a/tos/chips/rf230/BareMessageC.nc b/tos/chips/rf230/BareMessageC.nc new file mode 100644 index 0000000000..86564410a4 --- /dev/null +++ b/tos/chips/rf230/BareMessageC.nc @@ -0,0 +1,25 @@ +configuration BareMessageC +{ + provides + { + interface BareSend; + interface BareReceive; + interface Packet as BarePacket; + interface PacketLink; + interface LowPowerListening; + interface SplitControl as RadioControl; + interface ShortAddressConfig; + } +} +implementation +{ + components RF230RadioC; + + BareSend = RF230RadioC; + BareReceive = RF230RadioC; + BarePacket = RF230RadioC.BarePacket; + PacketLink = RF230RadioC; + LowPowerListening = RF230RadioC; + RadioControl = RF230RadioC.SplitControl; + ShortAddressConfig = RF230RadioC; +} diff --git a/tos/chips/rf230/RF230BarePacketP.nc b/tos/chips/rf230/RF230BarePacketP.nc new file mode 100644 index 0000000000..ecb07cb035 --- /dev/null +++ b/tos/chips/rf230/RF230BarePacketP.nc @@ -0,0 +1,37 @@ +module RF230BarePacketP +{ + provides interface Packet as BarePacket; + uses interface RadioPacket; +} +implementation +{ + command void BarePacket.clear(message_t *msg) + { + call RadioPacket.clear(msg); + } + + command uint8_t BarePacket.payloadLength(message_t *msg) + { + //return call RadioPacket.payloadLength(msg); + return call RadioPacket.payloadLength(msg)+sizeof(rf230_header_t); + } + + command void BarePacket.setPayloadLength(message_t *msg, uint8_t len) + { + //call RadioPacket.setPayloadLength(msg, len); + call RadioPacket.setPayloadLength(msg, len-sizeof(rf230_header_t)); + } + + command uint8_t BarePacket.maxPayloadLength() + { + return call RadioPacket.maxPayloadLength(); + } + + command void *BarePacket.getPayload(message_t *msg, uint8_t len) + { + if (len > call RadioPacket.maxPayloadLength()) + return NULL; + else + return (void*)msg; + } +} diff --git a/tos/chips/rf230/RF230RadioC.nc b/tos/chips/rf230/RF230RadioC.nc index 59042f02a6..b013f0159c 100644 --- a/tos/chips/rf230/RF230RadioC.nc +++ b/tos/chips/rf230/RF230RadioC.nc @@ -56,13 +56,17 @@ configuration RF230RadioC #ifndef TFRAMES_ENABLED interface Ieee154Send; + interface BareSend; interface Receive as Ieee154Receive; + interface BareReceive; interface SendNotifier as Ieee154Notifier; interface Resource as SendResource[uint8_t clint]; interface Ieee154Packet; interface Packet as PacketForIeee154Message; + interface Packet as BarePacket; + interface ShortAddressConfig; #endif interface PacketAcknowledgements; @@ -94,6 +98,15 @@ implementation // -------- RadioP components RF230RadioP as RadioP; + + BareSend = TinyosNetworkLayerC.Ieee154Send; + BareReceive = TinyosNetworkLayerC.Ieee154Receive; + ShortAddressConfig = RadioP; + + components RF230BarePacketP as BarePacketP; + BarePacket = BarePacketP; + BarePacketP.RadioPacket -> RadioDriverLayerC; + #ifdef RADIO_DEBUG components AssertC; @@ -175,6 +188,7 @@ implementation components new Ieee154PacketLayerC(); Ieee154PacketLayerC.SubPacket -> PacketLinkLayerC; + // -------- UniqueLayer Send part (wired twice) components new UniqueLayerC(); diff --git a/tos/chips/rf230/RF230RadioP.nc b/tos/chips/rf230/RF230RadioP.nc index db0e48467e..1f21a2bffe 100644 --- a/tos/chips/rf230/RF230RadioP.nc +++ b/tos/chips/rf230/RF230RadioP.nc @@ -50,6 +50,8 @@ module RF230RadioP interface ActiveMessageConfig; interface DummyConfig; + interface ShortAddressConfig; + #ifdef LOW_POWER_LISTENING interface LowPowerListeningConfig; #endif @@ -78,6 +80,7 @@ implementation async command uint8_t RF230DriverConfig.maxPayloadLength() { return sizeof(rf230packet_header_t) + TOSH_DATA_LENGTH; + } async command uint8_t RF230DriverConfig.metadataLength(message_t* msg) @@ -129,7 +132,7 @@ implementation } #ifndef SOFTWAREACK_TIMEOUT -#define SOFTWAREACK_TIMEOUT 1000 +#define SOFTWAREACK_TIMEOUT 3000//1000 #endif async command uint16_t SoftwareAckConfig.getAckTimeout() @@ -235,6 +238,20 @@ implementation * congestion backoff = 0x7 * CC2420_BACKOFF_PERIOD = 70 jiffies = 2240 microsec */ +/*----------------- ShortAddressConfig-----------------*/ + + command void ShortAddressConfig.setShortAddr(uint16_t address) + { + // TODO: actually write the new ID + signal ShortAddressConfig.setShortAddrDone(FAIL); + } + + default event void ShortAddressConfig.setShortAddrDone(error_t error) + { + } + + /*----------------- LowPowerListening -----------------*/ + #ifndef LOW_POWER_LISTENING #ifndef RF230_BACKOFF_MIN @@ -337,7 +354,7 @@ implementation command uint16_t LowPowerListeningConfig.getListenLength() { - return 5; + return 12;//5 } async command uint16_t RandomCollisionConfig.getMinimumBackoff() diff --git a/tos/lib/net/blip/IPAddressP.nc b/tos/lib/net/blip/IPAddressP.nc index 755c45fb10..2954c132be 100644 --- a/tos/lib/net/blip/IPAddressP.nc +++ b/tos/lib/net/blip/IPAddressP.nc @@ -31,7 +31,15 @@ module IPAddressP { interface Ieee154Address; } } implementation { + +#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) + bool m_valid_addr = FALSE, m_short_addr = TRUE; +#elif defined(PLATFORM_TELOSB) || defined (PLATFORM_EPIC) || defined (PLATFORM_TINYNODE) + bool m_valid_addr = FALSE, m_short_addr = FALSE; +#else bool m_valid_addr = FALSE, m_short_addr = FALSE; +#endif + struct in6_addr m_addr; command bool IPAddress.getLLAddr(struct in6_addr *addr) { diff --git a/tos/lib/net/blip/IPDispatchC.nc b/tos/lib/net/blip/IPDispatchC.nc index 95a61a2c9d..d62454d34c 100644 --- a/tos/lib/net/blip/IPDispatchC.nc +++ b/tos/lib/net/blip/IPDispatchC.nc @@ -40,7 +40,16 @@ configuration IPDispatchC { /* IPDispatchP wiring -- fragment rassembly and lib6lowpan bindings */ components IPDispatchP; + + +#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) + components BareMessageC as MessageC; +#elif defined(PLATFORM_TELOSB) || defined (PLATFORM_EPIC) || defined (PLATFORM_TINYNODE) + components CC2420RadioC as MessageC; +#else components CC2420RadioC as MessageC; +#endif + components ReadLqiC; components new TimerMilliC(); @@ -58,8 +67,17 @@ configuration IPDispatchC { IPDispatchP.RadioControl -> MessageC; IPDispatchP.BarePacket -> MessageC.BarePacket; + +#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) + IPDispatchP.BareSend -> MessageC; + IPDispatchP.BareReceive -> MessageC; +#elif defined(PLATFORM_TELOSB) || defined (PLATFORM_EPIC) || defined (PLATFORM_TINYNODE) + IPDispatchP.Ieee154Send -> MessageC.BareSend; + IPDispatchP.Ieee154Receive -> MessageC.BareReceive; +#else IPDispatchP.Ieee154Send -> MessageC.BareSend; IPDispatchP.Ieee154Receive -> MessageC.BareReceive; +#endif #ifdef LOW_POWER_LISTENING IPDispatchP.LowPowerListening -> MessageC; diff --git a/tos/lib/net/blip/IPDispatchP.nc b/tos/lib/net/blip/IPDispatchP.nc index 628f39a0dd..67851ba5f2 100644 --- a/tos/lib/net/blip/IPDispatchP.nc +++ b/tos/lib/net/blip/IPDispatchP.nc @@ -55,8 +55,17 @@ module IPDispatchP { interface SplitControl as RadioControl; interface Packet as BarePacket; + +#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) + interface BareSend; + interface BareReceive; +#elif defined(PLATFORM_TELOSB) || defined (PLATFORM_EPIC) || defined (PLATFORM_TINYNODE) + interface Send as Ieee154Send; + interface Receive as Ieee154Receive; +#else interface Send as Ieee154Send; interface Receive as Ieee154Receive; +#endif /* context lookup */ interface NeighborDiscovery; @@ -332,6 +341,102 @@ void SENDINFO_DECR(struct send_info *si) { return ret; } +#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) + event message_t *BareReceive.receive(message_t *msg) { + struct packed_lowmsg lowmsg; + struct ieee154_frame_addr frame_address; + uint8_t len = call BarePacket.payloadLength(msg); + void *msg_payload = call BarePacket.getPayload(msg, len); + uint8_t *buf = msg_payload; + + // printf(" -- RECEIVE -- len : %i\n", len); + + BLIP_STATS_INCR(stats.rx_total); + + /* unpack the 802.15.4 address fields */ + buf = unpack_ieee154_hdr(msg_payload, &frame_address); + len -= buf - (uint8_t *)msg_payload; + + /* unpack and 6lowpan headers */ + lowmsg.data = buf; + lowmsg.len = len; + lowmsg.headers = getHeaderBitmap(&lowmsg); + if (lowmsg.headers == LOWMSG_NALP) { + goto fail; + } + + if (hasFrag1Header(&lowmsg) || hasFragNHeader(&lowmsg)) { + // start reassembly + int rv; + struct lowpan_reconstruct *recon; + uint16_t tag, source_key; + + source_key = ieee154_hashaddr(&frame_address.ieee_src); + getFragDgramTag(&lowmsg, &tag); + recon = get_reconstruct(source_key, tag); + if (!recon) { + goto fail; + } + + /* fill in metadata: on fragmented packets, it applies to the + first fragment only */ + memcpy(&recon->r_meta.sender, &frame_address.ieee_src, + sizeof(ieee154_addr_t)); + recon->r_meta.lqi = call ReadLqi.readLqi(msg); + recon->r_meta.rssi = call ReadLqi.readRssi(msg); + + if (hasFrag1Header(&lowmsg)) { + if (recon->r_buf != NULL) goto fail; + rv = lowpan_recon_start(&frame_address, recon, buf, len); + } else { + rv = lowpan_recon_add(recon, buf, len); + } + + if (rv < 0) { + recon->r_timeout = T_FAILED1; + goto fail; + } else { + // printf("start recon buf: %p\n", recon->r_buf); + recon->r_timeout = T_ACTIVE; + recon->r_source_key = source_key; + recon->r_tag = tag; + } + + if (recon->r_size == recon->r_bytes_rcvd) { + deliver(recon); + } + + } else { + /* no fragmentation, just deliver it */ + int rv; + struct lowpan_reconstruct recon; + + /* fill in metadata */ + memcpy(&recon.r_meta.sender, &frame_address.ieee_src, + sizeof(ieee154_addr_t)); + recon.r_meta.lqi = call ReadLqi.readLqi(msg); + recon.r_meta.rssi = call ReadLqi.readRssi(msg); + + buf = getLowpanPayload(&lowmsg); + if ((rv = lowpan_recon_start(&frame_address, &recon, buf, len)) < 0) { + goto fail; + } + + if (recon.r_size == recon.r_bytes_rcvd) { + deliver(&recon); + } else { + // printf("ip_free(%p)\n", recon.r_buf); + ip_free(recon.r_buf); + } + } + goto done; + fail: + BLIP_STATS_INCR(stats.rx_drop); + done: + return msg; + } + +#elif defined(PLATFORM_TELOSB) || defined (PLATFORM_EPIC) || defined (PLATFORM_TINYNODE) event message_t *Ieee154Receive.receive(message_t *msg, void *msg_payload, uint8_t len) { struct packed_lowmsg lowmsg; struct ieee154_frame_addr frame_address; @@ -423,8 +528,99 @@ void SENDINFO_DECR(struct send_info *si) { done: return msg; } +#else + event message_t *Ieee154Receive.receive(message_t *msg, void *msg_payload, uint8_t len) { + struct packed_lowmsg lowmsg; + struct ieee154_frame_addr frame_address; + uint8_t *buf = msg_payload; + + // printf(" -- RECEIVE -- len : %i\n", len); + + BLIP_STATS_INCR(stats.rx_total); + + /* unpack the 802.15.4 address fields */ + buf = unpack_ieee154_hdr(msg_payload, &frame_address); + len -= buf - (uint8_t *)msg_payload; + + /* unpack and 6lowpan headers */ + lowmsg.data = buf; + lowmsg.len = len; + lowmsg.headers = getHeaderBitmap(&lowmsg); + if (lowmsg.headers == LOWMSG_NALP) { + goto fail; + } + + if (hasFrag1Header(&lowmsg) || hasFragNHeader(&lowmsg)) { + // start reassembly + int rv; + struct lowpan_reconstruct *recon; + uint16_t tag, source_key; + + source_key = ieee154_hashaddr(&frame_address.ieee_src); + getFragDgramTag(&lowmsg, &tag); + recon = get_reconstruct(source_key, tag); + if (!recon) { + goto fail; + } + + /* fill in metadata: on fragmented packets, it applies to the + first fragment only */ + memcpy(&recon->r_meta.sender, &frame_address.ieee_src, + sizeof(ieee154_addr_t)); + recon->r_meta.lqi = call ReadLqi.readLqi(msg); + recon->r_meta.rssi = call ReadLqi.readRssi(msg); + + if (hasFrag1Header(&lowmsg)) { + if (recon->r_buf != NULL) goto fail; + rv = lowpan_recon_start(&frame_address, recon, buf, len); + } else { + rv = lowpan_recon_add(recon, buf, len); + } + + if (rv < 0) { + recon->r_timeout = T_FAILED1; + goto fail; + } else { + // printf("start recon buf: %p\n", recon->r_buf); + recon->r_timeout = T_ACTIVE; + recon->r_source_key = source_key; + recon->r_tag = tag; + } + + if (recon->r_size == recon->r_bytes_rcvd) { + deliver(recon); + } + + } else { + /* no fragmentation, just deliver it */ + int rv; + struct lowpan_reconstruct recon; + /* fill in metadata */ + memcpy(&recon.r_meta.sender, &frame_address.ieee_src, + sizeof(ieee154_addr_t)); + recon.r_meta.lqi = call ReadLqi.readLqi(msg); + recon.r_meta.rssi = call ReadLqi.readRssi(msg); + + buf = getLowpanPayload(&lowmsg); + if ((rv = lowpan_recon_start(&frame_address, &recon, buf, len)) < 0) { + goto fail; + } + if (recon.r_size == recon.r_bytes_rcvd) { + deliver(&recon); + } else { + // printf("ip_free(%p)\n", recon.r_buf); + ip_free(recon.r_buf); + } + } + goto done; + fail: + BLIP_STATS_INCR(stats.rx_drop); + done: + return msg; + } +#endif /* * Send-side functionality */ @@ -448,6 +644,24 @@ void SENDINFO_DECR(struct send_info *si) { goto fail; } +#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) + if (call BareSend.send(s_entry->msg) != SUCCESS) { + dbg("Drops", "drops: sendTask: send failed\n"); + goto fail; + } else { + radioBusy = TRUE; + } + +#elif defined(PLATFORM_TELOSB) || defined (PLATFORM_EPIC) || defined (PLATFORM_TINYNODE) + if ((call Ieee154Send.send(s_entry->msg, + call BarePacket.payloadLength(s_entry->msg))) != SUCCESS) { + dbg("Drops", "drops: sendTask: send failed\n"); + goto fail; + } else { + radioBusy = TRUE; + } + +#else if ((call Ieee154Send.send(s_entry->msg, call BarePacket.payloadLength(s_entry->msg))) != SUCCESS) { dbg("Drops", "drops: sendTask: send failed\n"); @@ -456,6 +670,8 @@ void SENDINFO_DECR(struct send_info *si) { radioBusy = TRUE; } +#endif + return; fail: printf("SEND FAIL\n"); @@ -491,6 +707,9 @@ void SENDINFO_DECR(struct send_info *si) { struct send_entry *s_entry; message_t *outgoing; +//#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) + uint8_t max_len; +//#endif int frag_len = 1; error_t rc = SUCCESS; @@ -530,11 +749,28 @@ void SENDINFO_DECR(struct send_info *si) { } call BarePacket.clear(outgoing); - frag_len = lowpan_frag_get(call Ieee154Send.getPayload(outgoing, 0), +#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) + max_len = call BarePacket.maxPayloadLength()-1; + frag_len = lowpan_frag_get(call BarePacket.getPayload(outgoing, max_len), + max_len, + msg, + frame_addr, + &ctx); +#elif defined(PLATFORM_TELOSB) || defined (PLATFORM_EPIC) || defined (PLATFORM_TINYNODE) + max_len = call BarePacket.maxPayloadLength();//TEST############ + frag_len = lowpan_frag_get(call Ieee154Send.getPayload(outgoing, max_len),//max_len statt 0################## + call BarePacket.maxPayloadLength(), //TEST################ + msg, + frame_addr, + &ctx); +#else +frag_len = lowpan_frag_get(call Ieee154Send.getPayload(outgoing, 0), call BarePacket.maxPayloadLength(), msg, frame_addr, &ctx); +#endif + if (frag_len < 0) { printf(" get frag error: %i\n", frag_len); } @@ -578,7 +814,47 @@ void SENDINFO_DECR(struct send_info *si) { cleanup_outer: return rc; } +#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) + event void BareSend.sendDone(message_t *msg, error_t error) { + struct send_entry *s_entry = call SendQueue.head(); + radioBusy = FALSE; + + // printf("sendDone: %p %i\n", msg, error); + + if (state == S_STOPPING) { + call RadioControl.stop(); + state = S_STOPPED; + goto done; + } + + s_entry->info->link_transmissions += (call PacketLink.getRetries(msg)); + s_entry->info->link_fragment_attempts++; + + if (!call PacketLink.wasDelivered(msg)) { + printf("sendDone: was not delivered! (%i tries)\n", + call PacketLink.getRetries(msg)); + s_entry->info->failed = TRUE; + signal IPLower.sendDone(s_entry->info); +/* if (s_entry->info->policy.dest[0] != 0xffff) */ +/* dbg("Drops", "drops: sendDone: frag was not delivered\n"); */ + // need to check for broadcast frames + // BLIP_STATS_INCR(stats.tx_drop); + } else if (s_entry->info->link_fragment_attempts == + s_entry->info->link_fragments) { + signal IPLower.sendDone(s_entry->info); + } + + done: + // kill off any pending fragments + SENDINFO_DECR(s_entry->info); + call FragPool.put(s_entry->msg); + call SendEntryPool.put(s_entry); + call SendQueue.dequeue(); + + post sendTask(); + } +#elif defined(PLATFORM_TELOSB) || defined (PLATFORM_EPIC) || defined (PLATFORM_TINYNODE) event void Ieee154Send.sendDone(message_t *msg, error_t error) { struct send_entry *s_entry = call SendQueue.head(); @@ -619,6 +895,47 @@ void SENDINFO_DECR(struct send_info *si) { post sendTask(); } +#else + event void Ieee154Send.sendDone(message_t *msg, error_t error) { + struct send_entry *s_entry = call SendQueue.head(); + + radioBusy = FALSE; + + // printf("sendDone: %p %i\n", msg, error); + + if (state == S_STOPPING) { + call RadioControl.stop(); + state = S_STOPPED; + goto done; + } + + s_entry->info->link_transmissions += (call PacketLink.getRetries(msg)); + s_entry->info->link_fragment_attempts++; + + if (!call PacketLink.wasDelivered(msg)) { + printf("sendDone: was not delivered! (%i tries)\n", + call PacketLink.getRetries(msg)); + s_entry->info->failed = TRUE; + signal IPLower.sendDone(s_entry->info); +/* if (s_entry->info->policy.dest[0] != 0xffff) */ +/* dbg("Drops", "drops: sendDone: frag was not delivered\n"); */ + // need to check for broadcast frames + // BLIP_STATS_INCR(stats.tx_drop); + } else if (s_entry->info->link_fragment_attempts == + s_entry->info->link_fragments) { + signal IPLower.sendDone(s_entry->info); + } + + done: + // kill off any pending fragments + SENDINFO_DECR(s_entry->info); + call FragPool.put(s_entry->msg); + call SendEntryPool.put(s_entry); + call SendQueue.dequeue(); + + post sendTask(); + } +#endif #if 0 command struct tlv_hdr *IPExtensions.findTlv(struct ip6_ext *ext, uint8_t tlv_val) { int len = ext->len - sizeof(struct ip6_ext); @@ -669,3 +986,4 @@ void SENDINFO_DECR(struct send_info *si) { /* struct ip_metadata *meta) { */ /* } */ } + diff --git a/tos/lib/net/blip/Ieee154AddressC.nc b/tos/lib/net/blip/Ieee154AddressC.nc index 74d83eb43d..15343f15d3 100644 --- a/tos/lib/net/blip/Ieee154AddressC.nc +++ b/tos/lib/net/blip/Ieee154AddressC.nc @@ -5,13 +5,30 @@ configuration Ieee154AddressC { } implementation { components Ieee154AddressP; components LocalIeeeEui64C; + +#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) + components BareMessageC; +#endif + components MainC; Ieee154Address = Ieee154AddressP; MainC.SoftwareInit -> Ieee154AddressP; Ieee154AddressP.LocalIeeeEui64 -> LocalIeeeEui64C; +#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) + Ieee154AddressP.ShortAddressConfig -> BareMessageC; + +#elif defined(PLATFORM_TELOSB) || defined (PLATFORM_EPIC) || defined (PLATFORM_TINYNODE) // workaround until the radio stack uses this interface components CC2420ControlC; Ieee154AddressP.CC2420Config -> CC2420ControlC; + +#else + // workaround until the radio stack uses this interface + components CC2420ControlC; + Ieee154AddressP.CC2420Config -> CC2420ControlC; +#endif + + } diff --git a/tos/lib/net/blip/Ieee154AddressP.nc b/tos/lib/net/blip/Ieee154AddressP.nc index 82a58a8b81..6621e20ed4 100644 --- a/tos/lib/net/blip/Ieee154AddressP.nc +++ b/tos/lib/net/blip/Ieee154AddressP.nc @@ -6,7 +6,14 @@ module Ieee154AddressP { } uses { interface LocalIeeeEui64; + +#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) + interface ShortAddressConfig; +#elif defined(PLATFORM_TELOSB) || defined (PLATFORM_EPIC) || defined (PLATFORM_TINYNODE) + interface CC2420Config; +#else interface CC2420Config; +#endif } } implementation { ieee154_saddr_t m_saddr; @@ -40,11 +47,29 @@ module Ieee154AddressP { command error_t Ieee154Address.setShortAddr(ieee154_saddr_t addr) { m_saddr = addr; + +#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) + call ShortAddressConfig.setShortAddr(addr); +#elif defined(PLATFORM_TELOSB) || defined (PLATFORM_EPIC) || defined (PLATFORM_TINYNODE) + call CC2420Config.setShortAddr(addr); + call CC2420Config.sync(); +#else call CC2420Config.setShortAddr(addr); call CC2420Config.sync(); +#endif + + signal Ieee154Address.changed(); return SUCCESS; } - event void CC2420Config.syncDone(error_t err) {} +#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) + event void ShortAddressConfig.setShortAddrDone(error_t error){} +#elif defined(PLATFORM_TELOSB) || defined (PLATFORM_EPIC) || defined (PLATFORM_TINYNODE) + event void CC2420Config.syncDone(error_t err) {} +#else + event void CC2420Config.syncDone(error_t err) {} +#endif + + } diff --git a/tos/lib/net/blip/interfaces/ShortAddressConfig.nc b/tos/lib/net/blip/interfaces/ShortAddressConfig.nc new file mode 100644 index 0000000000..1b8c051abb --- /dev/null +++ b/tos/lib/net/blip/interfaces/ShortAddressConfig.nc @@ -0,0 +1,6 @@ +interface ShortAddressConfig +{ + command void setShortAddr(uint16_t address); + + event void setShortAddrDone(error_t error); +} diff --git a/tos/platforms/iris/chips/rf230/RadioConfig.h b/tos/platforms/iris/chips/rf230/RadioConfig.h index 5ae9ccc75a..8d91f35c61 100644 --- a/tos/platforms/iris/chips/rf230/RadioConfig.h +++ b/tos/platforms/iris/chips/rf230/RadioConfig.h @@ -67,12 +67,12 @@ enum /* This is the default value of the CHANNEL field of the PHY_CC_CCA register. */ #ifndef RF230_DEF_CHANNEL -#define RF230_DEF_CHANNEL 11 +#define RF230_DEF_CHANNEL 13 #endif /* The number of microseconds a sending IRIS mote will wait for an acknowledgement */ #ifndef SOFTWAREACK_TIMEOUT -#define SOFTWAREACK_TIMEOUT 1000 +#define SOFTWAREACK_TIMEOUT 5000 #endif /* diff --git a/tos/platforms/shimmer/chips/bluetooth/RovingNetworksP.nc b/tos/platforms/shimmer/chips/bluetooth/RovingNetworksP.nc index 462a2056f8..1f2891b348 100644 --- a/tos/platforms/shimmer/chips/bluetooth/RovingNetworksP.nc +++ b/tos/platforms/shimmer/chips/bluetooth/RovingNetworksP.nc @@ -147,9 +147,9 @@ implementation { call UARTControl.setUbr(0x08); call UARTControl.setUmctl(0xee); - /* 4000000hz smclk - call UARTControl.setUbr(0x22); - call UARTControl.setUmctl(0xdd); + /* 4mhz smclk + call UARTControl.setUbr(0x23); + call UARTControl.setUmctl(0xd6); */ #endif From eb8eaa2313b6aadd46ca54bc05f63880ff0503d5 Mon Sep 17 00:00:00 2001 From: sd Date: Tue, 8 Jan 2013 11:14:26 +0100 Subject: [PATCH 2/3] RF230 Blip2.0 patch working tree --- apps/BaseStation15.4/Makefile | 8 +- apps/BaseStation15.4/readme.txt | 91 ++++++ apps/BaseStation15.4/seriallisten15-4 | Bin 0 -> 34014 bytes apps/BaseStation15.4/seriallisten15-4.c | 276 ++++++++++++------ apps/BaseStation15.4/seriallisten15-4.o | Bin 0 -> 6840 bytes apps/PppRouter/Makefile | 26 +- apps/PppRouter/PppRouterC.nc | 2 +- apps/UDPEcho/Makefile | 94 +++--- apps/UDPEcho/UDPEchoC.nc | 2 +- apps/UDPEcho/UDPEchoP.nc | 0 apps/tests/tkn154/packetsniffer/app_profile.h | 2 +- 11 files changed, 364 insertions(+), 137 deletions(-) create mode 100644 apps/BaseStation15.4/readme.txt create mode 100755 apps/BaseStation15.4/seriallisten15-4 create mode 100644 apps/BaseStation15.4/seriallisten15-4.o mode change 100644 => 100755 apps/UDPEcho/Makefile mode change 100644 => 100755 apps/UDPEcho/UDPEchoC.nc mode change 100644 => 100755 apps/UDPEcho/UDPEchoP.nc diff --git a/apps/BaseStation15.4/Makefile b/apps/BaseStation15.4/Makefile index c58ce5213c..4bd5457f3b 100644 --- a/apps/BaseStation15.4/Makefile +++ b/apps/BaseStation15.4/Makefile @@ -1,14 +1,14 @@ COMPONENT=BaseStationC -CFLAGS += -DCC2420_NO_ACKNOWLEDGEMENTS +#CFLAGS += -DCC2420_NO_ACKNOWLEDGEMENTS +CFLAGS += -DCC2420_HW_ACKNOWLEDGEMENTS CFLAGS += -DCC2420_NO_ADDRESS_RECOGNITION BUILD_EXTRA_DEPS += seriallisten15-4 CLEAN_EXTRA = seriallisten15-4.o seriallisten15-4 seriallisten15-4: seriallisten15-4.o - gcc -o $@ $< $(TOSDIR)/../support/sdk/c/sf/libmote.a + gcc -o $@ $< $(TOSDIR)/../support/sdk/c/sf/libmote.a -I /usr/msp430/include/ -I /usr/lib/gcc/msp430/4.6.3/include/ -I /usr/include/i386-linux-gnu -I /usr/include/c++/4.6/parallel/ -I /usr/include/i386-linux-gnu/bits/ seriallisten15-4.o: seriallisten15-4.c - gcc -c -o $@ -I$(TOSDIR)/../support/sdk/c/sf -I$(TOSDIR)/lib/serial -I$(TOSDIR)/types $< - + gcc -c -o $@ -I$(TOSDIR)/../support/sdk/c/sf -I$(TOSDIR)/lib/serial -I$(TOSDIR)/types $< -I /usr/msp430/include/ -I /usr/lib/gcc/msp430/4.6.3/include/ -I /usr/include/i386-linux-gnu -I /usr/include/c++/4.6/parallel/ -I /usr/include/i386-linux-gnu/bits/ include $(MAKERULES) diff --git a/apps/BaseStation15.4/readme.txt b/apps/BaseStation15.4/readme.txt new file mode 100644 index 0000000000..bcb3e79ac9 --- /dev/null +++ b/apps/BaseStation15.4/readme.txt @@ -0,0 +1,91 @@ +Sniffer +----------------------------------- + + by Silvia Krug + date 20120921 + + +----------------------------------- +Hardware +----------- + +tmote / telosB Knoten + +----------------------------------- +Software - auf Knoten +----------- + Anwendung: packetsniffer + Pfad: tinyos-2.x/apps/tests/tkn15.4/packetsniffer + + notwendige Einstellungen: + Kanal: in app_profile.h INITAL_RADIO_CHANNEL setzen + + übersetzen mit: + make tmote install, + + = Knoten-ID + +Der Knoten ist in dieser Anwendung passiv und zeichnet alle Pakete auf +der Luftschnittstelle auf. Die Anwendung stellt eine Art Basisstation +bereit, d.h. die Pakete werden über die Serielle Schnittstelle zum +Rechner übertragen. + +----------------------------------- +Software - auf Rechnerseite +----------- + Anwendung: BaseStation15.4 + Pfad: tinyos-2.x/apps/BaseStation15.4 + + übersetzen mit: + make tmote + +Auf Rechnerseite wird ein C-Programm verwendet, das sich im genannten +Ordner befindet. Dieses wurde erweitert, um + + 1) Pakete im Wireshark-Format pcap zu speichern und + 2) die Zusatzinformationen (LQI,RSSI,CRC ok,MAC Header Länge,PHY + Kanal und Zeitstemple) des TKN15.4-Protokolls anzuzeigen + +Das C.Programm wird mit der Anwendung übersetzt und ist anschließend +einsatzbereit. Die Wireshark-Datei wird im gleichen Verzeichnis angelegt. + + Aufruf: + ./seriallisten15-4 iframe 115200 + + = Serielle Schnittstelle an der der Sniffer + angeschlossen ist + + = Datei, in der die Pakete für Wireshark gespeichert + werden + +Fehlermeldungen werden in die Konsole geschrieben. Ggf. ist nach dem +Start des C-Programms ein Reset der Knotens notwendig. + + +----------------------------------- +Auswertung mit Wireshark +----------- + +Die erzeugte Datei kann mit Wireshark geöffnet und analysiert werden. +Der Funkchip der Tmotes schneidet die letzen 2 Byte (CRC des Paketes) ab +und ersetzt sie durch andere Informationen. Damit die Pakete in +Wireshark korrekt angezeigt werden sind folgende Einstellungen +notwendig: + + Unter: Eintstellungen -> Protokolle -> IEEE 802.15.4 + den Haken bei 'TI CC24xx FCS format' setzen + + +Pakete, die mit Blip 1 versendet wurden können aber nicht korrekt +entschlüsselt werden. Ohne weitere Einstellungen werden diese Pakete +ggf. als ZigBee Pakete interpretiert. Um dies zu verhindern sollten die +ZigBee-Protokolle in Wireshark deaktiviert werden. + + Unter: Analyze -> Enabled Protocols + die entsprechenden Haken bei ZigBee entfernen. + +Blip 2 Pakete sollten von der in Wireshark enthaltenen 6LoWPAN Engine +dekodiert werden können. + + + diff --git a/apps/BaseStation15.4/seriallisten15-4 b/apps/BaseStation15.4/seriallisten15-4 new file mode 100755 index 0000000000000000000000000000000000000000..acddfb6acf0e80094437a4c6966c3edd1f136d82 GIT binary patch literal 34014 zcmd6Qdwdkt+5efHNf=1TZXjwDlm!9;LT&^NHwh*ygo_|IL9I(jHf%~rVzNQ75CR*N zb-@NptF4#dwN|mE)t4e54HpS&FL-&;wpi18OA1yhO3}9F_x+wTvl$lrynWxlegh}Z z^*rY}&$-N*nKQF%eKW4tG)>rtOXz}BW5h7?0NZa@l04xRJ;g9FL<|y%U{RLW2puFZ zGB728XCUcF^FYsAXP8WVK{HVXwoCvh#4wpwX9~f@{KBK;X<0&~{mL+zK1U|QC1kmj z0~Ny{9|jrI5ztKZi)Ancktc|)ci8sl zK<@PKBs7_rpY_YCtXPs&SvIP&qN;vnW?gk=u9CrZDW7t~d|;{`w3&{?ylF^`9p&Gd z_=kIjXouTo?Roqy|J%P?bNclS`&jQmNGwCf%IhL2dHJ73`#(4R{Z`V>qc@eUqYvPZ zYyyxp{k9L%@7n|*>4doaL*wWtg=~179NjK<(0-aD1L+ensVe_y99J~b2kIiE1`=vz_In={~5 z5R&)(EkD52k|4%dbefbKqQIh4C9R8T7VVL=OU~Q0cM9`rA|@pEl?2W*t%lhHx&|R8 zB9jo4RWczulZOzKQW_yjPABXkM1Mk42rpqzAuMPEJQXTYLG{mB1AqR zy5j^wRH%S374tYD2F6rEoK$8I!q3@+7vY>kc(D)*2`>@iRzgg$iwQ3kqKpuoK1kS4 zh)Tl#LevmmE<}j%3L#b!4#0Vd&?`hE;XonghEJLu4A3p>4(`bpA{zczS6A1D)=)yn zjR;T2Uc{#3V;Bq{GH*F3MAw+Jh-BB0f8j5)bqx`)6eQZ&j+|XX7||eQoku0j$OhSj zovo5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?#;c!`>g`fw!nfjz#MW*_XGxDz9Ct@`$H z^%f7u$)5vl_ct%52le?Bl)th` zUaG6FsEm`Zi=)2>+HOA&+HYH&oR1yt!wckB4w~ihb52iK^G&KNT^x^-p9H-L{YTZ$ zE&d5Q5ApaG^3wla6j%rCT^UD@i=(H<(Mv${r$|eXm-cGooKJhR93dGsp&Vc4`q@F^HQ2(Ex`E!&b zEqjSLrST2L!4{2|i(-ctSSDz`BFQrw^G^cZig>H?(nXO&pZ+eOzIFcUgDVj}oU{+h zm&eiA%o?f-VY?dMpYZz&=gpeqpHVz_9)3~V?=L!snpWr#l~wzfR#q>;9y56*=`X2Y zDR-b%2CxM!^Xi;2V+95Nin5iUuFkE^DKm+)8|*jg5|dzM0r{8Oj`U{tjBd zpBLG<=B+JRB{wemix%B5d1i4Ts^O5x-ys+NDKlnWH+hDC*7euV_099on|$32A0sJ$ zm%FsC-Y+lGaVdn`=wc zhH|IS`nhl?>jL`;u~QWvOLi)83$`EM>@BOrHau%zo>R^(a!&dJ`|#8jTc?sgAa5V2 zUq0^^4_lwUf46HQV}$b|=UA^XN{#dJo6RQGv$3SbhoJ+Q;e-$}blq*ysM- zdw0G(fnQnY>pk5pwoU9;XQ-mS&VauBHw9s7-Vr-u4fcqa$jdL8YI zAE-Z9c+St>^VjXq6_?djTdgTQJV(gAq;V#BwT>Gm_nm9PG&tal3Fg3vrZt*ZEm|>>?mz}o4KPRx16HRR)_LbM+ pj@P+**#25qRZ;^(wV~=tr#EtDP<{OzwqL&Q #include #include +#include + +#include #include "serialsource.h" +FILE * f; // file handle for capture file +unsigned int snap = 65535; + +typedef struct pcaprec_hdr_s { // header for each packet + unsigned int ts_sec; + unsigned int ts_usec; + unsigned int incl_len; + unsigned int orig_len; +} pcaprec_hdr_t; + +typedef struct pcap_hdr_s { // header for capture file + unsigned int magic_number; + unsigned short version_major; + unsigned short version_minor; + int thiszone; + unsigned int sigfigs; + unsigned int snaplen; + unsigned int network; +} pcap_hdr_t; + + static char *msgs[] = { "unknown_packet_type", "ack_timeout" , @@ -17,11 +41,50 @@ static char *msgs[] = { "unix_error" }; +void capture_global(){ // write file header with values for 802.15.4 - no change needed + pcap_hdr_t globalheader; + + globalheader.magic_number = 0xa1b2c3d4; + globalheader.version_major = 0x0204; + globalheader.version_minor = 0x0204; + globalheader.thiszone = -3600; + globalheader.sigfigs = 0; + globalheader.snaplen = snap; + globalheader.network = 195; + + fwrite(&globalheader, sizeof(globalheader),1,f); + +} + +void capture_packet_header (int wire_len, int org_len){ // write packet header + pcaprec_hdr_t headerpkt; + + struct timeb temps; + ftime(&temps); + + headerpkt.ts_sec = temps.time; + headerpkt.ts_usec = temps.millitm; + headerpkt.incl_len = wire_len; + headerpkt.orig_len = org_len; + + fwrite(&headerpkt, sizeof(headerpkt), 1, f); + +} + void stderr_msg(serial_source_msg problem) { fprintf(stderr, "Note: %s\n", msgs[problem]); } +void sign_handler(int signum){ + switch (signum) { + case SIGINT: + fclose(f); + exit(0); + break; + } +} + enum { TOS_SERIAL_802_15_4_ID = 2, }; @@ -30,8 +93,8 @@ int main(int argc, char **argv) { serial_source src; int iframes = 0; - if (argc != 4) { - fprintf(stderr, "Usage: %s - dump packets from a serial port\n", argv[0]); + if (argc != 5) { + fprintf(stderr, "Usage: %s - dump packets from a serial port\n", argv[0]); exit(2); } @@ -53,13 +116,22 @@ int main(int argc, char **argv) argv[2], argv[3]); exit(1); } + + f=fopen(argv[4],"wb"); // open capture file, name provided by user + capture_global(); // write header + signal(SIGINT, sign_handler); for (;;) { - int len, i, plen; + int len, i, plen, x; short fcf; + int offset_serial = 2; + int offset_meta = 9; + int offset = offset_serial - offset_meta; const unsigned char *packet = read_serial_packet(src, &len); + unsigned char wireshark_packet[len - offset]; int intraPan = 0; + int ack = 0; if (!packet) exit(0); @@ -69,10 +141,19 @@ int main(int argc, char **argv) plen = packet[1]; printf("Received packet of length %i: \n", plen); + if (plen != len) { printf("Packet format error: read packet length (%hhx) is different than expected from frame (%hhx).\n", plen, len); } + for(x=2; x> 10) & 0x3; - short saddr = 0; - long long laddr = 0; - - // 16- and 64-bit destinations have a PAN ID - if (addrLen == 2 || addrLen == 3) { - short destPan = packet[i++] << 8 | packet[i++]; - printf(" Destination PAN: 0x%02hx\n", destPan); - } - - switch (addrLen) { - case 0: - printf(" Destination address: none\n"); - break; - case 1: - printf(" Destination address: invalid? (0x01)\n"); - break; - case 2: - saddr = (packet[i] << 8 | packet[i+1]); - i += 2; - printf(" Destination address: 0x%04hx\n", saddr); - break; - case 3: { - int j; - for (j = 0; j < 8; j++) { - laddr = laddr << 8; - laddr |= packet[i++]; + if (ack != 1) { // no addresses, no payload + { + char addrLen = (fcf >> 10) & 0x3; + short saddr = 0; + long long laddr = 0; + + // 16- and 64-bit destinations have a PAN ID + if (addrLen == 2 || addrLen == 3) { + short destPan = packet[i++] << 8 | packet[i++]; + printf(" Destination PAN: 0x%02hx\n", destPan); } - printf(" Destination address: 0x%016llx\n", laddr); - break; - } - default: - printf(" Destination address: parse serror\n"); - } - } + + switch (addrLen) { + case 0: + printf(" Destination address: none\n"); + break; + case 1: + printf(" Destination address: invalid? (0x01)\n"); + break; + case 2: + saddr = (packet[i] << 8 | packet[i+1]); + i += 2; + printf(" Destination address: 0x%04hx\n", saddr); + break; + case 3: { + int j; + for (j = 0; j < 8; j++) { + laddr = laddr << 8; + laddr |= packet[i++]; + } + printf(" Destination address: 0x%016llx\n", laddr); + break; + } + default: + printf(" Destination address: parse serror\n"); + } + } - { - char addrLen = (fcf >> 14) & 0x3; - short saddr = 0; - long long laddr = 0; - - if (!intraPan) { // Intra-PAN packet - short srcPan = packet[i] << 8 | packet[i+1]; - i += 2; - printf(" Source PAN: 0x%02hx\n", srcPan); - } - - switch (addrLen) { - case 0: - printf(" Source address: none\n"); - break; - case 1: - printf(" Source address: invalid? (0x01)\n"); - break; - case 2: - saddr = (packet[i] << 8 | packet[i + 1]); - i += 2; - printf(" Source address: 0x%04hx\n", saddr); - break; - case 3: { - int j; - for (j = 0; j < 8; j++) { - laddr = laddr << 8; - laddr |= packet[i++]; + { + char addrLen = (fcf >> 14) & 0x3; + short saddr = 0; + long long laddr = 0; + + if (!intraPan) { // Intra-PAN packet + short srcPan = packet[i] << 8 | packet[i+1]; + i += 2; + printf(" Source PAN: 0x%02hx\n", srcPan); } - printf(" Source address: 0x%016llx\n", laddr); - break; - } - default: - printf(" Source address: parse serror\n"); - } - } - if (iframes) { - printf(" I-Frame: %s\n", (packet[i++] == 0x3f)? "yes":"no"); - } + switch (addrLen) { + case 0: + printf(" Source address: none\n"); + break; + case 1: + printf(" Source address: invalid? (0x01)\n"); + break; + case 2: + saddr = (packet[i] << 8 | packet[i + 1]); + i += 2; + printf(" Source address: 0x%04hx\n", saddr); + break; + case 3: { + int j; + for (j = 0; j < 8; j++) { + laddr = laddr << 8; + laddr |= packet[i++]; + } + printf(" Source address: 0x%016llx\n", laddr); + break; + } + default: + printf(" Source address: parse serror\n"); + } + } + + if (iframes) { + printf(" I-Frame: %s\n", (packet[i++] == 0x3f)? "yes":"no"); + } - printf(" AM type: 0x%02hhx\n", packet[i++]); + printf(" AM type: 0x%02hhx\n", packet[i++]); + + if (i >= plen) { + printf("Packet format error: read packet is shorter than expected.\n"); + } + else { + printf(" Payload: "); + for (; i < plen + 2; i++) { // first two bytes of len where skipped by i but are not counted for plen + printf("0x%02hhx ", packet[i]); + } - if (i >= plen) { - printf("Packet format error: read packet is shorter than expected.\n"); + printf("\n\n"); + } } - else { - printf(" Payload: "); - for (; i < plen; i++) { - printf("0x%02hhx ", packet[i]); - } - printf("\n\n"); - putchar('\n'); + + // additional info from tkn15.4 Mac Layer + + printf(" LQI: 0x%02hhx \n", packet[i++]); + printf(" RSSI: 0x%02hhx \n", packet[i++]); + printf(" CRC ok: 0x%02hhx \n", packet[i++]); + printf(" MAC Header length: 0x%02hhx \n", packet[i++]); + printf(" PHY channel: 0x%02hhx \n", packet[i++]); + printf("\n"); + printf(" Timestamp: "); + + while(i < len){ + printf("0x%02hhx ", packet[i++]); } + + printf("\n\n"); + putchar('\n'); + free((void *)packet); } } diff --git a/apps/BaseStation15.4/seriallisten15-4.o b/apps/BaseStation15.4/seriallisten15-4.o new file mode 100644 index 0000000000000000000000000000000000000000..d46ee27dac71c56a082094a3c96baac721a17bb4 GIT binary patch literal 6840 zcma)Ae{2)i9e;KVaj1*aj&7yDc3p!OR^o;>MI}TdG`tq1l%)X|b=u@!>~rE`pWX8v zBoirY1}QfaiA~wcA5^6povO8eWD}zS4`1zU7XJQ8$fwM0b%D~xIzPDq z_1y|;`s&VqF*`f^)+yWgAiwBLY&F&po8sozTDZF*=N2$$lIUT z`uGno4uEUEUE+sHEVpives8|bm-nB@050eb7QNtE79pA|`tr;iEu6vJ>x=O)-#1JD z`epFB(cn*u=DYPH=IP)Y#r;L2M);VPU0Uy5j}|3;T7)%;@zuhr0`E##0fZ%zkl*Ud zjr#L9W9I^pp&j%SHL;WCGJ6+Iek|92j2X>Vbb)-MMg7RcD)_fu>U9CLBKgP$g=e`v z(Sf0*Rtw**9r^`1vqY$N2)L7IPMN1lyg*4U@sl+md44h}X$f31-Lccv9K2$gYHhBIDkrF>jhNqY3`O(2mU*cIsG1TVynSo{g96#!@ z7JPCYKe}fUx-U}TYe#pj&GU&|(QD^t!pTqmMq)z@>e#UWIi%FXceyA^{0Mo>^CJk~ zaz-l{nev;Xm@7}zjK@v>VGhE|0HEsdtCfK!io4-sR zr*9(xb2Rr!b)gYFcWP`^|Nf$0UHA@o(~An*K~6kHa<1~UC_zk|n&tYTq5FUGKu&QMj zsKRj{>Z@{>tMr}=Bjngu_Zbwey}5AGp70@7d*T&LEEI>kJgjP%L>Q=s@MK{Xl-DSv~ z(^j_jAC+qc>?>-T&S=JoS0s3;mEg~i;3>-NLGoVWLqu}@}S`N*;kyvoXn1uC$2lQQzDG1!nuktD6_+~D9Y@?e0Zpw*@I?y$XTN+vj=O! zLw06|k=bF&tOr-Gt-N4nC9thZ$n_s)`U8$l*0Mf0R3uaT=#aV(-+E}c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r5vAFfo%aq=P&QfwhWtpU`)2CXbOEzK=`i^Dvtr)QbjAX6X zI*ZesWeL&Hx17VbLt(;I#?Z4254?!rN>dbCwpD{S*x&LV9G2~v^Wxw3Sj@Kqvcm2z-yA^@27D{&s<*0>2~hUj_E#W z;G)293H)cm&|g_?+j|g{P=j zRN!8L_X&KE=v|EcOw2zo=8p+n6!;y1CkP{sDWcGuCW;RqiH<7bs1vka&{cvq3fd$n e{q`sM7C~DD-6*I8>c!b<74#`V_X>JM(EkHf#rJ&x literal 0 HcmV?d00001 diff --git a/apps/PppRouter/Makefile b/apps/PppRouter/Makefile index 297ff80863..f88d3fb504 100644 --- a/apps/PppRouter/Makefile +++ b/apps/PppRouter/Makefile @@ -1,6 +1,18 @@ COMPONENT=PppRouterC -# PFLAGS += -DENABLE_SPI0_DMA -# PFLAGS += -DCC2420_DEF_CHANNEL=21 +#PFLAGS += -DENABLE_SPI0_DMA +PFLAGS += -DCC2420_DEF_CHANNEL=13 + +#IRIS Software-Ack +CFLAGS+=-DRF230_HARDWARE_ACK +CFLAGS+=-DCC2420_HARDWARE_ACK + +CFLAGS += -DHARDWAREACK +CFLAGS += -DCC2420_HARDWAREACK +CFLAGS += -DRF230_HARDWAREACK + +CFLAGS+=-DCC2420_HW_ACKNOWLEDGEMENTS +CFLAGS+=-DRF230_HW_ACKNOWLEDGEMENTS +#CFLAGS += -DSOFTWAREACK_TIMEOUT=3000 # use rpl PFLAGS += -DRPL_ROUTING -DRPL_STORING_MODE -I$(LOWPAN_ROOT)/tos/lib/net/rpl @@ -20,4 +32,14 @@ PFLAGS += -DIN6_PREFIX=\"fec0::\" # derive short address from the dhcp address assignment, if possible PFLAGS += -DBLIP_DERIVE_SHORTADDRS +# tell the 6lowpan layer to not generate hc-compressed headers +#PFLAGS += -DLIB6LOWPAN_HC_VERSION=-1 + +#LPL FLAGS +#CFLAGS += -DLOW_POWER_LISTENING +#CFLAGS += -DLPL_SLEEP_INTERVAL=512 +#CFLAGS += -DBLIP_L2_RETRIES=2 +#CFLAGS += -DBLIP_L2_DELAY=2048 +#CFLAGS += -DDUTY_ON_TIME=15 + include $(MAKERULES) diff --git a/apps/PppRouter/PppRouterC.nc b/apps/PppRouter/PppRouterC.nc index 4584a50df7..8ceaf9a2ea 100644 --- a/apps/PppRouter/PppRouterC.nc +++ b/apps/PppRouter/PppRouterC.nc @@ -57,7 +57,7 @@ configuration PppRouterC { components UDPShellC; // prints the routing table - components RouteCmdC; + //components RouteCmdC; #ifndef IN6_PREFIX components Dhcp6ClientC; diff --git a/apps/UDPEcho/Makefile b/apps/UDPEcho/Makefile old mode 100644 new mode 100755 index e26d94923e..45d1b218ee --- a/apps/UDPEcho/Makefile +++ b/apps/UDPEcho/Makefile @@ -1,41 +1,53 @@ -COMPONENT=UDPEchoC -# uncomment this for network programming support -# BOOTLOADER=tosboot - -# radio options -# CFLAGS += -DCC2420_DEF_CHANNEL=26 -# CFLAGS += -DRF230_DEF_CHANNEL=26 -# CFLAGS += -DCC2420_DEF_RFPOWER=4 -DENABLE_SPI0_DMA - -# enable dma on the radio -# PFLAGS += -DENABLE_SPI0_DMA - -# you can compile with or without a routing protocol... of course, -# without it, you will only be able to use link-local communication. -PFLAGS += -DRPL_ROUTING -DRPL_STORING_MODE -I$(TOSDIR)/lib/net/rpl -# PFLAGS += -DRPL_OF_MRHOF - -# tell the 6lowpan layer to not generate hc-compressed headers -# PFLAGS += -DLIB6LOWPAN_HC_VERSION=-1 - -# if this is set, motes will send debugging information to the address -# listed. BLIP_STATS causes blip to record statistics. -# you can log this information using the util/Listener.py script -# PFLAGS += -DREPORT_DEST=\"fec0::100\" -DBLIP_STATS - -# if you're using DHCP, set this to try and derive a 16-bit address -# from the IA received from the server. This will work if the server -# gives out addresses from a /112 prefix. If this is not set, blip -# will only use EUI64-based link addresses. If not using DHCP, this -# causes blip to use TOS_NODE_ID as short address. Otherwise the -# EUI will be used in either case. -PFLAGS += -DBLIP_DERIVE_SHORTADDRS - -# this disables dhcp and statically chooses a prefix. the motes form -# their ipv6 address by combining this with TOS_NODE_ID -PFLAGS += -DIN6_PREFIX=\"fec0::\" - -# PFLAGS += -DNEW_PRINTF_SEMANTICS -DPRINTFUART_ENABLED - -include $(MAKERULES) - +COMPONENT=UDPEchoC +# uncomment this for network programming support +# BOOTLOADER=tosboot + +# radio options +CFLAGS += -DCC2420_DEF_CHANNEL=13 +CFLAGS += -DRF230_DEF_CHANNEL=13 +CFLAGS += -DCC2420_DEF_RFPOWER=4 -DENABLE_SPI0_DMA + +#IRIS Software-Ack +CFLAGS+=-DRF230_HARDWARE_ACK +CFLAGS+=-DCC2420_HARDWARE_ACK + +CFLAGS += -DHARDWAREACK +CFLAGS += -DCC2420_HARDWAREACK +#CFLAGS += -DRF230_HARDWAREACK + +CFLAGS+=-DCC2420_HW_ACKNOWLEDGEMENTS +CFLAGS+=-DRF230_HW_ACKNOWLEDGEMENTS +CFLAGS += -DSOFTWAREACK_TIMEOUT=3000 + +# enable dma on the radio +# PFLAGS += -DENABLE_SPI0_DMA + +# you can compile with or without a routing protocol... of course, +# without it, you will only be able to use link-local communication. +PFLAGS += -DRPL_ROUTING -DRPL_STORING_MODE -I$(TOSDIR)/lib/net/rpl +# PFLAGS += -DRPL_OF_MRHOF + +# tell the 6lowpan layer to not generate hc-compressed headers +#PFLAGS += -DLIB6LOWPAN_HC_VERSION=-1 + +# if this is set, motes will send debugging information to the address +# listed. BLIP_STATS causes blip to record statistics. +# you can log this information using the util/Listener.py script +PFLAGS += -DREPORT_DEST=\"fec0::100\" #-DBLIP_STATS -BLIP_STAPS_IP_MEM + +# if you're using DHCP, set this to try and derive a 16-bit address +# from the IA received from the server. This will work if the server +# gives out addresses from a /112 prefix. If this is not set, blip +# will only use EUI64-based link addresses. If not using DHCP, this +# causes blip to use TOS_NODE_ID as short address. Otherwise the +# EUI will be used in either case. +PFLAGS += -DBLIP_DERIVE_SHORTADDRS + +# this disables dhcp and statically chooses a prefix. the motes form +# their ipv6 address by combining this with TOS_NODE_ID +PFLAGS += -DIN6_PREFIX=\"fec0::\" + +# PFLAGS += -DNEW_PRINTF_SEMANTICS -DPRINTFUART_ENABLED + +include $(MAKERULES) + diff --git a/apps/UDPEcho/UDPEchoC.nc b/apps/UDPEcho/UDPEchoC.nc old mode 100644 new mode 100755 index 5e598eedc8..bd8920c314 --- a/apps/UDPEcho/UDPEchoC.nc +++ b/apps/UDPEcho/UDPEchoC.nc @@ -69,7 +69,7 @@ configuration UDPEchoC { components UDPShellC; // prints the routing table - components RouteCmdC; + //components RouteCmdC; #ifndef IN6_PREFIX components DhcpCmdC; #endif diff --git a/apps/UDPEcho/UDPEchoP.nc b/apps/UDPEcho/UDPEchoP.nc old mode 100644 new mode 100755 diff --git a/apps/tests/tkn154/packetsniffer/app_profile.h b/apps/tests/tkn154/packetsniffer/app_profile.h index ab843b10bf..d6f7de2c39 100644 --- a/apps/tests/tkn154/packetsniffer/app_profile.h +++ b/apps/tests/tkn154/packetsniffer/app_profile.h @@ -37,7 +37,7 @@ #define __APP_PROFILE_H enum { - INITAL_RADIO_CHANNEL = 26, // may be changed later via command over serial line + INITAL_RADIO_CHANNEL = 13, // may be changed later via command over serial line RX_QUEUE_SIZE = 10, // max. packets queued after received over radio }; From e8340aa5af84f49004cc914fefccec985cbe7f62 Mon Sep 17 00:00:00 2001 From: Andras Biro Date: Thu, 24 Jan 2013 00:07:25 +0100 Subject: [PATCH 3/3] Ported blip2 rfxlink patch to ucmini --- apps/PppRouter/PppRouterC.nc | 2 +- apps/UDPEcho/UDPEchoC.nc | 2 +- tos/chips/atm128rfa1/radio/BareMessageC.nc | 25 +++++ tos/chips/atm128rfa1/radio/RFA1BarePacketP.nc | 37 +++++++ .../atm128rfa1/radio/RFA1Ieee154MessageC.nc | 98 +++++++++++++++++++ tos/chips/atm128rfa1/radio/RFA1RadioC.nc | 13 +++ tos/chips/atm128rfa1/radio/RFA1RadioP.nc | 16 +++ tos/lib/net/blip/IPAddressP.nc | 2 +- tos/lib/net/blip/IPDispatchC.nc | 4 +- tos/lib/net/blip/IPDispatchP.nc | 10 +- tos/lib/net/blip/Ieee154AddressC.nc | 4 +- tos/lib/net/blip/Ieee154AddressP.nc | 6 +- tos/lib/net/blip/ReadLqiC.nc | 7 +- 13 files changed, 210 insertions(+), 16 deletions(-) create mode 100644 tos/chips/atm128rfa1/radio/BareMessageC.nc create mode 100644 tos/chips/atm128rfa1/radio/RFA1BarePacketP.nc create mode 100644 tos/chips/atm128rfa1/radio/RFA1Ieee154MessageC.nc diff --git a/apps/PppRouter/PppRouterC.nc b/apps/PppRouter/PppRouterC.nc index 8ceaf9a2ea..4584a50df7 100644 --- a/apps/PppRouter/PppRouterC.nc +++ b/apps/PppRouter/PppRouterC.nc @@ -57,7 +57,7 @@ configuration PppRouterC { components UDPShellC; // prints the routing table - //components RouteCmdC; + components RouteCmdC; #ifndef IN6_PREFIX components Dhcp6ClientC; diff --git a/apps/UDPEcho/UDPEchoC.nc b/apps/UDPEcho/UDPEchoC.nc index bd8920c314..5e598eedc8 100755 --- a/apps/UDPEcho/UDPEchoC.nc +++ b/apps/UDPEcho/UDPEchoC.nc @@ -69,7 +69,7 @@ configuration UDPEchoC { components UDPShellC; // prints the routing table - //components RouteCmdC; + components RouteCmdC; #ifndef IN6_PREFIX components DhcpCmdC; #endif diff --git a/tos/chips/atm128rfa1/radio/BareMessageC.nc b/tos/chips/atm128rfa1/radio/BareMessageC.nc new file mode 100644 index 0000000000..1cd59170e8 --- /dev/null +++ b/tos/chips/atm128rfa1/radio/BareMessageC.nc @@ -0,0 +1,25 @@ +configuration BareMessageC +{ + provides + { + interface BareSend; + interface BareReceive; + interface Packet as BarePacket; + interface PacketLink; + interface LowPowerListening; + interface SplitControl as RadioControl; + interface ShortAddressConfig; + } +} +implementation +{ + components RFA1RadioC; + + BareSend = RFA1RadioC; + BareReceive = RFA1RadioC; + BarePacket = RFA1RadioC.BarePacket; + PacketLink = RFA1RadioC; + LowPowerListening = RFA1RadioC; + RadioControl = RFA1RadioC.SplitControl; + ShortAddressConfig = RFA1RadioC; +} diff --git a/tos/chips/atm128rfa1/radio/RFA1BarePacketP.nc b/tos/chips/atm128rfa1/radio/RFA1BarePacketP.nc new file mode 100644 index 0000000000..9ed60e9e99 --- /dev/null +++ b/tos/chips/atm128rfa1/radio/RFA1BarePacketP.nc @@ -0,0 +1,37 @@ +module RFA1BarePacketP +{ + provides interface Packet as BarePacket; + uses interface RadioPacket; +} +implementation +{ + command void BarePacket.clear(message_t *msg) + { + call RadioPacket.clear(msg); + } + + command uint8_t BarePacket.payloadLength(message_t *msg) + { + //return call RadioPacket.payloadLength(msg); + return call RadioPacket.payloadLength(msg)+sizeof(rfa1_header_t); + } + + command void BarePacket.setPayloadLength(message_t *msg, uint8_t len) + { + //call RadioPacket.setPayloadLength(msg, len); + call RadioPacket.setPayloadLength(msg, len-sizeof(rfa1_header_t)); + } + + command uint8_t BarePacket.maxPayloadLength() + { + return call RadioPacket.maxPayloadLength(); + } + + command void *BarePacket.getPayload(message_t *msg, uint8_t len) + { + if (len > call RadioPacket.maxPayloadLength()) + return NULL; + else + return (void*)msg; + } +} diff --git a/tos/chips/atm128rfa1/radio/RFA1Ieee154MessageC.nc b/tos/chips/atm128rfa1/radio/RFA1Ieee154MessageC.nc new file mode 100644 index 0000000000..98e6b6e1df --- /dev/null +++ b/tos/chips/atm128rfa1/radio/RFA1Ieee154MessageC.nc @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2007, Vanderbilt University + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * - Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Author: Miklos Maroti + */ + +#include + +#ifdef TFRAMES_ENABLED +#error "You cannot use Ieee154MessageC with TFRAMES_ENABLED defined" +#endif + +configuration RFA1Ieee154MessageC +{ + provides + { + interface SplitControl; + + interface Ieee154Send; + interface Receive as Ieee154Receive; + interface SendNotifier; + + interface Ieee154Packet; + interface Packet; + interface Resource as SendResource[uint8_t clint]; + + interface PacketAcknowledgements; + interface LowPowerListening; + interface PacketLink; + + interface RadioChannel; + + interface PacketField as PacketLinkQuality; + interface PacketField as PacketTransmitPower; + interface PacketField as PacketRSSI; + + interface LocalTime as LocalTimeRadio; + interface PacketTimeStamp as PacketTimeStampRadio; + interface PacketTimeStamp as PacketTimeStampMilli; + } +} + +implementation +{ + components RFA1RadioC; + + SplitControl = RFA1RadioC; + + Ieee154Send = RFA1RadioC.Ieee154Send; + Ieee154Receive = RFA1RadioC.Ieee154Receive; + SendNotifier = RFA1RadioC.Ieee154Notifier; + + Packet = RFA1RadioC.PacketForIeee154Message; + Ieee154Packet = RFA1RadioC; + SendResource = RFA1RadioC; + + PacketAcknowledgements = RFA1RadioC; + LowPowerListening = RFA1RadioC; + PacketLink = RFA1RadioC; + + RadioChannel = RFA1RadioC; + + PacketLinkQuality = RFA1RadioC.PacketLinkQuality; + PacketTransmitPower = RFA1RadioC.PacketTransmitPower; + PacketRSSI = RFA1RadioC.PacketRSSI; + + LocalTimeRadio = RFA1RadioC; + PacketTimeStampMilli = RFA1RadioC; + PacketTimeStampRadio = RFA1RadioC; +} diff --git a/tos/chips/atm128rfa1/radio/RFA1RadioC.nc b/tos/chips/atm128rfa1/radio/RFA1RadioC.nc index ecd27566a6..1ee1ee8fbb 100644 --- a/tos/chips/atm128rfa1/radio/RFA1RadioC.nc +++ b/tos/chips/atm128rfa1/radio/RFA1RadioC.nc @@ -57,13 +57,17 @@ configuration RFA1RadioC #ifndef TFRAMES_ENABLED interface Ieee154Send; + interface BareSend; interface Receive as Ieee154Receive; + interface BareReceive; interface SendNotifier as Ieee154Notifier; interface Resource as SendResource[uint8_t clint]; interface Ieee154Packet; interface Packet as PacketForIeee154Message; + interface Packet as BarePacket; + interface ShortAddressConfig; #endif interface PacketAcknowledgements; @@ -95,6 +99,15 @@ implementation // -------- RadioP components RFA1RadioP as RadioP; + + BareSend = TinyosNetworkLayerC.Ieee154Send; + BareReceive = TinyosNetworkLayerC.Ieee154Receive; + ShortAddressConfig = RadioP; + + components RFA1BarePacketP as BarePacketP; + BarePacket = BarePacketP; + BarePacketP.RadioPacket -> RadioDriverLayerC; + #ifdef RADIO_DEBUG components AssertC; diff --git a/tos/chips/atm128rfa1/radio/RFA1RadioP.nc b/tos/chips/atm128rfa1/radio/RFA1RadioP.nc index bcc921bcf7..36b4da65b0 100644 --- a/tos/chips/atm128rfa1/radio/RFA1RadioP.nc +++ b/tos/chips/atm128rfa1/radio/RFA1RadioP.nc @@ -51,6 +51,8 @@ module RFA1RadioP interface ActiveMessageConfig; interface DummyConfig; + interface ShortAddressConfig; + #ifdef LOW_POWER_LISTENING interface LowPowerListeningConfig; #endif @@ -230,6 +232,20 @@ implementation * congestion backoff = 0x7 * CC2420_BACKOFF_PERIOD = 70 jiffies = 2240 microsec */ +/*----------------- ShortAddressConfig-----------------*/ + + command void ShortAddressConfig.setShortAddr(uint16_t address) + { + // TODO: actually write the new ID + signal ShortAddressConfig.setShortAddrDone(FAIL); + } + + default event void ShortAddressConfig.setShortAddrDone(error_t error) + { + } + + /*----------------- LowPowerListening -----------------*/ + #ifndef LOW_POWER_LISTENING #ifndef RFA1_BACKOFF_MIN diff --git a/tos/lib/net/blip/IPAddressP.nc b/tos/lib/net/blip/IPAddressP.nc index 2954c132be..304fce9cc7 100644 --- a/tos/lib/net/blip/IPAddressP.nc +++ b/tos/lib/net/blip/IPAddressP.nc @@ -32,7 +32,7 @@ module IPAddressP { } } implementation { -#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) +#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_UCMINI) bool m_valid_addr = FALSE, m_short_addr = TRUE; #elif defined(PLATFORM_TELOSB) || defined (PLATFORM_EPIC) || defined (PLATFORM_TINYNODE) bool m_valid_addr = FALSE, m_short_addr = FALSE; diff --git a/tos/lib/net/blip/IPDispatchC.nc b/tos/lib/net/blip/IPDispatchC.nc index d62454d34c..961f9aab1c 100644 --- a/tos/lib/net/blip/IPDispatchC.nc +++ b/tos/lib/net/blip/IPDispatchC.nc @@ -42,7 +42,7 @@ configuration IPDispatchC { components IPDispatchP; -#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) +#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_UCMINI) components BareMessageC as MessageC; #elif defined(PLATFORM_TELOSB) || defined (PLATFORM_EPIC) || defined (PLATFORM_TINYNODE) components CC2420RadioC as MessageC; @@ -68,7 +68,7 @@ configuration IPDispatchC { IPDispatchP.BarePacket -> MessageC.BarePacket; -#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) +#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_UCMINI) IPDispatchP.BareSend -> MessageC; IPDispatchP.BareReceive -> MessageC; #elif defined(PLATFORM_TELOSB) || defined (PLATFORM_EPIC) || defined (PLATFORM_TINYNODE) diff --git a/tos/lib/net/blip/IPDispatchP.nc b/tos/lib/net/blip/IPDispatchP.nc index 67851ba5f2..02cb409ede 100644 --- a/tos/lib/net/blip/IPDispatchP.nc +++ b/tos/lib/net/blip/IPDispatchP.nc @@ -56,7 +56,7 @@ module IPDispatchP { interface Packet as BarePacket; -#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) +#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_UCMINI) interface BareSend; interface BareReceive; #elif defined(PLATFORM_TELOSB) || defined (PLATFORM_EPIC) || defined (PLATFORM_TINYNODE) @@ -341,7 +341,7 @@ void SENDINFO_DECR(struct send_info *si) { return ret; } -#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) +#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_UCMINI) event message_t *BareReceive.receive(message_t *msg) { struct packed_lowmsg lowmsg; struct ieee154_frame_addr frame_address; @@ -644,7 +644,7 @@ void SENDINFO_DECR(struct send_info *si) { goto fail; } -#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) +#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_UCMINI) if (call BareSend.send(s_entry->msg) != SUCCESS) { dbg("Drops", "drops: sendTask: send failed\n"); goto fail; @@ -749,7 +749,7 @@ void SENDINFO_DECR(struct send_info *si) { } call BarePacket.clear(outgoing); -#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) +#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_UCMINI) max_len = call BarePacket.maxPayloadLength()-1; frag_len = lowpan_frag_get(call BarePacket.getPayload(outgoing, max_len), max_len, @@ -814,7 +814,7 @@ frag_len = lowpan_frag_get(call Ieee154Send.getPayload(outgoing, 0), cleanup_outer: return rc; } -#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) +#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_UCMINI) event void BareSend.sendDone(message_t *msg, error_t error) { struct send_entry *s_entry = call SendQueue.head(); diff --git a/tos/lib/net/blip/Ieee154AddressC.nc b/tos/lib/net/blip/Ieee154AddressC.nc index 15343f15d3..77edf3f980 100644 --- a/tos/lib/net/blip/Ieee154AddressC.nc +++ b/tos/lib/net/blip/Ieee154AddressC.nc @@ -6,7 +6,7 @@ configuration Ieee154AddressC { components Ieee154AddressP; components LocalIeeeEui64C; -#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) +#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_UCMINI) components BareMessageC; #endif @@ -16,7 +16,7 @@ configuration Ieee154AddressC { MainC.SoftwareInit -> Ieee154AddressP; Ieee154AddressP.LocalIeeeEui64 -> LocalIeeeEui64C; -#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) +#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_UCMINI) Ieee154AddressP.ShortAddressConfig -> BareMessageC; #elif defined(PLATFORM_TELOSB) || defined (PLATFORM_EPIC) || defined (PLATFORM_TINYNODE) diff --git a/tos/lib/net/blip/Ieee154AddressP.nc b/tos/lib/net/blip/Ieee154AddressP.nc index 6621e20ed4..e70001286c 100644 --- a/tos/lib/net/blip/Ieee154AddressP.nc +++ b/tos/lib/net/blip/Ieee154AddressP.nc @@ -7,7 +7,7 @@ module Ieee154AddressP { uses { interface LocalIeeeEui64; -#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) +#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_UCMINI) interface ShortAddressConfig; #elif defined(PLATFORM_TELOSB) || defined (PLATFORM_EPIC) || defined (PLATFORM_TINYNODE) interface CC2420Config; @@ -48,7 +48,7 @@ module Ieee154AddressP { command error_t Ieee154Address.setShortAddr(ieee154_saddr_t addr) { m_saddr = addr; -#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) +#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_UCMINI) call ShortAddressConfig.setShortAddr(addr); #elif defined(PLATFORM_TELOSB) || defined (PLATFORM_EPIC) || defined (PLATFORM_TINYNODE) call CC2420Config.setShortAddr(addr); @@ -63,7 +63,7 @@ module Ieee154AddressP { return SUCCESS; } -#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) +#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_UCMINI) event void ShortAddressConfig.setShortAddrDone(error_t error){} #elif defined(PLATFORM_TELOSB) || defined (PLATFORM_EPIC) || defined (PLATFORM_TINYNODE) event void CC2420Config.syncDone(error_t err) {} diff --git a/tos/lib/net/blip/ReadLqiC.nc b/tos/lib/net/blip/ReadLqiC.nc index 3949c209b1..1ab920c2f8 100644 --- a/tos/lib/net/blip/ReadLqiC.nc +++ b/tos/lib/net/blip/ReadLqiC.nc @@ -20,11 +20,16 @@ configuration ReadLqiC { components CC2420ReadLqiC, CC2420PacketC; ReadLqi = CC2420ReadLqiC; CC2420ReadLqiC.CC2420Packet -> CC2420PacketC; -#elif defined(PLATFORM_IRIS) || defined(PLATFORM_MULLE) +#elif defined(PLATFORM_IRIS) || defined(PLATFORM_MULLE) components RF230ReadLqiC, RF230Ieee154MessageC; ReadLqi = RF230ReadLqiC; RF230ReadLqiC.SubLqi -> RF230Ieee154MessageC.PacketLinkQuality; RF230ReadLqiC.SubRssi -> RF230Ieee154MessageC.PacketRSSI; +#elif defined(PLATFORM_UCMINI) + components RF230ReadLqiC, RFA1Ieee154MessageC; + ReadLqi = RF230ReadLqiC; + RF230ReadLqiC.SubLqi -> RFA1Ieee154MessageC.PacketLinkQuality; + RF230ReadLqiC.SubRssi -> RFA1Ieee154MessageC.PacketRSSI; #else #error "No radio support is available for your platform" #endif