Library updated

One of the tasks in my todo list was to update the released library with ways on making it easier to adapt it to different applications, thus I added 3 arguments into the constructor function.

Now along side the original Context and Callback arguments, you also need to supply Selector, settings and InstancePassword arguments.

The Selector is other callback interface, which can be set to null as well. it is set if the application wants to get knowledge on the services discovered and wants to implement selection of the device which the connection is to be made to. Basically the interface function will be called with array of discovered devices presented by ServiceItem instances, and the function must return one of the service items as selected device, to which the library will attempt open connection to.

The Settings argument will be instance of BTConnectorSettings, which with the application will tell the library the SERVICE_TYPE used with Wifi Direct services, the UUID used with Blue tooth connections as well as String to be used as a name for Blue tooth.

The InstancePassword is then used for encrypting the instance name variable used for delivering the Blue tooth address information, so it would be not directly human readable.

Each application using the library, should use own unique SERVICE_TYPE, UUID and InstancePassword to avoid any possible conflicts with other applications using the library.

I was also running some tests with the library, and found out that there is high change that two devices are trying to connect each other exactly the same time, which appears to create sockets which will cause exceptions with first read/write, even when they appears to be connected and also will report the remote device information correctly. Tests where I had 2-4 devices doing the tests, were indicating that up to 10% of concoctions did fail this way.

To fix this, the library now also implements really simple handshake, in which both ends are reading& writing few bytes, before the socket is given to the application.