Tuesday, November 20, 2007

List of Free PHP and MySQL Hosting

Chart #1: PHP environment details
for tested free webhosts

The free PHP hosting comparison chart below was compiled from phpinfo() files on test accounts of the free webspace hosts, and are subject to change as the free website hosts update their PHP software configurations.

Free Web Host PHP
Version
Database
Version
allow_url_
fopen
safe_
mode
max_
execution_
time
GD
Support
Last
Checked
007 iHost 5.1.6 MySQL 5.0.27 Off On 20 2.0.28 compatible 11/5/2007
100 Webspace 4.4.0 MySQL 3.23.56 Enabled Off 30 2.0.15 compatible 11/5/2007
110 mb 5.1.6 MySQL 5.0.27 Off Off 15 2.0.28 compatible 11/19/2007
12 Gb Free 5.1.6 MySQL 5.0.27 Off On 20 2.0.28 compatible 9/21/2007
3000 mb 4.4.1 MySQL 4.1.22 Enabled Off 20 - 6/15/2007
Award Space 4.4.1 MySQL 4.0.24 Enabled Off 30 2.0 or higher 4/12/2007
Best Free Web Space 5.1.6 MySQL 5.0.27 Off On 20 2.0.28 compatible 9/11/2007
Byet Host 5.2.3 MySQL 5.0.38 Off On 20 2.0 or higher 6/15/2007
Free Hostia 4.4.0 MySQL 3.23.56 Enabled Off 30 2.0.28 compatible 5/7/2007
Free PHP Web Hosting 5.1.6 MySQL 5.0.27 Off On 30 2.0.28 compatible 6/30/2007
Free Web Hosting 5.1.6 MySQL 5.0.27 Off On 20 2.0.28 compatible 10/12/2007
Free WebHosting Pro 5.1.6 MySQL 5.0.27 Off On 20 2.0.28 compatible 7/25/2007
FreeWeb 7 5.1.6 MySQL 5.0.27 Off On 20 2.0.28 compatible 7/24/2007
Joolo 5.1.6 MySQL 5.0.27 Off On 20 2.0.28 compatible 7/10/2007
Lead Hoster 4.4.2 MySQL 4.1.11 Enabled Off 30 2.0 or higher 6/15/2007
Synced 4.4.4 MySQL 4.1.22 Enabled Off 30 2.0.28 compatible 9/21/2007
Trap17 5.2.0 MySQL 5.0.27 Enabled Off 30 2.0.28 compatible 11/7/2007
Tripod.uk 4.4.6
phpinfo disabled now
MySQL ? Off On 10 ? 2.0 or higher 5/28/2007
X10 Hosting 5.2.3
phpinfo is disabled
MySQL 4.1.22 ? ? ? ? 8/20/2007
Xoom Webs 4.3.9 MySQL not working Enabled Off 20 ? 11/8/2007

Chart #2: General details
about all free web hosts with PHP

Free Web Host Web Space Forced Ads Upload Scripting Your URL Notes
007i Host 700 MB No adds FTP, Browser PHP Domain or Subdomain Bandwidth limit 7 GB/month. MySQL databases. Add-on domain name. LayeredPanel free website control panel. Multiple accounts allowed. Maximum file size limit 5 MB. Fantastico-like PHP scripts installer. Instant activation.
110 mb 5 GB No ads FTP, Browser PHP Domain or Subdomain Bandwidth limit 300 GB/month. MySQL database (requires forum posting or fee). PHP script installers like Fantastico. File size limit 6 MB. Add-on domain name.
Agility Hoster 200 MB No banners / ads FTP, Browser CGI, PHP, SSI, Front Page Server Extensions, Perl Domain or Subdomain Bandwidth limit 5 GB/month. POP3 Email, Web mail. MySQL database. Statistics. Host add-on domain name. Instant activation of free webspace hosting accounts.
Atb Host 500 MB No ads yet, but later Browser, FTP PHP Domain or Subdomain Bandwidth limit 30 GB/month. Xpanel control panel. MySQL database, PHPMyAdmin. 1-click phpBB, WordPress installers. Website statistics. Max file size limit 1 MB.
Award Space 200 MB No ads FTP, Browser CGI, PHP, SSI, Front Page Server Extensions, Perl Domain or Subdomain Bandwidth limit 5 GB/month. MySQL database. POP3, Web-based Email. Autoresponders. Addon domains. File size limit 500 KB. Traffic Statistics. Password-protected files. Fantastico-like scripts installer. Instant activation.
Best Free WebSpace 20,000 MB Banners FTP, Browser PHP Domain or Subdomain Bandwidth limit 300 GB per month. MySQL databases. LayeredPanel. Add-on domain names. Instant free hosting activation.
Byet Host 100 MB - 250 MB No ads (bannerless) FTP, Browser PHP Domain or Subdomain MySQL databases. POP3, Web-based Email, and Forwarding. Bandwidth limit 20-30 GB/month. Free website statistics. Host add-on domains. No file size limit. Instant free webspace hosting activation.
Dhost 100 MB Banner (Adbrite) FTP, Browser PHP /you Bandwidth limit 300 GB/month. MySQL database. No file size limits.
Frag Vault 600 MB Banner FTP, Browser CGI, PHP, Perl Domain or Subdomain Bandwidth limit 70 GB monthly. cPanel control panel with Fantastico. PSQL. MySQL, PostgreSQL databases. POP3, SMTP, Web-based Email. Addon domains. Shared SSL Server. Custom error pages. No maximum filesize limit.
Free Web Hosting 5000 MB TextLink at Bottom FTP, Browser PHP Domain or Subdomain Bandwidth limit 20 GB/month. Awstats advanced traffic statistics. Layered Panel (LayeredPanel) file manager. MySQL databases. One-click PHP Scripts Installer. Maximum file size limitation 10 MB. Instant account activation.
Free Hostia 250 MB No ads FTP, Browser CGI, PHP, SSI, Front Page Server Extensions, Perl Domain or Subdomain Bandwidth limit 5 GB/month. POP3, Forwarding, Web-based Email. Auto-responders. SpamAssassin. MySQL database. Addon domain names. Statistics. Elefante installer. Instant activation. File size limit 500 KB. 30-days Inactivity limit. Custom error pages.
Free PHP Web Hosting 1000 MB No banners or ads FTP, Browser PHP5 Domain or Subdomain Bandwidth limit 10 GB/month. Awstats web site statistics. Layered Panel websitel panel (LayeredPanel control panel). MySQL databases.
Free WebHosting 360 3600 MB Banner-Top FTP, Browser PHP Domain or Subdomain Bandwidth limit 3.6 GB/month. LayeredPanel website hosting panel. MySQL databases. Multiple free webhosting accounts allowed. Host additional domains free.
FreeWeb 7 7000 MB No ads FTP, Browser PHP5 Domain or Subdomain Bandwidth limit 65 GB/month. LayeredPanel control panel. MySQL databases and 1-click script auto-installers. Instant activation.
Free WebHosting Pro 5000 MB No ads FTP, Browser PHP Domain or Subdomain Bandwidth limit 20 GB/month. LayeredPanel. MySQL databases. Instant activation of FreeWebHosting accounts.
Giga Cities 20 GB No ads FTP, Browser PHP Domain or Subdomain Bandwidth limit 300 GB/month. LayeredPanel free web site control panel. MySQL databases. Host multiple domains. AwStats Advanced Statistics. Instant activation of accounts.
Helio Host 150+ MB Banner-Top FTP, Browser CGI, PHP, SSI, Front Page Server Extensions, Perl Domain or Subdomain Bandwidth limit 1500+ MB/month. Cpanel, Fantastico. Unlimited addon domains. POP3 Email, Spam Assassin. Statistics, raw logs. Cron jobs allowed. Unlimited MySQL and PostgreSQL databases. Custom error pages. SSL Secure server.
Joolo 1000 MB Button-Bottom FTP, Browser PHP Domain or Subdomain Bandwidth limit 10 GB/month. LayeredPanel control panel. MySQL databases. Host Add-on domain names. AWstats statistics.
Lead Hoster 250 MB No adds FTP, Browser CGI, Perl, PHP, SSI, Microsoft FrontPage Server Extensions Domain or Subdomain Bandwidth limit 6 GB/month. Custom control panel. POP3, IMAP, Web-based Email, Auto-responders, Spam e-mail filters. MySQL database. Addon domain names. Website statistics.
NewSit.es (New Sites) 20 GB No ads FTP, Browser PHP Domain or Subdomain Bandwidth limit 300 GB/month. Layered Panel control panel. MySQL databases, PHP 5.
Ofingo 250 MB No Banners or ads FTP, Browser PHP Domain or Sub-domain Bandwidth limit 6 GB/month. MySQL databases. POP3 e-mail, Webmail. Password-protected directories allowed. Fantastico-like automatic PHP scripts installers. Add-on domain names (host multiple domains on one freehosting account). Web Site Statistics. Instant account activation.
Profuse Host 2 GB Banner-Top FTP, Browser CGI, PHP, SSI, Front Page Extensions, Perl, Python, Ruby Domain or Subdomain Cpanel. Bandwidth limit 100 GB/month. PostgreSQL, MySQL databases. PhpMyAdmin, phpPgAdmin. Web-based Email, Forwarding, Auto-responders. Webalizer, Analog, AWStats web statistics. Password-protected files. Ruby on Rails. .htaccess. Addon domains. Backup.
Quotaless Unlimited Banners-Top FTP, Browser PHP Domain or Subdomain Virtually unlimited bandwidth. LayeredPanel control panel. Zantastico 1-click script installer for over 20 popular forums/CMS scripts. MySQL database, phpMyAdmin. Awstats website statistics.
RipWay 30 MB No ads FTP, Browser PHP /you Bandwidth limit 750 MB/month (25 MB/day). Instant activation. Online file storage allowed. 30-days Inactivity limit. Filesize limit 10 MB.
Synced 300 MB Banner FTP, Browser CGI, PHP, SSI, Front Page Extensions, Perl Domain or Subdomain Bandwidth limit 35 GB/month. Cpanel, Fantastico. PSQL and MySQL databases. Custom error pages. No file sizelimit. POP3, Forwarding, Web-based Email. Free web site statistics. Addon domains. .htaccess files supported. English websites only.
Trap17 500 MB No ads FTP, Browser CGI, PHP, SSI, Front Page Server Extensions, JSP JavaServer Pages, Perl Domain or Subdomain Note: Forum posting required. Bandwidth limit 10 GB/month. MySQL databases. Cpanel. Fantastico. Cronjobs/Crontab support. Website Statistics. Shared SSL Secure Server. POP, SMTP, Forwarders, Custom MX change, Web-based Email. Custom error 404 pages. TCL. Free JSP web hosting service. Add-on domain names.
T35 Unlimited Pop-up FTP, Browser PHP, SSI Subdomain Unlimited bandwidth (unmetered). All file types allowed. File size limit 500 KB. No inactivity limit. Monthly backups of free websites.
Tripod.uk 1024 MB (1 GB) Frame + Popup FTP, Browser PHP, SSI, Front Page Server Extensions /you MySQL database. Statistics. Unlimited bandwidth. Unlimited file size. Custom error pages. Web-based Email. Instant activation.
Ueuo 200 MB Popunder once per user FTP, Browser PHP, SSI Domain or Subdomain Unmetered bandwidth. Xpanel. MySQL database, preinstalled phpMyAdmin. Custom error pages. File size limit 10 MB. Statistics. Php mail enabled. Email. Cron jobs. Addon domains. Multiple accounts allowed. Instant free webspace hosting activation.
Vlexo.com 1024 GB Banner FTP, Browser CGI, PHP, FrontPage Server Extensions, Perl, Python, Ruby on Rails Domain or Subdomain Bandwidth limit 15 GB/month. Cpanel, Fantastico, Installatron. MySQL databases. Website Statistics. No maximum file size limits. POP3 Email. Addon domain names.
Websites Network 200 MB No ads FTP, Browser CGI, Perl, PHP Domain or Subdomain Bandwidth limit 2,000 MB/month. cPanel, Fantastico. MySQL databases. POP3/SMTP, Email Forwarding, Web mail. Auto-responders. Awstats Web Site Traffic Statistics.
X10 Hosting 300+ MB No banners or ads FTP, Browser, SiteCopier CGI, PHP, ASP, SSI, Front Page Server Extensions, Perl, Python Domain or Subdomain Bandwidth limit 10 GB/month, upgradeable. Cpanel, Fantastico del luxe. MySQL databases. AwStats Statistics. POP3, SMTP, Forwarding, Web-based Email, PHP Sendmail. Spam Assassin. Add-on domains. Cronjobs.


Friday, November 16, 2007

P2P Streaming Application

P2P Streaming Application developed during P2P Challenge Task 2006

Description

This application is the result of a P2P challenge performed by 5 different groups in the scope of a lecture on Peer-to-Peer Systems and Applications during summer term 2006 at the University of Zurich.

The goal of this challenge was to build a P2P application, that transports an MPEG Transport Stream (TS) from a streaming server to several clients via the UDP protocol (cf. Figure 1). The application was used to broadcast the FIFA World Cup 2006 as live stream to the students participating in the challenge.

The application had to meet the following requirements:

  • Only one client receives the stream from the streaming server. All other clients receive the stream only via other clients (i.e. clients are servers for other clients at the same time.
  • The delay of the stream between the streaming server and the clients should be minimal. At the same time, the application should scale for many (e.g. up to 10 billion) clients.
  • The stream should be distributed on application-level only (Application-Level Multicast), i.e. no use of IP Multicast or similar technologies below the application layer.
  • The clients should be able to join and leave dynamically. At the same time, the stream should be delivered with as few interrupts as possible.
  • The application should be fully decentralized. No use of (centralized) infrastructure services such as, e.g., a DNS server.

More information about the challenge task can be found at http://www.csg.uzh.ch/teaching/ss06/p2p/challenge (in german).

Software Requirements

The application has been implemented in Java. It requires Java version 1.4.2 (JDK) or higher for compilation*. It depends on the FreePastry 1.4.4 library which is included in the application source package and needs to be put on the class path. The application may easily be compiled using Eclipse or any other development environment.

* Package csg.p2p.challenge.group3 requires Java 1.5

Furthermore, the application uses VLC as streaming server as well as streaming client to display the MPEG stream locally. VLC is a free media player, which is able to stream and receive several multimedia formats. The layer model in Figure 2 shows, how the UDP stream is distributed through the P2P application and received with VLC locally. In principle, other UDP-enabled streaming engines may be used, too.

Download

Documentation

Refer to the README file. Further documentation about the different solutions can be found in the doc folder of the source distribution.

License

Refer to the LICENSE file.

See AUTHORS for the full list of authors for the different P2P challenge groups.

Basic VoIp Concept

Here we see some important info about VoIP, needed to understand it.

Overview on a VoIP connection

To setup a VoIP communication we need:

  1. First the ADC to convert analog voice to digital signals (bits)
  2. Now the bits have to be compressed in a good format for transmission: there is a number of protocols we'll see after.
  3. Here we have to insert our voice packets in data packets using a real-time protocol (typically RTP over UDP over IP)
  4. We need a signaling protocol to call users: ITU-T H323 does that.
  5. At RX we have to disassemble packets, extract datas, then convert them to analog voice signals and send them to sound card (or phone)
  6. All that must be done in a real time fashion cause we cannot waiting for too long for a vocal answer! (see QoS section)

                      
Base architecture

Voice )) ADC - Compression Algo - Assembling RTP in TCP/IP ----
----> |
<---- | Voice (( DAC - Decompress. Algo - Disass. RTP from TCP/IP ----

Analog to Digital Conversion

This is made by hardware, typically by card integrated ADC.

Today every sound card allows you convert with 16 bit a band of 22050 Hz (for sampling it you need a freq of 44100 Hz for Nyquist Principle) obtaining a throughput of 2 bytes * 44100 (samples per second) = 88200 Bytes/s, 176.4 kBytes/s for stereo stream.

For VoIP we needn't such a throughput (176kBytes/s) to send voice packet: next we'll see other coding used for it.

Compression Algorithms

Now that we have digital data we may convert it to a standard format that could be quickly transmitted.

PCM, Pulse Code Modulation, Standard ITU-T G.711

  • Voice bandwidth is 4 kHz, so sampling bandwidth has to be 8 kHz (for Nyquist).
  • We represent each sample with 8 bit (having 256 possible values).
  • Throughput is 8000 Hz *8 bit = 64 kbit/s, as a typical digital phone line.
  • In real application mu-law (North America) and a-law (Europe) variants are used which code analog signal a logarithmic scale using 12 or 13 bits instead of 8 bits (see Standard ITU-T G.711).

ADPCM, Adaptive differential PCM, Standard ITU-T G.726

It converts only the difference between the actual and the previous voice packet requiring 32 kbps (see Standard ITU-T G.726).

LD-CELP, Standard ITU-T G.728
CS-ACELP, Standard ITU-T G.729 and G.729a
MP-MLQ, Standard ITU-T G.723.1, 6.3kbps, Truespeech
ACELP, Standard ITU-T G.723.1, 5.3kbps, Truespeech
LPC-10, able to reach 2.5 kbps!!

This last protocols are the most important cause can guarantee a very low minimal band using source coding; also G.723.1 codecs have a very high MOS (Mean Opinion Score, used to measure voice fidelity) but attention to elaboration performance required by them, up to 26 MIPS!

RTP Real Time Transport Protocol

Now we have the raw data and we want to encapsulate it into TCP/IP stack. We follow the structure:

VoIP data packets
RTP
UDP
IP
I,II layers

VoIP data packets live in RTP (Real-Time Transport Protocol) packets which are inside UDP-IP packets.

Firstly, VoIP doesn't use TCP because it is too heavy for real time applications, so instead a UDP (datagram) is used.

Secondly, UDP has no control over the order in which packets arrive at the destination or how long it takes them to get there (datagram concept). Both of these are very important to overall voice quality (how well you can understand what the other person is saying) and conversation quality (how easy it is to carry out a conversation). RTP solves the problem enabling the receiver to put the packets back into the correct order and not wait too long for packets that have either lost their way or are taking too long to arrive (we don't need every single voice packet, but we need a continuous flow of many of them and ordered).

                    Real Time Transport Protocol

0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|V=2|P|X| CC |M| PT | sequence number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| timestamp |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| synchronization source (SSRC) identifier |
+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
| contributing source (CSRC) identifiers |
| .... |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Where:

  • V indicates the version of RTP used
  • P indicates the padding, a byte not used at bottom packet to reach the parity packet dimension
  • X is the presence of the header extension
  • CC field is the number of CSRC identifiers following the fixed header. CSRC field are used, for example, in conference case.
  • M is a marker bit
  • PT payload type

For a complete description of RTP protocol and all its applications see relative RFCs 1889 and 1890.

RSVP

There are also other protocols used in VoIP, like RSVP, that can manage Quality of Service (QoS).

RSVP is a signaling protocol that requests a certain amount of bandwidth and latency in every network hop that supports it.

For detailed info about RSVP see the RFC 2205

Quality of Service (QoS)

We said many times that VoIP applications require a real-time data streaming cause we expect an interactive data voice exchange.

Unfortunately, TCP/IP cannot guarantee this kind of purpose, it just make a "best effort" to do it. So we need to introduce tricks and policies that could manage the packet flow in EVERY router we cross.

So here are:

  1. TOS field in IP protocol to describe type of service: high values indicate low urgency while more and more low values bring us more and more real-time urgency
  2. Queuing packets methods:
    1. FIFO (First in First Out), the more stupid method that allows passing packets in arrive order.
    2. WFQ (Weighted Fair Queuing), consisting in a fair passing of packets (for example, FTP cannot consume all available bandwidth), depending on kind of data flow, typically one packet for UDP and one for TCP in a fair fashion.
    3. CQ (Custom Queuing), users can decide priority.
    4. PQ (Priority Queuing), there is a number (typically 4) of queues with a priority level each one: first, packets in the first queue are sent, then (when first queue is empty) starts sending from the second one and so on.
    5. CB-WFQ (Class Based Weighted Fair Queuing), like WFQ but, in addition, we have classes concept (up to 64) and the bandwidth value associated for each one.
  3. Shaping capability, that allows to limit the source to a fixed bandwidth in:
    1. download
    2. upload
  4. Congestion Avoidance, like RED (Random Early Detection).

For an exhaustive information about QoS see Differentiated Services at IETF.

H323 Signaling Protocol

H323 protocol is used, for example, by Microsoft Netmeeting to make VoIP calls.

This protocol allow a variety of elements talking each other:

  1. Terminals, clients that initialize VoIP connection. Although terminals could talk together without anyone else, we need some additional elements for a scalable vision.
  2. Gatekeepers, that essentially operate:
    1. address translation service, to use names instead IP addresses
    2. admission control, to allow or deny some hosts or some users
    3. bandwidth management
  3. Gateways, points of reference for conversion TCP/IP - PSTN.
  4. Multipoint Control Units (MCUs) to provide conference.
  5. Proxies Server also are used.

h323 allows not only VoIP but also video and data communications.

Concerning VoIP, h323 can carry audio codecs G.711, G.722, G.723, G.728 and G.729 while for video it supports h261 and h263.

More info about h323 is available at Openh323 Standards, at this h323 web site and at its standard description: ITU H-series Recommendations.

You can find it implemented in various application software like Microsoft Netmeeting, Net2Phone, DialPad, ... and also in freeware products you can find at Openh323 Web Site.

Hardware requirement

To create a little VoIP system you need the following hardware:

  1. PC 386 or more
  2. Sound card, full duplex capable
  3. a network card or connection to internet or other kind of interface to allow communication between 2 PCs

All that has to be present twice to simulate a standard communication. The tool above are the minimal requirement for a VoIP connection: next we'll see that we should (and in Internet we must) use more hardware to do the same in a real situation. Sound card has be full duplex unless we couldn't hear anything while speaking! As additional you can use hardware cards (see next) able to manage data stream in a compressed format (see Par 4.3).

Hardware accelerating cards

We can use special cards with hardware accelerating capability. Two of them (and also the only ones directly managed by the Linux kernel at this moment) are the

  1. Quicknet PhoneJack
  2. Quicknet LineJack
  3. VoiceTronix V4PCI
  4. VoiceTronix VPB4
  5. VoiceTronix VPB8L

Quicknet PhoneJack is a sound card that can use standard algorithms to compress audio stream like G723.1 (section 4.3) down to 4.1 Kbps rate.

It can be connected directly to a phone (POTS port) or a couple mic-speaker.

It has a ISA or PCI connector bus.

Quicknet LineJack works like PhoneJack with some addition features (see next).

VoiceTronix V4PCI is a PCI card pretty like Quicknet LineJack but with 4 phone ports

VoiceTronix VPB4 is a ISA card equivalent to V4PCI.

VoiceTronix VPB8L is a logging card with 8 ports.

For more info see Quicknet web site and VoiceTronix web site

Hardware gateway cards

Quicknet LineJack and VoiceTronix cards can be connected to a PSTN line allowing VoIP gateway feature.

Then you'll need a software to manage it (see after).

Software requirement

We can choose what O.S. to use:

  1. Win9x
  2. Linux

Under Win9x we have Microsoft Netmeeting, Internet Phone, DialPad or others or Internet Switchboard (from Quicknet web site) for Quicknet cards.

Warning!!: Latest Quicknet cards using Swithboard (older version too) NEED to be connected to Internet to get working for managing Microtelco account (not free of charge), so if you plan to remain isolated from Internet you need to install OpenH323 software.

For VoiceTronix cards you can find software at VoiceTronix web site

Under Linux we have free software GnomeMeeting, a clone of Microsoft Netmeeting, while in console mode we use (also free software) applications from OpenH323 web site: simph323 or ohphone that can also work with Quicknet accelerating hardware.

Attention: all Openh323 source code has to be compiled in a user directory (if not it is necessary to change some environment variable). You are warned that compiling time could be very high and you could need a lot of RAM to make it in a decent time.

Gateway software

To manage gateway feature (join TCP/IP VoIP to PSTN lines) you need some kind of software like this:

  • Internet SwitchBoard (only when connected to Internet) for Windows systems also acting as a h323 terminal;
  • PSTNGw for Linux and Windows systems you download from OpenH323.

Gatekeeper software

You can download as gatekeeper the Free product Openh323 Gatekeeper (GK) from here.

Version 2.0 of it supports "proxy function" to enabe talking from/to a private network.

Other software

In addition I report some useful software h323 compliant:

  • Phonepatch, able to solve problems behind a NAT firewall. It simply allows users (external or internal) calling from a web page (which is reachable from even external and internal users): when web application understands the remote host is ready, it calls (h323) the source telling it all is ok and communication can be established. Phonepatch is a proprietary software (with also a demo version for no more than 3 minutes long conversations) you download from here.

Same function can be obtained using "Proxy" function of Gatekeeper Gnugk (see before).

Here we see how to configure special hardware card in Linux and Windows environment.

Quicknet PhoneJack

As we saw, Quicknet Phonejack is a sound card with VoIP accelerating capability. It supports:

  • G.711 normal and mu/A-law, G.728-9, G.723.1 (TrueSpeech) and LPC10.
  • Phone connector (to allow calling directly from your phone) or
  • Mic & speaker jacks.

Quicknet PhoneJack is a ISA (or PCI) card to install into your Pc box. It can work without an IRQ.

Software installation

Under Windows you have to install:

  1. Card driver
  2. Internet Switchboard application (working only with Internet, using newer Quicknet cards)

all downloadable from Quicknet web site

After Switchboard has been installed, you need to register to Quicknet to obtain full capability of your card.

When you pick up the phone Internet Switchboard wakes up and waits for your calling number (directly entered from your phone), you can:

  1. enter an asterisk, then type an IP number (with asterisks in place of dot) with a # in the end
  2. type directly a PSTN phone number (with international prefix) to call a classic phone user. In this case you need a registration to a gateway manager to which pay for time.
  3. enter directly a quick dial number (up to 2 digits) you have previously stored which make a call (IP or PSTN).

Internet Swichboard is h323 compatible, so if you can use, for example, Microsoft Netmeeting at the other end to talk.

Warning!! Internet Switchboard NEED to be connected to Internet when used with newer Quicknet cards

In place of Internet Switchboard you can use openh323 application openphone (using GUI) or ohphone (command line).

Under Linux you have to install:

  1. Card driver, from Quicknet web site. After downloaded you have to compile it (you must have a /usr/src/linux soft or hard link to your Linux source directory): type make for instructions.
  2. Application openphone or ohphone.
  3. If you are a developer you can use SDK to create your own application (also for Windows).

Settings

With Internet Switchboard (and with other application) you can:

  1. Change compression algorithm preferred
  2. Tune jitter delay
  3. Adjust volume
  4. Adjust echo cancellation level.

Quicknet LineJack

This card is very similar to the previous, it supports also gateway feature.

We only notice that we have to download PSTNGx application (for Linux and Windows) or we use Internet Switchboard to gateway feature.

VoiceTronix products

  1. First download software here
  2. Untar it
  3. Modify 'src/vpbreglinux.cpp' according to file README
  4. type 'make'
  5. type 'make install'
  6. cd to src
  7. type 'insmod vpb.o'
  8. retrieve (from console of from 'dmesg' output command) major number, say MAJOR
  9. type 'mknod /dev/vpb0 c MAJOR 0' where MAJOR is the above number
  10. cd to unittest and type './echo'

Follow README file for more help.

I personally haven't tested VoiceTronix products so please contact VoiceTronix web site for support.

In this chapter we try to setup VoIP system, simple at first, then more and more complex.

Simple communication: IP to IP

       A (Sound card)   -  -  -    B (Sound card)

192.168.1.1 - - - 192.168.1.2


192.168.1.1 calls 192.168.1.2 and viceversa.

A and B should have

  1. an application like Microsoft Netmeeting, Internet Switchboard, Openh323 (under Windows environment) or Ohphone, Gnomemeeting (under Linux), installed and properly configured.
  2. a network card or other kind of TCP/IP interface to talk each other.

In this kind of view A can make a H323 call to B (if B has server side application active) using B IP address. Then B can answer to it if it wants. After accepting call, VoIP data packets start to flow.

Using names

Under Microsoft Windows a NetBIOS name can be used instead of an IP address.

          A            -  -  -             B

192.168.1.1 - - - 192.168.1.2

John - - - Alice


John calls Alice.

This is possible cause John call request to Alice is converted to IP calling by the NetBIOS protocol.

The above 2 examples are very easy to implement but aren't scalable.

In a more big view such as Internet it is impossible to use direct calling cause, usually, the callers don't know the destination IP address. Furthermore NetBIOS naming feature cannot work cause it uses broadcast messages, which typically don't pass ISP routers .

You can also use DNS to solve name in IP address: for example you can call ''box.domain.com''.

Internet calling using a WINS server

The NetBIOS name calling idea can be implemented also in a Internet environment, using a WINS server: NetBIOS clients can be configured to use a WINS server to resolve names.

PCs using the same WINS server will be able to make direct calling between them.

A (WINS Server is S) - - - - I  - - - -  B (WINS Server is S)
N
T
E - - - - - S (WINS Server)
C (WINS Server is S) - - - - R
N
E - - - - D (WINS Server is S)
T

Internet communication

A, B, C and D are in different subnets, but they can call each other in a NetBIOS name calling fashion. The needed is that all are using S as WINS Server.

Note: WINS server hasn't very high performance cause it use NetBIOS feature and should only be used for joining few subnets.

ILS server

ILS is a kind of server which allows you to solve your name during an H323 calling: when you start VoIP application you first register to ILS server using a name, then everyone will be able to see you using that name (if he uses same Server ILS!).

A big problem: the masquering.

A problem of few IPs is commonly solved using the so called masquering (also NAT, network address translation): there is only 1 IP public address (that Internet can directly "see"), the others machines are "masqueraded" using all this IP.

       
A - - -

B - - - Router with NAT - - - Internet

C - - -


This doesn't work

In the example A,B and C can navigate, pinging, using mail and news services with Internet people, but they CANNOT make a VoIP call. This because H323 protocol send IP address at application level, so the answer will never arrive to source (that is using a private IP address).

Solutions:

  • there is a Linux module that modifies H323 packets avoiding this problem. You can download the module here. To install it you have to copy it to source directory specified, modify Makefile and go compiling and installing module with "modprobe ip_masq_h323". Unfortunately this module cannot work with ohphone software at this moment (I don't know why).


A - - - Router with NAT

B - - - + - - - Internet

C - - - ip_masq_h323 module


This works

  • There is a application program that also solves this problem: for more see Par 5.7

          
A - - -

B - - - PhonePatch - - - Internet

C - - -


This works

Open Source applications

Ohphone Sintax

Sintax is:

"ohphone -l|--listen [options]"

"ohphone [options]... address"

  • "-l", listen to standard port (1720)
  • "address", mean that we don't wait for a call, but we connect to "address" host
  • "-n", "--no-gatekeeper", this is ok if we haven't a gatekeeper
  • "-q num", "--quicknet num", it uses Quicknet card, device /dev/phone(num)
  • "-s device", "--sound device", it uses /dev/device sound device.
  • "-j delay", "--jitter delay", it change delay buffer to "delay".

Also, when you start ohphone, you can give command to the interpreter directly (like decrease AEC, Automatic Echo Cancellation).

Gnomemeeting

Gnomemeeting is an application using GUI interface to make call using VoIP. It is very simple to use and allows you to use ILS server, chat and other things.

Setting up a gatekeeper

You can also experiment gatekeeper feature

Example

(Terminal H323) A - - -
\
(Terminal H323) B - - - D (Gatekeeper)
/
(Terminal H323) C - - -

Gatekeeper configuration

  1. Hosts A,B and C have gatekeeper setting to point to D.
  2. At start time each host tells D own address and own name (also with aliases) which could be used by a caller to reach it.
  3. When a terminal asks D for an host, D answers with right IP address, so communication can be established.

We have to notice that the Gatekeeper is able only to solve name in IP address, it couldn't join hosts that aren't reachable each other (at IP level), in other words it couldn't act as a NAT router.

You can find gatekeeper code here: openh323 library is also required.

Program has only to be launch with -d (as daemon) or -x (execute) parameter.

In addition you can use a config file (.ini) you find here.

Setting up a gateway

As we said, gateway is an entity that can join VoIP to PSTN lines allowing us to made call from Internet to a classic telephone. So, in addition, we need a card that could manage PSTN lines: Quicknet LineJack does it.

From OpenH323 web site we download:

  1. driver for Linejack
  2. PSTNGw application to create our gateway.

If executable doesn't work you need to download source code and openh323 library, then install all in a home user directory.

After that you only need to launch PSTNGw to start your H323 gateway.

Compatibility Matrix

First Matrix refers to:

  1. Software intercommunications (i.e. Netmeeting with SwitchBoard)
  2. Software/Driver/Hardware talking (i.e. Netmeeting can use a PhoneJACK card).

NetmeetingSwitchBoardSimph323OhPhoneLinPhoneSpeak-FreelyHW PhoneJACKHW LineJACK
NetmeetingVVVVXXVV
SwitchBoardVVVVXXVV
Simph323VVVVXXXX
OhPhoneVVVVXXVV
LinPhoneXXXXVXXX
SpeakFreelyXXXXXVXX
HW PhoneJACKVVXVXX--
HW LineJACKVVXVXX--


Second Matrix refers to Gateway softwares that manage LineJACK card.

 ___________________________________________________________
| |HW LineJACK GW| SwitchBoard | PSTNGW |
|______________|______________|______________|______________|
|HW LineJACK GW| _ | V | V |
|______________|______________|______________|______________|
| SwitchBoard | V | _ | _ |
|______________|______________|______________|______________|
| PSTNGW | V | _ | _ |
|______________|______________|______________|______________|

Notation:

  • V : Works
  • X : Doesn't Work
  • -- : Doesn't care

Tuesday, November 6, 2007

Search other bluetooth from desktop/PC

I tried to find information about developing desktop applications with Bluetooth support using Java but it seems that most of the articles are concentrated in mobile J2ME implementations. Now that I wanted to develop desktop bluetooth application I thought that I’d write down how I managed to do so. Read on, if you are interested…
Step 1. Find Bluetooth Stack Implementation for J2SE
There aren’t many JSR-82 implementations available for the desktop environment. Most of them are commercial but I was able to find the open source version from http://www.javabluetooth.org/. So the first thing was to download the source code and try to compile it. It wouldn’t compile as it depended on the Java Communications API (javax.comm.*). After I had downloaded the comm library I added comm.jar to my class path and I was able to compile the JavaBluetooth library. You can download the compiled binary here.
But… It turned out that JavaBluetooth library only supports Bluetooth devices with serial connection and thus it didn’t work with my laptop that has a built-in Bluetooth adapter.
This led me to another great site, http://www.javabluetooth.com/, which has a small list of Java Bluetooth SDKs and it included a library called BlueCove. This library works only on Windows platform but it will do for now as there aren’t other free options to choose from.
Step 2. Hello Bluetooth World
Next thing was to try it out by coding a simple application that would sniff any nearby bluetooth devices using the laptops built-in bluetooth adapter. This was easier then I thought.
You have to create class that will implement DiscoveryListener interface and the use DiscoveryAgent to search for devices. You can get the discovery agent from LocalDevice object as seen in the following code sample:


public class BluetoothBrowser
implements DiscoveryListener {

private LocalDevice localDevice;
private DiscoveryAgent agent;

/** Creates a new instance of BluetoothBrowser */
public BluetoothBrowser()
throws BluetoothStateException {
localDevice = LocalDevice.getLocalDevice();
agent = localDevice.getDiscoveryAgent();
}

/** Start inquiry */
public void inquiry()
throws BluetoothStateException {
agent.startInquiry(DiscoveryAgent.GIAC, this);
}

...implementations for DiscoveryListener...

Full Source Code of this example
This program contains 5 *.java files, such as:
1. PresenceJFrame.java
2. Application.java
3. Controller.java
4. BluetoothBrowser.java
5. Log.java

Those are full source code of file above:
PresenceJFrame.java

/*
* PresenceJFrame.java
*
* Created on 8. heinäkuuta 2007, 11:04
*/

package com.didiksoft.presence;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
*
* @author didiksoft
*/
public class PresenceJFrame extends javax.swing.JFrame {

private Controller controller;

/** Creates new form PresenceJFrame */
public PresenceJFrame() {
initComponents();
this.controller = Controller.getInstance();
}

/** Add text to the text area */
public void addText(String text) {
logTextArea.setText(logTextArea.getText() + text + "\r\n");
logTextArea.repaint();
}

/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// =editor-fold defaultstate="collapsed" desc=" Generated Code "=//GEN-BEGIN:initComponents
private void initComponents() {

jScrollPane1 = new javax.swing.JScrollPane();
logTextArea = new javax.swing.JTextArea();
jButton1 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Bluetooth example");

logTextArea.setColumns(20);
logTextArea.setRows(5);
jScrollPane1.setViewportView(logTextArea);

jButton1.setText("Search nearby devices");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
searchDevices(evt);
}
});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 291, Short.MAX_VALUE)
.addComponent(jButton1))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 186, Short.MAX_VALUE)
.addContainerGap())
);

pack();
}// =/editor-fold=//GEN-END:initComponents

private void searchDevices(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchDevices
controller.searchDevices();
}//GEN-LAST:event_searchDevices

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new PresenceJFrame().setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea logTextArea;
// End of variables declaration//GEN-END:variables

}


2. Application.java

/*
* __NAME__.java
*
* Copyright (C) 2007 didiksoft
* http://java-vb.blogspot.com
*
*/

package com.didiksoft.presence;

import javax.swing.UIManager;


/**
*
* @author Didik Rawandi (uchiha_didik@yahoo.com)
*/
public class Application {

private static Controller controller;

/** Creates a new instance of __NAME__ */
private Application() {
}

public static void main(String[] args) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
try {
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
//UIManager.setLookAndFeel( new com.jgoodies.looks.plastic.PlasticXPLookAndFeel() );
} catch(Exception ex) {
ex.printStackTrace();
}
controller = Controller.getInstance();
controller.start();
}
});


}

}

3. Controller.java

/*
* Controller.java
*
* Copyright (C) 2007 didiksoft
* http://java-vb.blogspot.com
*
*/

package com.didiksoft.presence;

import com.didiksoft.bluetooth.BluetoothBrowser;
import com.didiksoft.logging.Log;

/**
*
* @author Didik Rawandi (uchiha_didik@yahoo.com)
*/
public class Controller {

private static Controller instance;
private static PresenceJFrame mainFrame;

/** Creates a new instance of Controller */
private Controller() {
}

public static Controller getInstance() {
if(instance==null) {
instance = new Controller();
mainFrame = new PresenceJFrame();
}
return instance;
}

public void start() {
mainFrame.setVisible(true);
}

public void searchDevices() {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
Log.add("Start discovery");
Thread.yield();
try {
BluetoothBrowser browser = new BluetoothBrowser();
//browser.inquiry();
Thread.yield();
Thread.sleep(15000);
} catch(Exception ex) {
Log.error("Error in main: " + ex);
}
Log.add("Discovery end");
Thread.yield();
}
});

}

public void addLogText(String text) {
mainFrame.addText(text);
}

}

4. BluetoothBrowser.java

/*
* BluetoothBrowser.java
*
* Copyright (C) 2007 didiksoft
* http://java-vb.blogspot.com
*
*/

package com.didiksoft.bluetooth;

import com.didiksoft.logging.Log;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.bluetooth.BluetoothStateException;
import javax.bluetooth.DeviceClass;
import javax.bluetooth.DiscoveryAgent;
import javax.bluetooth.DiscoveryListener;
import javax.bluetooth.LocalDevice;
import javax.bluetooth.RemoteDevice;
import javax.bluetooth.ServiceRecord;

/**
*
* @author Didik Rawandi (uchiha_didik@yahoo.com)
*/
public class BluetoothBrowser implements DiscoveryListener {

private LocalDevice localDevice;
private DiscoveryAgent agent;

/** Creates a new instance of BluetoothBrowser */
public BluetoothBrowser() throws BluetoothStateException {

System.out.print(LocalDevice.isPowerOn());
localDevice = LocalDevice.getLocalDevice();
agent = localDevice.getDiscoveryAgent();
}

public void inquiry() throws BluetoothStateException {
agent.startInquiry(DiscoveryAgent.GIAC, this);
}

public void deviceDiscovered(RemoteDevice device, DeviceClass devClass) {
try {
Log.add("Device discovered: " + device.getFriendlyName(false));
} catch (IOException ex) {
Logger.getLogger("global").log(Level.SEVERE, null, ex);
}
}

public void servicesDiscovered(int transID, ServiceRecord[] servRecord) {
Log.add("Service discovered");
}

public void serviceSearchCompleted(int transID, int responseCode) {
Log.add("Service search completed");
}

public void inquiryCompleted(int discType) {
Log.add("Inquiry completed");
}

}


5. Log.java

/*
* Log.java
*
* Copyright (C) 2007 didiksoft
* http://java-vb.blogspot.com
*
*/

package com.didiksoft.logging;

import com.didiksoft.presence.Controller;

/**
*
* @author Didik Rawandi (uchiha_didik@yahoo.com)
*/
public class Log {

/** Creates a new instance of Log */
private Log() {
}

public static void add(String message) {
System.out.println("LOG: " + message);
Controller controller = Controller.getInstance();
controller.addLogText(message);
}

public static void error(String message) {
System.err.println("ERROR: " + message);
}

}



good luck, please clicks MyAds for donate myriset, thanks alot

Thursday, November 1, 2007

This article provides Java sample codes to search for Bluetooth devices using a JSR-82 API. If you are new to JSR-82, we recommend you to read the JSR-82 Basics tutorial to get a basic idea Java and Bluetooth.


JSR-82 provides the class DiscoveryAgent for performing Device Discovery and Service Discovery. The LocalDevice class provides a factory method 'getDiscoveryAgent' that returns a singleton instance of the DiscoveryAgent. This instance can then be used to discover other bluetooth devices and services.


The following code sample shows you how to use the DiscoveryAgent to discover other bluetooth devices. For this sample to work, you need a JSR-82 Implmentation (Java Bluetooth Stack) like ElectricBlue or aveLink in the classpath.


BluetoothDeviceDiscovery.java




import java.io.IOException;

import java.util.Vector;



import javax.bluetooth.DeviceClass;

import javax.bluetooth.DiscoveryAgent;

import javax.bluetooth.DiscoveryListener;

import javax.bluetooth.LocalDevice;

import javax.bluetooth.RemoteDevice;

import javax.bluetooth.ServiceRecord;





/**

* Class that discovers all bluetooth devices in the neighbourhood

* and displays their name and bluetooth address.

*/

public class BluetoothDeviceDiscovery implements DiscoveryListener{





//object used for waiting

private static Object lock=new Object();



//vector containing the devices discovered

private static Vector vecDevices=new Vector();





//main method of the application

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



//create an instance of this class

BluetoothDeviceDiscovery bluetoothDeviceDiscovery=new BluetoothDeviceDiscovery();



//display local device address and name

LocalDevice localDevice = LocalDevice.getLocalDevice();

System.out.println("Address: "+localDevice.getBluetoothAddress());

System.out.println("Name: "+localDevice.getFriendlyName());



//find devices

DiscoveryAgent agent = localDevice.getDiscoveryAgent();



System.out.println("Starting device inquiry...");

agent.startInquiry(DiscoveryAgent.GIAC, bluetoothDeviceDiscovery);



try {

synchronized(lock){

lock.wait();

}

}

catch (InterruptedException e) {

e.printStackTrace();

}





System.out.println("Device Inquiry Completed. ");



//print all devices in vecDevices

int deviceCount=vecDevices.size();



if(deviceCount <= 0){

System.out.println("No Devices Found .");

}

else{

//print bluetooth device addresses and names in the format [ No. address (name)
]

System.out.println("Bluetooth Devices: ");

for (int i = 0; i <deviceCount; i++) {

RemoteDevice remoteDevice=(RemoteDevice)vecDevices.elementAt(i);

System.out.println((i+1)+". "+remoteDevice.getBluetoothAddress()+"
("+remoteDevice.getFriendlyName(true)+")");

}

}





}//end main



//methods of DiscoveryListener



/**

* This call back method will be called for each discovered bluetooth devices.

*/

public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) {

System.out.println("Device discovered: "+btDevice.getBluetoothAddress());

//add the device to the vector

if(!vecDevices.contains(btDevice)){

vecDevices.addElement(btDevice);

}

}



//no need to implement this method since services are not being discovered

public void servicesDiscovered(int transID, ServiceRecord[] servRecord) {

}



//no need to implement this method since services are not being discovered

public void serviceSearchCompleted(int transID, int respCode) {

}





/**

* This callback method will be called when the device discovery is

* completed.

*/

public void inquiryCompleted(int discType) {

synchronized(lock){

lock.notify();

}



switch (discType) {

case DiscoveryListener.INQUIRY_COMPLETED :

System.out.println("INQUIRY_COMPLETED");

break;



case DiscoveryListener.INQUIRY_TERMINATED :

System.out.println("INQUIRY_TERMINATED");

break;



case DiscoveryListener.INQUIRY_ERROR :

System.out.println("INQUIRY_ERROR");

break;



default :

System.out.println("Unknown Response Code");

break;

}

}//end method

}//end class

Java Bluetooth : JSR-82 Initialization : LocalDevice

LocalDevice class can be considered as the basic entry point to the JSR-82 API. It is used to initialize the JSR-82 stack, and to control the local bluetooth settings. If you are new to JSR-82, check out the JSR-82 Basics tutorial before reading this. JSR 82 API can be broadly classified into the following sections.



  • a. LocalDevice Settings Manipulation

  • Device Discovery

  • Service Discovery

  • Service Registration

  • L2CAP

  • SPP

  • GOEP

  • BCC


Out of these sections ,the LocalDevice class provides the lowest level of access to the bluetooth stack. There is also another part that can more or less be counted among the lowest layers of JSR82 : the Bluetooth Control Center or the BCC. This part is implementation specific and has no standard APIs. Each vendor can expose their own required APIs which they think is appropriate for their JSR82 implementation. In this article we will look in to LocalDevice and how it can be used to manipulate the Local Bluetooth Device settings.



The class LocalDevice represents the local bluetooth device. The actual bluetooth device could be a built-in bluetooth chip in the case of latest bluetooth enabled laptops and mobiles or it could be a USB or UART interface attached to a PC. No matter whatever shape or form the device takes it can be manipulated using the methods of class LocalDevice.


Local Device Methods


public static LocalDevice getLocalDevice()


The LocalDevice class produces a singleton object. i.e. At any instance there’s only one instance of the class in the VM. Hence applications cannot directly instantiate this class. To obtain an instance of this class application has to invoke the method getLocalDevice(). Multiple calls to this method will return the same object. This object can be used to invoke other methods of this class. In effect, this method is the entry point to a JSR-82 API, and initializes the underlying JSR-82 bluetooth stack.


public java.lang.String getBluetoothAddress()


This method returns the unique address of the local bluetooth device as a String.


Each bluetooth device has a 48-bit or 6-byte value which is termed as the device’s bluetooth address. This is the unique value that differentiates one bluetooth device from the other. So if you and your friend each have a bluetooth enabled mobile, then the device addresses of these 2 mobiles will be different. The address will look somewhat like this. 00:55:34:A6:56:89


The ‘:’ used to separate each byte, and is not part of the address. This is usually used to present the address in a readable form.


public java.lang.String getFriendlyName()


This method returns the friendly name of the local bluetooth device.


Though the bluetooth address can be used to identify a bluetooth device it’s not always so easy to remember the 6 byte addresses. Unlike computers human users are not so good with numbers, especially big ones. So to make the task of recognizing a device easier to a human user, each device can be assigned a user friendly name. This is a String and can be set to any value.


public DeviceClass getDeviceClass()


This method returns the class of the local bluetooth device as an Object of DeviceClass. The class DeviceClass has methods to retrieve the major device class, minor device class and service classes of the device.


Each bluetooth device has a device class or (Class of Device, CoD as specified by the bluetooth spec). This field stores information about the type of device and which types of service are supported by the device. For example if the bluetooth deviec is a mobile then in the device class field the particular bit representing mobile should be set. Likewise for services like Imaging or Rendering the respective bits should be set in the CoD field.


Discoverability


Bluetooth devices usually have some way to discover all other neighbouring bluetooth devices within range. But in some cases the device user might wish to hide his device from other searching devices. This is just like logging in to an instance messenger and making ourselves invisible. The hidden device itself can see all other bluetooth devices (that are not hidden) and can perform bluetooth operations but the only difference is that, it will be invisible in the bluetooth network. Later on when the device user wishes to make it visible he can make the device discoverable so that it again becomes visible in the bluetooth network.


Related Methods:


public boolean setDiscoverable(int mode)


This method can be used to make the device visible/invisible. Infact this method sets the discoverable mode of the device. Valid modes are DiscoveryAgent.GIAC, DiscoveryAgent.LIAC, DiscoveryAgent.NOT_DISCOVERABLE.


public int getDiscoverable()


This method returns the current mode of the bluetooth device.


Device Properties


public static java.lang.String getProperty(java.lang.String property)


The local bluetooth device is associated with some properties which specifies the features the device supports and also some specific values related to the features. All these can be retreived by the application running above jsr82.


Device Search


public DiscoveryAgent getDiscoveryAgent()


It has been mentioned earlier that bluetooth devices can search for other bluetooth devices in it’s neighbourhood. Once a device is found, it can be searched for specific services. All this is made possible by the class DiscoveryAgent. This class exports methods to search for both bluetooth devices and services. A localdevice can have only one instance of discovery agent and this is retreived using the above method.


Local Service Database


Each bluetooth device has a service database in which it can register services so as to allow other bluetooth devices to use them. The details of each registered service is kept as an object of class ServiceRecord. The process of creating and registering services will be discussed in a later article. For the time being we’ll examine the ways in which local device’s service records can be manipulated.


Each service record is associated with a Notifier object that registers it. In JSR82 there are notifiers for L2CAP, SPP and GOEP. To retrieve a service record corresponding to a service, the notifier that registered the record is necessary. Once the service record is fetched from the local service database it can be updated with the new values and the modified record can be added to the service database.


Related Methods:


a. public ServiceRecord getRecord(javax.microedition.io.Connection notifier)


This method gets the service record corresponding to a btspp, btl2cap, or btgoep notifier.


b. public void updateRecord(ServiceRecord srvRecord) throws ServiceRegistrationException


Updates the service record in the local SDDB that corresponds to the ServiceRecord parameter. Updating is possible only if srvRecord was obtained using the getRecord() method.


These are the operations that can be performed using the LocalDevice.

Java Bluetooth : JSR-82 Basics

This is the first part of the tutorial covering the basics of JSR-82.


What is JSR-82?


JSR-82 is a standard defined by the Java Community Process for providing a standard to develop Bluetooth applications in Java. It is an open and non-proprietary standard for developing Bluetooth applications. The JSR-82 API hides the complexity of the Bluetooth protocol stack, by exposing a simple set of Java API’s. The JSR-82 specific can be downloaded from here.


Pre-Requisites


To develop a Bluetooth application in Java using the JSR-82, you need to have the following



  1. JSR-82 Compliant Bluetooth Stack.

  2. You need a JSR-82 Implementation to successfully develop and test a Java Bluetooth application. You either need to have a simulated enviorment like the Sun Java Wireless Toolkit, or a real Java Bluetooth Stack like ElectricBlue or Avelink. The simulator allows you to test the Bluetooth application in a simulated environment, with no access to real bluetooth device.


  3. Local Bluetooth Device.

  4. If you are using a simulator, this is not needed. But to test your application in real world over a java bluetooth stack, you need to have a bluetooth enabled system. This can either be a Bluetooth USB Dongle plugged in to your system, or the internal built in bluetooth device. The java application that you writes, runs over this bluetooth device, and this bluetooth device is called as the ‘LocalDevice’ in JSR-82.


Capabilities of JSR-82


What all applications can you develop using the JS-82? The JSR-82 API provides you the options to do the following



  1. Manage the Local Bluetooth Device settings.

  2. Discover other bluetooth devices in the neighborhood.

  3. Search for bluetooth devices on the discovered bluetooth devices.

  4. Connect to any of those bluetooth service and communicate with it.

  5. Register a bluetooth service on the Local Bluetooth Device, so that other bluetooth devices can connect to it.

  6. Manage and control the communication connections.

  7. Provide the security to all of the above options.


These are the properties and capabilities of JSR-82 in a nutshell. How you can develop application using the capabilities of the JSR-82 will be explained in the next section of this article.