Skip to content

This can be used to get the water meter data stored in the server. Or store the data using UDP messages.

Notifications You must be signed in to change notification settings

Buddhimah/FYP_Data_API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 

Repository files navigation

a da# FYP_Data_API This can be used to get the water meter data stored in the server. Or store the data using UDP messages.

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

How to get data? Send a GET request to http://192.248.15.157:8081/meter/all image

Data will be received in the JSON format.

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

How to Store data? For our final year project, we are using NB-iOT and 6Lowpan Mesh network as Communication Protocols stacks. Hence UDP messages will be used to transfer data. This application has functionality to receive those UDP messages and store them in MySQL database.

Send UDP packet in the format Id:data Here id is the meter id : is the delimiter Data is meter data

IP ADDRESS : 192.248.15.157 Port : 57 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

image

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

image

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Code for sending UDP Packets

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

import java.io.*;

import java.net.*;

class UDPClient

{ public static void main(String args[]) throws Exception

{

  BufferedReader inFromUser =
     new BufferedReader(new InputStreamReader(System.in)); 
  DatagramSocket clientSocket = new DatagramSocket();
  
  InetAddress IPAddress = InetAddress.getByName("192.248.15.157");
  
  byte[] sendData = new byte[10000];
  
  byte[] receiveData = new byte[2048];
  
  String sentence = inFromUser.readLine();
  
  sendData = sentence.getBytes();
  
System.out.println(sendData);

System.out.println(sendData.length);	

  DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, 57);
  clientSocket.send(sendPacket);
  
  DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
  clientSocket.receive(receivePacket);
  
  String modifiedSentence = new String(receivePacket.getData());
  
  System.out.println("FROM SERVER:" + modifiedSentence);
  
  clientSocket.close();

} } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 3 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 4

About

This can be used to get the water meter data stored in the server. Or store the data using UDP messages.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published