X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tos%2Fchips%2Frf2xx%2Frf230%2FRF230ActiveMessageP.nc;h=0b07d1eb5948b8b40a74dd147344b750c8a7a7c7;hb=00e708814493e030803019f2a98f3fe7e707805d;hp=3f1100a20e8af808d4183e52a8f9e7caf9e717e4;hpb=51b365b6cb1df293dac98e285ae4856c2dccba2b;p=tinyos-2.x.git diff --git a/tos/chips/rf2xx/rf230/RF230ActiveMessageP.nc b/tos/chips/rf2xx/rf230/RF230ActiveMessageP.nc index 3f1100a2..0b07d1eb 100644 --- a/tos/chips/rf2xx/rf230/RF230ActiveMessageP.nc +++ b/tos/chips/rf2xx/rf230/RF230ActiveMessageP.nc @@ -37,21 +37,10 @@ module RF230ActiveMessageP interface RandomCollisionConfig; interface SlottedCollisionConfig; interface ActiveMessageConfig; - interface LowpanNetworkConfig; - interface IEEE154MessageConfig; interface DummyConfig; - interface Packet; - - interface PacketData as PacketFlagsMetadata; - interface PacketData as PacketRF230Metadata; - interface PacketData as PacketTimeStampMetadata; - #ifdef LOW_POWER_LISTENING interface LowPowerListeningConfig; -#endif -#ifdef PACKET_LINK - interface PacketData as PacketLinkMetadata; #endif } @@ -59,6 +48,8 @@ module RF230ActiveMessageP { interface IEEE154MessageLayer; interface RadioAlarm; + interface RadioPacket as ActiveMessagePacket; + interface RadioPacket as RF230Packet; interface PacketTimeStamp; } @@ -66,45 +57,30 @@ module RF230ActiveMessageP implementation { - rf230packet_header_t* getHeader(message_t* msg) - { - return (rf230packet_header_t*)(msg->data - sizeof(rf230packet_header_t)); - } - - rf230packet_metadata_t* getMeta(message_t* msg) - { - return (rf230packet_metadata_t*)(msg->metadata); - } /*----------------- RF230DriverConfig -----------------*/ - async command uint8_t RF230DriverConfig.getLength(message_t* msg) + async command uint8_t RF230DriverConfig.headerLength(message_t* msg) { - return call IEEE154MessageLayer.getLength(msg); + return offsetof(message_t, data) - sizeof(rf230packet_header_t); } - async command void RF230DriverConfig.setLength(message_t* msg, uint8_t len) + async command uint8_t RF230DriverConfig.maxPayloadLength() { - call IEEE154MessageLayer.setLength(msg, len); + return sizeof(rf230packet_header_t) + TOSH_DATA_LENGTH; } - async command uint8_t* RF230DriverConfig.getPayload(message_t* msg) + async command uint8_t RF230DriverConfig.metadataLength(message_t* msg) { - return ((uint8_t*)(call IEEE154MessageConfig.getHeader(msg))) + 1; + return 0; } - async command uint8_t RF230DriverConfig.getHeaderLength() + async command uint8_t RF230DriverConfig.headerPreloadLength() { // we need the fcf, dsn, destpan and dest return 7; } - async command uint8_t RF230DriverConfig.getMaxLength() - { - // note, that the ieee154_footer_t is not stored, but we should include it here - return sizeof(rf230packet_header_t) - 1 + TOSH_DATA_LENGTH + sizeof(ieee154_footer_t); - } - async command bool RF230DriverConfig.requiresRssiCca(message_t* msg) { return call IEEE154MessageLayer.isDataFrame(msg); @@ -149,7 +125,9 @@ implementation tasklet_async command void SoftwareAckConfig.reportChannelError() { +#ifdef TRAFFIC_MONITOR signal TrafficMonitorConfig.channelError(); +#endif } /*----------------- UniqueConfig -----------------*/ @@ -171,25 +149,13 @@ implementation tasklet_async command void UniqueConfig.reportChannelError() { +#ifdef TRAFFIC_MONITOR signal TrafficMonitorConfig.channelError(); +#endif } /*----------------- ActiveMessageConfig -----------------*/ - command error_t ActiveMessageConfig.checkPacket(message_t* msg) - { - // the user forgot to call clear, we should return EINVAL - if( ! call IEEE154MessageLayer.isDataFrame(msg) ) - call Packet.clear(msg); - - return SUCCESS; - } - - command activemessage_header_t* ActiveMessageConfig.getHeader(message_t* msg) - { - return &(getHeader(msg)->am); - } - command am_addr_t ActiveMessageConfig.destination(message_t* msg) { return call IEEE154MessageLayer.getDestAddr(msg); @@ -249,7 +215,7 @@ implementation * ack required: 8-16 byte separation, 11 bytes airtime, 5-10 bytes separation */ - uint8_t len = call IEEE154MessageLayer.getLength(msg); + uint8_t len = call RF230Packet.payloadLength(msg); return call IEEE154MessageLayer.getAckRequired(msg) ? len + 6 + 16 + 11 + 10 : len + 6 + 10; } @@ -258,11 +224,6 @@ implementation return call IEEE154MessageLayer.getSrcAddr(msg); } - tasklet_async command void TrafficMonitorConfig.timerTick() - { - signal SlottedCollisionConfig.timerTick(); - } - /*----------------- RandomCollisionConfig -----------------*/ /* @@ -338,37 +299,16 @@ implementation return (uint16_t)(2 * 7 * 32 * RADIO_ALARM_MICROSEC); } - default tasklet_async event void SlottedCollisionConfig.timerTick() { } - /*----------------- Dummy -----------------*/ async command void DummyConfig.nothing() { } -/*----------------- LowpanNetwork -----------------*/ - - command lowpan_header_t* LowpanNetworkConfig.getHeader(message_t* msg) - { - return &(getHeader(msg)->lowpan); - } - -/*----------------- IEEE154Message -----------------*/ - - async command ieee154_header_t* IEEE154MessageConfig.getHeader(message_t* msg) - { - return &(getHeader(msg)->ieee154); - } - /*----------------- LowPowerListening -----------------*/ #ifdef LOW_POWER_LISTENING - async command lpl_metadata_t* LowPowerListeningConfig.metadata(message_t* msg) - { - return &(getMeta(msg)->lpl); - } - async command bool LowPowerListeningConfig.getAckRequired(message_t* msg) { return call IEEE154MessageLayer.getAckRequired(msg); @@ -376,73 +316,4 @@ implementation #endif -/*----------------- Headers and Metadata -----------------*/ - - async command flags_metadata_t* PacketFlagsMetadata.get(message_t* msg) - { - return &(getMeta(msg)->flags); - } - - async command rf230_metadata_t* PacketRF230Metadata.get(message_t* msg) - { - return &(getMeta(msg)->rf230); - } - - async command timestamp_metadata_t* PacketTimeStampMetadata.get(message_t* msg) - { - return &(getMeta(msg)->timestamp); - } - -#ifdef PACKET_LINK - async command link_metadata_t* PacketLinkMetadata.get(message_t* msg) - { - return &(getMeta(msg)->link); - } -#endif - -/*----------------- Packet -----------------*/ - - enum - { - PACKET_LENGTH_INCREASE = - sizeof(rf230packet_header_t) - 1 // the 8-bit length field is not counted - + sizeof(ieee154_footer_t), // the CRC is not stored in memory - }; - - command void Packet.clear(message_t* msg) - { - signal PacketFlagsMetadata.clear(msg); - signal PacketRF230Metadata.clear(msg); - signal PacketTimeStampMetadata.clear(msg); -#ifdef LOW_POWER_LISTENING - signal LowPowerListeningConfig.clear(msg); -#endif -#ifdef PACKET_LINK - signal PacketLinkMetadata.clear(msg); -#endif - call IEEE154MessageLayer.createDataFrame(msg); - } - - command void Packet.setPayloadLength(message_t* msg, uint8_t len) - { - call IEEE154MessageLayer.setLength(msg, len + PACKET_LENGTH_INCREASE); - } - - command uint8_t Packet.payloadLength(message_t* msg) - { - return call IEEE154MessageLayer.getLength(msg) - PACKET_LENGTH_INCREASE; - } - - command uint8_t Packet.maxPayloadLength() - { - return TOSH_DATA_LENGTH; - } - - command void* Packet.getPayload(message_t* msg, uint8_t len) - { - if( len > TOSH_DATA_LENGTH ) - return NULL; - - return msg->data; - } }