wifi p2p network with channels - java

I read about P2P connections with wifi on the official android tutorial. It allows me to connect devices who are in close proximity. The problem is that
I want to be able to decide which device becomes the group owner
I don't want to use the device name as an ID for each peer in the network. I would like the group owner to setup a channel name which can be recognized by others. Each peer can connect to the channel name and choose a name (not their device name).
Maybe the standard direct wifi implementation as put forth in the tutorial isn't the exact tool I'm looking for. Maybe a third party library could help?

Basically the API has the functionality to do just this (though the implementation is not the most robust one, so do expect issues when developing & using the API):
Use the CreateGroup to create the group
Start local service advertisement with the group owner (set the Service type and/or the instance name to identify the 'channel name')
Start and Do remember to keep peers discovery active with your GO (otherwise other devices can not discover it)
Start Peer discovery with other devices, and once you find peers, then start Service discovery and discover the 'channel name' services yor GO is advertising

Related

Ble Scan service of a device without connecting to it

I want to scan some device with BLE.
I only want to show my device, so for know I get the name of the device and if it is the good one I put it in my list.
if (device.getName().contains(DEVICE_NAME)) {
mDevices.put(device.hashCode(), device);
invalidateOptionsMenu();
}
My problem is that if I change the name of my device this check will be false.
So I look if it was possible to get some uuid of some services that I add to do the check with something that would not change.
And the only way is to connect to the device doing a
device.connectGatt(this, false, mGattCallback); and after with the gatt I discover service but, is it possible to discover some services from a device without connectiong to it ?
I am not with the android background, but I have understanding of how BLE works.
Take a look at all standard GATT characteristics here and all the standard GATT services here.
The characteristic Device Name (UUID is 0x2A00) is bundled into Generic Access service (UUID is 0x1800).
The GAP is always broadcasted within the advertisement packet from the GATT Server.
A GATT Client should run a discovery scan to receive the advertisement and parse the advertisement packet to receive the GAP descriptor. While you are doing this, technically speaking the connection is yet to be made.
Addressing to:
If I change the name of my device this check will be false, So I look if it was possible to get some uuid of some services that I add to do the check with something that would not change.
Assuming that you want your app to connect only to a particular set of device that has some unique identification. Say for example, a BLE-enabled digital pen configured by you should only connect to your app and no other device gadget should be able to connect with your app. If that is the use case and if you have the liberty to configure the GATT server on the BLE device then you can add some custom characteristics in GAP service on GATT server which will be unique to those devices. Needless to say, you will have to generate a 128-bit custom UUID for that characteristics and the UUID will be known to your application as well. This is more like a work-around solution.
Take a look at scan filter in android.
It allows you to scan by service UUID, which needs to be sent through advertisement by BLE peripheral. I haven't worked on android, but I am certain that the ScanFilter would allow you to to filter by either a 16-bit or a 128-but UUID.
Kindly refer Bluetooth Development Portal for more details.

broadcasting in a LAN/between interconnected LAN's using android

I have to design an app in android for voice over WiFi communication for my university. Our university's infrastructure consists of interconnected LAN's(interconnection between multiple routers at different hostels and classrooms) and also a few wireless access point(all having wired interconnection). The speed of the university LAN is around 100Mbps. What I need my app to do is discover via broadcasting other instances of the app running in various devices within the campus(same android app will be installed on all devices),both within the same subnet(router) and also devices connected to other routers within the campus. The ultimate goal is to also enable end users who connect their phones using connectify me to their laptops to be able to communicate with each other,provided both the laptops are connected to the university network(may not share same subnet).However, even if that is not posible, atleast two devices residing on two different subnets must be able to discover each other. Thereafter, voice calls can be made from one device to another. The idea for discovery is via broadcast messages. There would be no central server. I am new to network programming and also android programming(though I have prior knowledge of core java). Kindly help with the procedure to broadcast messages across my university network for the initial device discovery stage and also suggest any protocols that I need to learn and any codecs for conversion from voice to data. Any other help regarding design and implementation would also be welcomed with gratitude. Please reply as soon as possible.
Broadcast does not cross subnets. For instance pinging 255.255.255.255 on a class C network is the same as pinging A.B.C.255 with A.B.C being the first 3 Octets of your IP address.
Since you mentioned
broadcast messages across my university network
I believe you want to reach destinations beyond your own subnet. You could do so by using DHCP , which would use the routers as a relay agent to forward broadcasts to different subnets. However, I would rather use Multicast as eee mentioned earlier.

A connection between 2 applications

I would like to manage a connection between 2 applications, they will run on diffrent phones.
The purpose doesn't really matters let's say that it would be some kind of a chat.
How can I create this connection between the applications? I know how to do it on pc java programs using the socket and the serverSocket classes but I guess it's diffrent in here since the phone might change his ip when he moves between networks.
So how would you do that? how would you create a connection between 2 applications/phones
Given the scenario you described in your comment, using Push Notification i.e Google Cloud Messaging (GCM) might be sufficient.
So, when program B wants update from program A, it will ask the server to push a notification (via GCM) to program A. Note that program A will not connect to the server every x time to check for updates.
Another out-of-the-box solution is to use SMS if the communication is not so frequent and messages are short. Here I mean SMS that will be processed directly by your app (given it has certain attention word) and will not go to the inbox i.e. no SMS notification on the phone
Since the two phones will, as you note, have changing IP addresses, you'll probably need to use an intermediary.
The general design pattern here would be to have a server with a fixed IP or DNS address that relays messages between your two mobile devices. The simplest implementation would be a webserver, to which each phone would connect via HTTP(S) to transmit data or poll for updates.
There are a number of backend-as-a-service platforms that provide this type of functionality pre-built, and would likely suffice for something like a chat system. Check out Cloudmine and Parse.
If you need a low-latency or near-realtime connection, you could also consider implementing your own server that uses the Android C2DM (Cloud to Device Messaging) service.
See Android's Sample Bluetooth Chat App, It will give you an idea for how it can be achieved.

Java library to make recorded phone call

Scenario: GSM SIM card is connected to PC using a USB port. I have a audio file. I have a list of mobile numbers to call.
Question: I'm looking for JAVA library which detects the GSM SIM card, and allow my application to make a recorded phone call to this list of mobile numbers.
Extra Information: This is NOT A J2ME application. I studied some of resources from net. I found this http://smslib.org/ & http://www.voicent.com/devnet/docs/javaapi.htm which does not completely solve my problem. Former can only send SMS, latter uses a gateway which actually makes a call & application's responsibility is to connect to the gateway with necessary details.
There is an API called KooKoo and they have developed telephony API for automation. You can find details on Outbound calls here.
You require to send recipient's number and the audio file over the API to play it to the recipient. You need to explore more on the API to understand its capabilities and fulfil your requirements.

Is it possible to transfer data directly between two android devices to other users in the same network?

Let's say I have two android mobile devices, connected to the same wireless network, and that network hasnt external/internet access.
Without third party software, is it possible to transfer data through wifi without knowing the ip from each other and without creating an hotspot? Something like we do on Windows (if 2 pcs are on same network, they can share information directly without internet access)
Starting with the basics, I would like to develop an application, where android phones on same network appears on a list , and then a user choose on of them and writes something - and if the other user have the same app running, appears that on his phone (and then he can reply of course - basically, a chat.
I know this make no practical sense, but believe makes all the sense for what I need to do (it's not a chat of course). If anyone knows anything, please help me - i found nothing.
Thanks in advance.
If you want to send data or messages from one phone to another using the network you will eventually need the IP address of the recipient phone. However, If you don't care about targeting specific phones you could always send UDP broadcast packets that each device on the network should receive.
If you don't want to manually specify an IP you'll need to create a discovery protocol that a phone uses to discover all the other phones on the network. You could do this buy scanning all available IP addresses and checking to see if they are a valid android phone. Or you could have each phone broadcast its presence on the network using a UDP broadcast packet sent to a predefined port.
Once you have discovered all the phones on the network its really up to you to decide how you want to send the data between phones and there are hundreds of examples of how to send data between devices/computers/processes using sockets.

Categories

Resources