eHouse Smart Home – Android Programming Open Source

eHouse 4 Android – Status Update of controllers for TCP / IP

eHouse Smart Home – Synchronization controllers state, input, output, measured values ​​of the devices and panels on Android.

class EhouseTCP

Class is used to maintain a TCP/IP communication to eHouse smart home system (online) and update data coming from the eHouse microprocessor controllers.
It also involves classes:
* ehousecommunication.class
* StatusEhouse.class
* StatusCommManager.class

When the connection “query” , to receive the current status of the driver (online ) , data is updated in instances (1 controller – one instance of class status ) classes:

  • StatusEhouse (for eHouse1 controllers)
  • StatusCommManager ( for eHouse Ethernet controllers TCP/IP)

These data can then be retrieved by the software to create logs and visualization algorithms or any other software on the Android platform, without having to write it “from scratch”. Names are taken directly from eHouse PC platform configuration .


features:

public static void TerminateQuery()

Terminate TCP/IP infinite loop for receiving the status of drivers .

Example of use: EhouseTCP.TerminateQuery();


public static boolean QueryStart( String host , int port )

Initiates and maintains communication and reception of the status of all system eHouse controllers ( infinite loop – it may be broken by TerminateQuery ())

If the specified host is using the parameters host and port

otherwise, use the configuration settings ( separately for Local and Internet connection depending on the launch function of public EnableInternet (boolean enable) )

Example of use: EhouseTCP.QueryStart(“” , 9876 ); // connects to the IP address of a server TCP / IP eHouse


public static void AllDevsStatus()

Imports ” eHouse 1 RS-485″ controllers configuration, together with the names of outputs , inputs , measuring inputs configuration files

Example of use: EhouseTCP.AllDevsStatus();


public static void AllDevsTCPStatus()

Imports controller names “eHouse Ethernet” together with the names of outputs , input , measuring inputs configuration files

Example of use: EhouseTCP.AllDevsTCPStatus() ;



An example of the complete source code :

/* EHouse For ANDROID panels , tablets , PDAs , Smartphones template API for communication to the eHouse system
* ONLY FOR REGISTERED USERS , VENDORS , COOPERATIVES Copyright iSys . En All Rights Reserved
*
* Requires classes :
* ehousecommunication class :
* Sending Events is eHouse system via:
* SMS , eMail , WIFI , INTERNET , ETHERNET , TCPIP

* EhouseTCP . class :
* Initiate TCP Communication for updating the current status of devices
* Performing Query status from eHouse microcontrollers
* Assuring challange – Authorisation response to the system and communication
*

* StatusEhouse class :
* Organize classes of devices ( names , actual status values ​​etc )
* Fill up with actual values ​​and the date of eHouse1 controllers
* (RS-485)

* StatusCommManager class :
* Organize classes of devices ( names , actual status values ​​etc )
* Fill up with actual values ​​and data of Ethernet controllers eHouse
* (Ethernet )
*
*
* Application Template Steering (API ) for ANDROID platform to communicate with the system eHouse and Visualization System Status
* ONLY for registered users of the system eHouse , Cooperating Firm All Rights Reserved
*
* Requires class :
*
* ehousecommunication class :
* Sends system events (commands ) to the system drivers eHouse by :
* SMS , eMail , WIFI , INTERNET , ETHERNET , TCPIP
*
* EhouseTCP class :
* Initiates and maintains TCP / IP communication with drivers to update the state
* Drivers eHouse – output , measuring inputs eHouse
* Provides authentication method challange – response to the connection to the system
*
* StatusEhouse class :
* This class contains all the settings and current data for each driver eHouse
* For further processing ( name , values , status) updated on a regular basis by the TCP / IP
* For drivers eHouse1 ( RS-485 )

* StatusCommManager class :
* This class contains all the settings and current data for each driver eHouse
* For further processing ( name , values , status) updated on a regular basis by the TCP / IP
* For drivers eHouse2 (Ethernet )
*
*
*/
package ehouse.android ;
import android.app.Activity ;
import android.os.Bundle ;
import android.widget.TextView;

public class extends Activity ehouseandroid
{

Override
public void onCreate ( Bundle savedInstanceState )
{ TextView tv = new TextView (this) ;
super.onCreate ( savedInstanceState ) ;

/* Initate and setup Android Application from config files generated from eHouse . exe appliaction
*
* Initializes the settings application on the Android platform generated from the application eHouse . exe / mobile and copied to the SD card
*/
ehousecommunication.init(); // first INIT command eHouse LIBRARY STACK !!!!!!!!!!

/*
* Setup and Init List of Devices class containing :
* Names and Values ​​digital input , aDC inputs , outputs ,
* { StatusEhouse for eHouse 1 devices , StatusCommManager for eHouse 2}
*
*/
EhouseTCP.AllDevsStatus(); // second command INIT DEVICE CONFIGURATION – initialize the device configuration ehouse 1 485
EhouseTCP.AllDevsTCPStatus(); // third INIT command TCPIP DEVICE CONFIGURATION – initialize the device configuration eHouse Ethernet
EhouseTCP.EnableInternet(true); // Initialize query reception via the Internet (external address or ddns service )
// Sets the external address to connect to the Internet tcpip
/* Start infinite loop for reading the query from eHouse controllers and putting it
* StatusEhouse and StatusCommManager Classes .
* Can be interrupted by EhouseTCP . TerminateQuery () ; function
* Initiates an infinite loop current status data retrieval ( query) with drivers and
* Loading the class StatusEhouse and StatusCommManager
* Can be interrupted by functions EhouseTCP . TerminateQuery ()
*/

EhouseTCP.QueryStart (“”, 9876); // Start Query reception

/*
* Terminate query eHouse controllers before end of application
*
* If you stop updating the drivers before the end of the program
*
*/

// EhouseTCP . TerminateQuery () ;

/* Send Contents of EventQueue via eMail for reception by emailgate.exe
* Sends an event from the event queue by eMail to receive the software emailgate.exe
*/

// ehousecommunication.SendEmail() ;

/*
* Send Contents of EventQueue via SMS for reception by CommManager or SMS – Gate connected to PC
* Sends the contents of the Event queue by SMS for CommManager
* Or Goals SMS / GSM phone connected to the PC received by the application SMSGate . exe
*
*
*/
// SendSMS();

/*
* Clear Event Queue to send ( after successful transmition via any method ) performed automatically box
*
* Clears the event queue to be sent ( automatically removes events after przasłaniu any method )
*
*/

// ehousecommunication.ClearEventQueue();

/*
* Get recent transmition Log
* Returns the log of the last transmission
*/

// ehousecommunication.GetLog();

/*
*
* Clear Log
*
* Clear Log
*
*/
// ClearLog () ;

tv.setText( ehousecommunication.log) ;
setContentView (tv) ; }
}