find all devices in a network - android

In my local network there are several devices (running linux, c++) and an Android Smartphone.
Now I want to find and display all devices in the network on the Android Smartphone. Later i want to pair the android smart phone with the device for communication.
What's a good way to implement this?
My first ideas are:
sending a udp broadcast from the android smartphone, and handle these requests on each device and return a udp packet with more informations about the device.
or
When a device is active it periodically sends heartbeats as broadcast which the android smartphone can detect.
i also read about upnp, but i think this is kinda overkill.
Can you give me any hints how to implement this kind of task?
ty

You may want to have a look at nmap. It is a network scanner that can look through the network and find devices on it. Parse the output from it and display on the phone.

Related

Android to iOS connect via WiFi or using Multipeer connectivity or using WiFi direct

So I am developing an APP and I need to connect multiple android and multiple Iphone to send text data without any internet connection or service provider data network.
So one of the phone will have to act as a server to relay information between them. But the app will have to decide which phone will be the server and if a phone that is the server leaves the conversation then another phone will pickup as the server this will all be done with some smart programming but before I get there.
I know Android WiFi direct can do a one to many connection setup which makes it easy to connect android phone and accomplish the task between android phone only. But the problems comes when I need to connect Iphone with the android phones. Since the Iphone must be able to act as a server as well.
I would like to know a few things:
Can I connect Android and Iphone via WiFi Direct?
Can I connect Android and Iphone using Multipeer connectivity feature on Iphone?
Is there anyway to create a soft access point using Iphone? I know android can do this via WiFi direct feature.
If non of these can work can you suggest something.
From the discussion here it doesn't look possible
I wonder though if both OS allow enough control over the WiFi transceiver if you couldn't just write an app that could what you are asking and just bypassing the built in software architecture all together. I would think Bluetooth would be too weak except in extremely dense device saturation environments, but just for proof of concept that could be another route to take. My guess though is that you just wouldn't get that level of control over any of the radios inside a phone through the current OS.

Is it possible to connect iOS and android device using Bluetooth?

I have to make an application to pair an iOS and Android device (iPhone 5, iPad 3, Galaxy S3, Nexus 7 they all use Bluetooth 4.0) and then send data to each other.
Is this amount of data limited ? Can we send something like a photo or a PDF?
I've already done the pairing and sending data between 2 iOS devices using CoreBluetooth and the sample code from Apple BTLE_Transfer
Of what i understood, a Peripheral (Server) can Advertise to a Central (Client).
This central is scanning around itself, and then try to find the Server by looking for the UUID of the service advertised.
When i make a Server on Android, it is waiting for a connection (listening), i know the UUID and the mac address of my Server.
But when i scan with my iPhone (scanning for the same UUID of course), i can't find the server.
So is there a possibility for the android server to advertise like the Peripheral on iOS?
Or maybe a possibility for my iPhone client to connect using the mac address of the server?
Q: Is this amount of data limited ? Can we send something like a photo or a PDF?
Bluetooth Low Energy was not optimised for sending large amounts of data, nor is it optimised for streaming. It is more suitable for sending small chunks of data periodically (e.g. temperature readings, time, etc). Please have a look at this answer to understand how BLE transfer is different from classic Bluetooth. That being said, you can still send large amounts of data over BLE, and the amount of data is unlimited. However, this might end up being unreliable and relatively slow.
Q: So is there a possibility for the android server to advertise like the Peripheral on iOS?
Being a server/client is a completely different thing from being a peripheral/central:-
Peripheral/central dictates how the connection is made. A central device should initiate the connection. A peripheral device should advertise and wait for a connection request.
Client/Server dictates how the data is distributed. The Gatt Server holds the data. The Gatt Client can read, write or be notified (getting a continuous stream of readings) of this data. In most cases, the server is also the peripheral, but this is not mandatory.
So to answer your question, yes, the server can advertise like the peripheral on iOS. However, for Android, this feature is not yet available and will be part of the next version (Android L) release. Please see this answer for more information.
Q: Or maybe a possibility for my iPhone client to connect using the mac address of the server?
As far as I know, in coreBluetooth you would need the UUID, not the MAC Address, of a peripheral device to connect to it. You do not need to know the services being advertised from the peripheral device. Your best bet would be to scan for peripheral devices, and then connect to the one with the UUID and/or the advertising data that u know belong to your peripheral.
I hope this helps.
I'm not sure. Bluetooth LE isn't good idea to transfer large files. In one request phone you have only 18 bytes.
Nexus 7 bluetooth chip has some defect - not work correctly.
Try free application for IPhone - Light Blue.
so...
First question: yes.
Second: Yes but it's not good idea. MAc address in Iphone is alternating every 10 minutes and all turn on/off bluetooth.
In general, sending large files is best done using an internet connection (over the cloud), there are many frameworks that can cut down the overhead for you.
However, the main question is still how to discover to which device you would want to send the data.
There could be multiple ways of doing that on your own such as using BLE or even sound.
To be honest, its a lot of work so if your app is end-user driven, i would suggest using a framework that can do cross platform discovery for you such as: http://p2pkit.io or google nearby.
Disclaimer: i work for Uepaa developing p2pkit for iOS and Android

How to send Bluetooth data to an unknown device?

I'm asking because I've been facing that issue for weeks.
I need to develop an Android application that can be able to perform an Bluetooth Connection and send data to an Bluetooth Hardware.
Ok, so here's the point:
is it possible to perform a RFCOMM connection to an 'unknown' device?
I mean, is it possible to do this without having any information about the hardware code?
Because i'm only able to modify the AndroidDevice (cellphone) code, for SENDING purposes.
I want to send a byte and make sure it was received, but there's only a sending code.
Could we have some more details? Is the other device accessible by you, as in can the other device know information about the Android device? And what do you mean by a "sending code"?
The Android device can pick up any active Bluetooth device in its range, and know the name and address of those devices. So, if the Android device doesn't know anything about the Bluetooth device it wants to connect to, you can always sort through the list of devices in range, and get its hardware code through that.
See the documentation about Bluetooth, specifically the Finding Devices section:
http://developer.android.com/guide/topics/connectivity/bluetooth.html
I've done a fair amount of Bluetooth work with Android devices and Arduinos, and the Bluetooth library might be a bit of a pain to work with, but it is powerful.
With bluetooth the two devices have a UUID. If you a writing a program that runs on both devices you have them listen for that UUID. When they connect as a client or a server you have a dataInputStream and a dataOutputStream. Then you can push and pull bytes out of those.

Getting started with Bluetooth development for Android: Suggestions for test application

I have a task to integrate a Bluetooth device into my application. Now my requirement is very specific. The device has a specific communication protocol which relies on certain ACKs but I figured it would make my development much easier if there was a program that let me test communication with the device.
I was wondering if there was a program for Linux, or perhaps a simple Android program which let me communicate with any Bluetooth device with a series of pings using data I enter and simply log the responses.
EDIT: I might not have been clear enough in my question.
I have a scale that I need to integrate into my application, and the scale has a protocol similar to this:
Get a specific byte string from device
Transfer data
Transfer packet for disconnection
Receive acknowledgement for disconnect packet
Disconnect
Now when I have to issue a POST request from my application, I usually build a test script online so I can test if the POST works properly.
I was wondering if there was something similar I could do with the device.
Thanks
Your question is not clear enough. To communicate with a BT device, you need to know what profile your device supports. Depending on that, you can find a way in Android or Linux or windows to communicate with the device.
The simplest way is to open an RFCOMM channel from android/PC and transfer data to and from the device. For this the device has to support the serial port profile (SPP). If you want to do this in Android, look for the BluetoothChat example from google.
If you want to use a PC/mac/linux look at the Bluez python module. It's really simple to use. There are plenty of other options too..
I was looking for something like SENA BTerm. It lets me connect to any device and send whatever data I wish.
It is an extremely useful tool for testing my code.
http://www.sena.com/download/manual_bterm/overview.html is where you can find it.

Is it possible to exchange messages between 2 android devices through wifi?

I am currently working on the creation of an application for mobile devices with Android which should be capable of sending and receiving messages through local means like wifi and bluetooth. After making a research about it I found out that Android doesn't have a native wifi ad hoc functionality and that the only way to achieve that is through rooting your device and patching the wpa_suplicant and some other similiar methods which are not generic for every device.
Synopsis of what I am trying to achieve:
An application for Android that scans for devices nearby and tries to connect to them automatically. If the other device also got this application isntalled then it automatically accepts any connection request it receives and when the connection is established it sends back a message which ensures that it has this app installed so that both can start exchanging messages automatically and the users don't have to allow/deny any of the sending/receiving in real time.
My questions are:
Is there any way of sending messages through wifi between 2 android
devices without the use of internet?
Since Ad Hoc is not supported, is there any alternative?
In case the answer to 2 is no , then is it possible to make one of
the devices to be an access point so the other can connect to it and
vice versa.
As for bluetooth, is it possible to skip or automate the allow/deny
pop up of an incoming connection and the pairing procedure?
I'll be glad if you could give me an answer to those and/or any suggestions.
You'll be able to communicate between two devices over wifi without a router/access point using Wifi Direct (P2P) in Android 4.0.
Otherwise, I don't believe you can achieve this over Wifi (bluetooth would be the next best alternative). Since 2.2 you can set your phone up to be a Wifi Access Point (for tethering your device's network connection), but during this time, the Wifi hardware is unavailable for normal use. If you had 3 devices it could work (1 AP, 2 connecting to it).
Is this for a constant connection, or a one-off small delivery? You could use NFC if you want to transmit a URL for example (Android Beam integrates this type of sharing in Android 4.0, but could implement it in 2.3).

Categories

Resources