--- /dev/null
+
+import java.io.*;
+import net.tinyos.message.*;
+import net.tinyos.util.*;
+
+public class DipInject implements MessageListener
+{
+ MoteIF mote;
+
+ DipInject(DipMsg dipmsg) {
+ mote = new MoteIF(PrintStreamMessenger.err);
+ mote.registerListener(dipmsg, this);
+ }
+
+ public synchronized void messageReceived(int dest_addr, Message message)
+ {
+ // do nothing for now
+ }
+
+ void sendDipDataMsg(int key, long version, short[] data) {
+ int totalsize = DipMsg.DEFAULT_MESSAGE_SIZE +
+ DipDataMsg.DEFAULT_MESSAGE_SIZE +
+ DipData.DEFAULT_MESSAGE_SIZE;
+ DipMsg dm = new DipMsg(totalsize);
+ dm.set_type((short)3);
+
+ DipDataMsg ddm = new DipDataMsg(dm, DipMsg.DEFAULT_MESSAGE_SIZE);
+ ddm.set_key(key);
+ ddm.set_version(version);
+ ddm.set_size((short)data.length);
+
+ DipData dd = new DipData(ddm, DipDataMsg.DEFAULT_MESSAGE_SIZE);
+ dd.set_data(data);
+
+ try {
+ mote.send(MoteIF.TOS_BCAST_ADDR, dd);
+ }
+ catch(IOException e) {
+ System.err.println("Cannot send message");
+ }
+ }
+
+ public static void main(String args[]) {
+ int i;
+
+ System.out.println("Usage: java DipInject [key] [version] [hex data delimit space in quotes]");
+ int k = Integer.parseInt(args[0], 16);
+ long v = Long.parseLong(args[1]);
+ String hexdata[] = args[2].split(" ");
+ short d[];
+
+ if(hexdata.length > 16) {
+ System.err.println("Data too long, keep it <= 16 bytes please");
+ }
+
+ d = new short[hexdata.length];
+ for(i = 0; i < d.length; i++)
+ d[i] = Short.parseShort(hexdata[i], 16);
+
+ System.out.println("Key: " + k);
+ System.out.println("Version: " + v);
+ System.out.print("Data: ");
+ for(i = 0; i < d.length; i++) {
+ System.out.print(d[i] + " ");
+ }
+ System.out.println();
+
+ DipInject dipinject = new DipInject(new DipMsg());
+ dipinject.sendDipDataMsg(k, v, d);
+ }
+}
\ No newline at end of file
COMPONENT=TestDIPC
+BUILD_EXTRA_DEPS = DipMsg.py DipDataMsg.py DipMsg.class DipDataMsg.class DipData.class DipInject.class
CFLAGS += -I$(TOSDIR)/lib/net
CFLAGS += -I$(TOSDIR)/lib/net/dip -I$(TOSDIR)/lib/net/dip/interfaces
#CFLAGS += -I$(TOSDIR)/lib/net/drip
CONSTANTS += -DTOSH_DATA_LENGTH=32
CFLAGS += $(CONSTANTS)
+
+DipMsg.py:
+ mig python -target=$(PLATFORM) -python-classname=DipMsg $(CFLAGS) $(TOSDIR)/lib/net/dip/Dip.h dip_msg -o $@
+
+DipDataMsg.py:
+ mig python -target=$(PLATFORM) -python-classname=DipDataMsg -python-extends=DipMsg $(CFLAGS) $(TOSDIR)/lib/net/dip/Dip.h dip_data_msg -o $@
+
+DipData.py:
+ mig python -target=$(PLATFORM) -python-classname=DipData -python-extends=DipDataMsg $(CFLAGS) $(TOSDIR)/lib/net/dip/Dip.h dip_data -o $@
+
+
+DipMsg.class: DipMsg.java
+ javac -target 1.4 -source 1.4 DipMsg.java
+
+DipDataMsg.class: DipDataMsg.java
+ javac -target 1.4 -source 1.4 DipDataMsg.java
+
+DipData.class: DipData.java
+ javac -target 1.4 -source 1.4 DipData.java
+
+DipMsg.java:
+ mig java -target=$(PLATFORM) -java-classname=DipMsg $(CFLAGS) $(TOSDIR)/lib/net/dip/Dip.h dip_msg -o $@
+
+DipDataMsg.java:
+ mig java -target=$(PLATFORM) -java-classname=DipDataMsg -java-extends=DipMsg $(CFLAGS) $(TOSDIR)/lib/net/dip/Dip.h dip_data_msg -o $@
+
+DipData.java:
+ mig java -target=$(PLATFORM) -java-classname=DipData -java-extends=DipDataMsg $(CFLAGS) $(TOSDIR)/lib/net/dip/Dip.h dip_data -o $@
+
+DipInject.class:
+ javac -target 1.4 -source 1.4 DipInject.java
+
+#clean-inject:
+# rm -f DipMsg.py DipDataMsg.py DipData.py
+# rm -f DipMsg.java DipDataMsg.java DipData.java
+# rm -f DipMsg.class DipDataMsg.class DipData.class
+# rm -f DipInject.class
+
include $(MAKERULES)
the total number of items and the number of new items. The items that
are random are chosen randomly.
-If you want 128 total items and 96 new items, you would type:
+If you want 128 total items in the dissemination set, where 96 of
+those 128 items are new, you would type:
python gentest.py 128 96
count is how many new items it has received so far
isOk will be true if the data value was as expected
-4. TIMING
+4. PACKET INJECTOR
+
+You can also use the injector to send data packets via a
+basestation. The syntax to do that is:
+
+java DipInject [key] [version] [data in quotes delimited by space]
+
+key is the data key in hexadecimal
+version is the version number in decimal
+data is the actual data in quotes delimited by space
+
+For example, if you want to send key 10, version 2, and data "ab cd
+ef". You would type:
+
+java DipInject 0a 2 "ab cd ef"
+
+For this specific test application, your data needs to be "ef be". You
+will need a SerialForwarder running for this work.
+
+5. TIMING
With a single sender and single receiver on a table using TelosB
nodes, it takes approximately: