X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tos%2Fchips%2Fcc2420%2Fpacket%2FCC2420PacketP.nc;h=50b138fcf19280a03a228bb5e6d5718cf3663a77;hb=e9bfab607e051bae6afb47b44892ce37541d1b44;hp=0a730484f83c8dcf06837f507b5d3b0cd05d6fd6;hpb=adf1de6c009d13b7b52e68535c63b28f59c97400;p=tinyos-2.x.git diff --git a/tos/chips/cc2420/packet/CC2420PacketP.nc b/tos/chips/cc2420/packet/CC2420PacketP.nc index 0a730484..50b138fc 100644 --- a/tos/chips/cc2420/packet/CC2420PacketP.nc +++ b/tos/chips/cc2420/packet/CC2420PacketP.nc @@ -95,6 +95,21 @@ implementation { return (call CC2420PacketBody.getMetadata( p_msg ))->lqi; } + async command uint8_t CC2420Packet.getNetwork( message_t* p_msg ) { +#if defined(TFRAMES_ENABLED) + return TINYOS_6LOWPAN_NETWORK_ID; +#else + return (call CC2420PacketBody.getHeader( p_msg ))->network; +#endif + } + + async command void CC2420Packet.setNetwork( message_t* p_msg , uint8_t networkId ) { +#if ! defined(TFRAMES_ENABLED) + (call CC2420PacketBody.getHeader( p_msg ))->network = networkId; +#endif + } + + /***************** CC2420PacketBody Commands ****************/ async command cc2420_header_t * ONE CC2420PacketBody.getHeader( message_t* ONE msg ) { return TCAST(cc2420_header_t* ONE, (uint8_t *)msg + offsetof(message_t, data) - sizeof( cc2420_header_t )); @@ -138,10 +153,13 @@ implementation { return call PacketTimeStamp32khz.isValid(msg); } + //timestmap is always represented in 32khz + //28.1 is coefficient difference between T32khz and TMilli on MicaZ async command uint32_t PacketTimeStampMilli.timestamp(message_t* msg) { - int32_t offset = call PacketTimeStamp32khz.timestamp(msg) - call LocalTime32khz.get(); - return (offset >> 5) + call LocalTimeMilli.get(); + int32_t offset = (call LocalTime32khz.get()-call PacketTimeStamp32khz.timestamp(msg)); + offset/=28.1; + return call LocalTimeMilli.get() - offset; } async command void PacketTimeStampMilli.clear(message_t* msg)