Exercises in .NET Development Code 128 in .NET Exercises

Exercises generate, create none none for none projects iPhone 1. Port the anti none for none -theft application to a different platform than the micaz, by writing new theft detection code tailored to the particular sensors you have available. 2.

Extend the anti-theft application so that motes notice the theft reports sent by neighboring motes and report them locally by blinking LED 1. 3. Extend the anti-theft application so that the user can select between the light-level (DarkC) and acceleration (MovingC) theft detection methods, and switch the LED 0 blinking on or off.

4. Add code to FlashSampler to transfer samples and sample summaries to the PC over the serial port. Allow the user to (re)request speci c sample summaries or erase all the summaries.

. Mote-PC communication This chapter sho none none ws how to build a PC application that talks to motes. As we saw in Section 6.4, a PC typically interacts with a mote network by exchanging packets with a distinguished base station mote (occasionally, several motes) over a serial connection (Figure 6.

2, page 95). The PC code in this chapter is written in Java, using the Java libraries and tools distributed with TinyOS. TinyOS also includes libraries and tool support for other languages (e.

g. C). Please refer to the TinyOS documentation for more information on these other languages.

The TinyOS Java code for communicating with motes is found under the net.tinyos package..

Basics At the most basi none for none c level, PCs and motes exchange packets that are simply sequences of bytes, using a protocol inspired by, but not identical to, RFC 1663 [24] (more details on the protocol can be found in TEP 113 [7]). This packet exchange is not fully reliable: the integrity of packets is ensured by the use of a CRC, but invalid packets are simply dropped. Furthermore:.

Packets sent from a PC to a mote are acknowledged by the mote (but there is no retry if no acknowledg none none e is received) this prevents the PC from overloading the mote with packets. Packets sent from a mote to a PC are not acknowledged. While it is possible to write mote communication code by reading and writing the raw bytes in packets, this approach is tedious and error-prone.

Furthermore, any changes to the packet layout (e.g. adding a new eld, changing the value of a constant used in the packets) requires corresponding changes throughout the code.

These problems are avoided on motes by using nesC s external types (Section 3.5.3) to specify packet layouts, and named constants to specify values.

Two tools, mig and ncg, allow these packet layouts and constants to be used in PC programs: mig (for message interface generator ) generates code to encode and decode a byte array whose layout is speci ed by a nesC external type, and ncg (for nesC constant generator ) extracts named constants from a nesC program. Both tools generate code for multiple languages, including Java..

7.1 Basics Serial communication stack Like the radio s tack (Section 6.3), the TinyOS serial stack follows a layered structure (Figure 6.1, page 89).

The lowest level of the TinyOS serial communication stack is de ned in TEP 113, and deals with the exchange of packets over an unreliable serial connection. Like radio packets, these are (in most cases) active message packets. In the rest of this chapter, we will use message to mean the payload of a serial AM packet, with different message types identi er by their AM type.

The layout of serial AM packets is de ned using external types:. typedef nx_struc none none t serial_header { n x _ u i n t 1 6 _ t dest ; /* p a c k e t d e s t i n a t i o n */ n x _ u i n t 1 6 _ t src ; /* p a c k e t s e n d e r */ n x _ u i n t 8 _ t l e n g t h ; /* p a y l o a d length , in b y t e s */ nx_uint8_t group ; /* i d e n t i f i e s a s p e c i f i c s e n s o r n e t w o r k */ n x _ u i n t 8 _ t type ; /* AM type */ } serial_header_t ; typedef nx_struct serial_packet { serial_header_t header ; n x _ u i n t 8 _ t data []; } serial_packet_t ;.
Copyright © . All rights reserved.