Skip to content

General Description

Stanislav Șcerbatiuc edited this page Feb 9, 2016 · 1 revision

UDP Server Client

What is this application?

This is an application designed to allow communication between 2 autonomous devices, connected to the same Network.

What it was built for?

This project was accomplished in order to let 2 devices (Arduino Board & Raspberry Pi computer) communicate with each other via the network using the predefined protocol. The Arduino chip is connected with the Light & PIR (movement) sensors and sends the information they provide to the Raspberry Pi. The Raspberry Pi is responsible for receiving and storing this information into a local file, in order to be used/analysed later.

How does it accomplish this task?

The communication is done using UDP transmission protocol. Under the hood, it uses java.net.DatagramSocket to listen a specific port for incoming datagrams DatagramPacket. This ensures a simple approach on receiving information as we can extract the information contained in these datagrams to the format we need. The data transmitted from the Arduino Board is received as a String of predefined format, which contains the information about the sensors' state.

  • This String is parsed in order to extract the information about each sensor.
  • Given the information extracted, a new object Message is created, which encapsulates the current status of the sensors and records it as a JSONObject to the local file, using JsonService class.