Searching, please wait...

libhomeradar

easy collect aircraft information
~50,000,000 registered contacts
303894 unique aircraft records, 28.78% unresolved records
 ACARS DECODER Planespotting Network Kinetic Avionics AirNav Systems Airframes.org Atlas Tracking
libhomeradar - easy collect aircraft informations

libhomeradar is an easy to use library for all type of programming language which can use libraries. libhomeradar can connect to different sources to collect aircraft informations arround the world with extended informations, powerful filtering and structured data access.

libhomeradar is written in C and is available for Linux and Windows (2003, XP, NT, Vista).

Currently libhomeradar works with the Kinetic Avionics SBS-1 base station and the Airnav Systems Radarbox.


Yahoo! My Web  Google Bookmarks  Windows Live  Facebook  Ask  del.icio.us  Furl 
 

Connect to host with event handler

In this example we try to add 3 hosts to the library handle and for every host we add an event handler for the LHR_ONCONNECT, LHR_ONTIMEOUT, LHR_ONFAILED and LHR_ONLOSS event handler. All contacted aircrafts will be written to stdout. The event listener for the LHR_ONCONTACT will be installed as soon as the connect is established. This program runs appr. 1 minute.


 
libhomeradar - easy collect aircraft informations - Download example  Download this source
/* System includes */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

/* libhomeradar header include */
#include "libhomeradar.h"

/* Show new contacted aircrafts */
void onair(LHR handle,const int *id, LHR_CONTACT *C) {
  char tstr[64];

  printf("*** NEW CONTACT ***\n===================\n");
  if (id != NULL) printf("[%s]\n",homeradar_gethostbyid(handle,*(id)));
  printf("Contact: %s [%s]\n",
          C->icao24,(C->reg)?C->reg:"UNKNOWN");
  strftime(tstr,sizeof(tstr),"%d %m %Y %H:%M:%S",localtime(&C->contacted));
  printf("Date: %s\n===================\n",tstr);

  /* Free used memory */
  homeradar_freecontact(C);
}

/* Callback function to show aircraft informations */
void newcontact(void *handle,const int *id, LHR_CONTACT *C) {

  /* Show ICAO24 code only because lookups are not enabled */
  printf("%sContact: %s [%s]\n",(C->newcontact)?"AIR":"",
          C->icao24,(C->reg)?C->reg:"UNKNOWN - Lookup not enabled?!");

  /* Free LHR_CONTACT struct */
  homeradar_freecontact(C); 
}

/* Connect is established */
void connectok(LHR handle, const int *item) {
  printf("SUCCESSFULLY CONNECTED TO = %s\n",homeradar_gethostbyid(handle,*(item)));

  /* Setup the event listener for the LHR_ONCONTACT event */
  if (homeradar_onhandler(handle, LHR_ONCONTACT, *(item), newcontact)==0) {
    printf("Unable to add event listener\n");
  }
}

/* Unable to establish connection */
void connectfailed(LHR handle, const int *item) {
  printf("UNABLE TO CONNECT TO = %s\n",homeradar_gethostbyid(handle,*(item)));
}

/* Connection lost */
void connectloss(LHR handle, const int *item) {
  printf("CONNECTION LOST TO = %s\n",homeradar_gethostbyid(handle,*(item)));
}

/* Main program */
int main(int argc, char **argv) {
  int e;
  LHR H = homeradar_init(16,LHR_AUTOCONNECT,&e,NULL);

  /* No error */
  if (H == NULL) {
    printf("Error initializing libhomeradar. Errorcode #%d\n",e);
    return 255;
  }

  /* Add host */
  e = homeradar_addhost(H, "sbs1.libhomeradar.org", 33033, LHR_SBS1, LHR_ONCONNECT, connectok);

  /* Install eventhandler to watch the connection */
  (void)homeradar_onhandler(H, LHR_ONLOSS, e, connectloss);
  (void)homeradar_onhandler(H, LHR_ONFAILED, e, connectfailed);

  /* Add a second host */
  e = homeradar_addhost(H, "sbs1.libhomeradar.org", 0, LHR_SBS1, LHR_ONFAILED, connectfailed);

  /* Install eventhandler to watch the connection */
  (void)homeradar_onhandler(H, LHR_ONLOSS, e, connectloss);

  /* Do nothing - in this example - loop will be finished after 60 seconds 
     In your real program you can do now what you want */
  e = 9;
  while (e--) sleep(6);

  /* Shutdown libhomeradar and free all alocated memory */
  printf("Shutdown libhomeradar...\n");
  homeradar_destroy(H);

  /* Return success */
  return 0;
}