Programming AssignmentProgramming Assignment 4 – TinyOS programming In every second, Sensor 1 (Network ID = 1) measures the ambient light intensity and then transmits a packet that carries...

Honest statement in the pdf file will be done from my side.
All the instructions in the pdf must be followed accurately.

Programming Assignment Programming Assignment 4 – TinyOS programming In every second, Sensor 1 (Network ID = 1) measures the ambient light intensity and then transmits a packet that carries the light intensity reading to Sensor 2 (Network ID = 2). In every two seconds, Sensor 1 measures the ambient temperature and then transmits a packet that carries the temperature reading to Sensor 2. Sensor 2 forwards all data to the computer. Display the readings in the Cooja simulator. Additional Requirements: 1. Please provide comments for each function block and a readme with your honest statement and run your code in the Cooja simulator. Submission Create a tar archive with the command ‘tar -czvf lab4.tar.gz .’, and then submit your archive to CANVAS before the submission deadline. Make sure you do not include the executable in your archive (make clean before creating the archive). Late assignments will not be accepted under any circumstances. Plan to turn in your assignments early. Grading Guidelines (20 points) ● Program does not have your academic honesty statement: -20 points ● Program is not implemented in NesC under TinyOS: -20 points ● Program cannot compile: -20 points ● Program cannot run properly: -15 points at least ● Program can run properly ○ Each logic error (e.g., using a wrong network ID, collect reading with a wrong interval, not display a reading properly): -3 points ● Others ○ Bad programming style (e.g., no indentation, using variable a, b, c): -3 points ○ Insufficient comments: -3 points Note: don’t forget to include your honest statement in your code (see course syllabus). You can create a readme file for it and put it in your archive. Submission Deadline: 4:00pm 12/5/2022 Eastern Time Demo: Putting it All Together 74 Demo #ifndef __DEMOAPP_H #define __DEMOAPP_H enum { AM_DEMO_MESSAGE = 150, }; typedef nx_struct demo_message { nx_uint16_t photoReading; } demo_message_t; #endif // __DEMOAPP_H DemoMessage.h COMPONENT=DemoAppC TINYOS_ROOT_DIR?=../.. include $(TINYOS_ROOT_DIR)/Makefile.include Makefile 75 ➢ DemoMessage.h ➢ ➢ ➢ Makefile ➢ JAVA ❑ ❑ Makefile 76 #include "DemoApp.h" configuration DemoAppC { } implementation { components DemoP, MainC, new HamamatsuS10871TsrC() as PhotoC; components ActiveMessageC; components new AMSenderC(AM_DEMO_MESSAGE), new AMReceiverC(AM_DEMO_MESSAGE); components LedsC; components new TimerMilliC(); components SerialActiveMessageC as SerialC; DemoP.Boot -> MainC; DemoP.Photo -> PhotoC; DemoP.RadioControl -> ActiveMessageC; DemoP.AMSend -> AMSenderC; DemoP.Receive -> AMReceiverC; DemoP.Packet -> ActiveMessageC; DemoP.SerialControl -> SerialC; DemoP.SerialAMSend -> SerialC.AMSend[AM_DEMO_MESSAGE]; DemoP.SerialPacket -> SerialC; DemoP.Leds -> LedsC; DemoP.Timer -> TimerMilliC; } module DemoP { uses interface Boot; uses interface Read as Photo; uses interface SplitControl as RadioControl; uses interface AMSend; uses interface Receive; uses interface Packet; uses interface SplitControl as SerialControl; uses interface Packet as SerialPacket; uses interface AMSend as SerialAMSend; uses interface Leds; uses interface Timer; } implementation { message_t buf; message_t *receivedBuf; task void readSensor(); task void sendPacket(); task void sendSerialPacket(); 77 event void Boot.booted() { call RadioControl.start(); call SerialControl.start(); } event void RadioControl.startDone(error_t err) { if(TOS_NODE_ID == 0) call Timer.startPeriodic(256); } event void Timer.fired() { post readSensor(); } event void RadioControl.stopDone(error_t err){} event void SerialControl.startDone(error_t err){} event void SerialControl.stopDone(error_t err){} 78 79 task void readSensor() { if(call != SUCCESS) post readSensor(); } event void Photo.readDone(error_t err, uint16_t value) { if(err != SUCCESS) post readSensor(); else { demo_message_t * payload = (demo_message_t *)call Packet.getPayload(&buf,sizeof(demo_message_t)); payload->photoReading = value; post sendPacket(); } } task void sendPacket() { if(call AMSend.send(AM_BROADCAST_ADDR, &buf, sizeof(demo_message_t)) != SUCCESS) post sendPacket(); } event void AMSend.sendDone(message_t * msg, error_t err) { if(err != SUCCESS) post sendPacket(); } 80 event message_t * Receive.receive(message_t * msg, void * payload, uint8_t len) { demo_message_t * demoPayload = (demo_message_t *)payload; call Leds.set(demoPayload->photoReading / 200); receivedBuf = msg; post sendSerialPacket(); return msg; } task void sendSerialPacket() { if(call SerialAMSend.send(AM_BROADCAST_ADDR, receivedBuf, sizeof(demo_message_t))!= SUCCESS) post sendSerialPacket(); } event void SerialAMSend.sendDone(message_t* ptr, error_t success) { if(success!=SUCCESS) post sendSerialPacket(); }
Dec 01, 2022

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here