1

Is it possible for 2 android devices to send broadcast packets (over wifi technology) from one device to another device without connecting to the same network.

Imaging when 2 devices doesn't have any network connection.

I already got my phones rooted and I'm trying to send a broadcast packet ( like a beacon packet ) over the air and catch it at another phone.

I'm so open to every solution that lead to my expected result (not just broadcast technique).

Phakin
  • 125
  • 2
  • 13
  • 2
    Answer here, find you not. Magic you seek! – Simon Feb 01 '14 at 18:35
  • 1
    broadcast it is not for networking connections , and you can using some other techniques in transferring data between devices with Bluetooth – mohammed momn Feb 01 '14 at 18:38
  • @Simon What does that mean?? – Phakin Feb 01 '14 at 18:39
  • @mohammedmomn I'm trying to make it work over WiFi technology. Thanks – Phakin Feb 01 '14 at 18:39
  • you can using sync offline connection , but your app will depend on connection also here – mohammed momn Feb 01 '14 at 18:41
  • @mohammedmomn I have no idea what is "sync offline connection". Can you explain a bit about it or give me some direction. Google it didn't help too. – Phakin Feb 01 '14 at 18:43
  • when you want to send data to another device and there is no network connection , you can save the data in some where , and when the app find the network is available it will send it throw the network – mohammed momn Feb 01 '14 at 18:45
  • @mohammedmomn Sorry. That's not what I want. I want to send an instant message to another device. Thanks for your help by the way :) – Phakin Feb 01 '14 at 18:47

3 Answers3

2

What you want isn't easy, but there may be some ways to accomplish it depending on the devices you need to support.

WiFi P2P (Androids implementation of the WiFi Direct interface), does can be used to create ad-hoc connections between devices without a connecting both to an access point. But - you will need Android 4.0 or higher AND a device that supports WiFi Direct.

The API includes a discovery protocol, so to achieve a broadcast like functionality you may be able to iterate through the devices in turn.

Android docs: http://developer.android.com/guide/topics/connectivity/wifip2p.html

Of course - even once you've achieved a network level connection you would still want a library to handle the messaging, and RabbitMQ as suggested by Neo might be a good fit for that.

Another option, if your message to broadcast is very small (and not secret!) - is to manipulate the SSID of your WiFi signal. A very small message could be put in the SSID and then received on other devices by polling the available networks list. See this question:

Can an Android device broadcast an SSID?

It would be interesting to know how you get on with this.

Community
  • 1
  • 1
James
  • 3,252
  • 1
  • 18
  • 33
  • Both of my phones support WiFi Direct :). Actually, I'm thinking about broadcasting a packet over the air and capture it at another phone (like beacon packet of Access Point). Thanks – Phakin Feb 01 '14 at 22:31
  • And your message is too big to cram into the SSID? (maybe you could try and tamper with the other fields on the beacon frame if you've got a low level API). One thing to watch out for is that I think that to comply with licence restrictions in some countries you have to actually transmit Wi-Fi in the Wi-Fi bands. Creating your own radio protocol and using the Wi-Fi hardware to transmit it might be frowned upon :-) – James Feb 01 '14 at 22:45
1

you can use the SSID (32 Byte String) to send message. For every message sent need to sent Beacon packet with 32 Byte message, which again your client may or may not receive. also everyone else will see the message until you somehow sent encrypted string.

0

What you are trying to do over Wifi Network is Called "Publisher Subscriber Framework"

one or many android devices publishes data and one or many subscribers receive data .

Java has a a framework in this called Java Messaging Service JMS

Publish/subscribe model

The publish/subscribe model supports publishing messages to a particular message topic. Subscribers may register interest in receiving messages on a particular message topic. In this model, neither the publisher nor the subscriber knows about each other. A good analogy for this is an anonymous bulletin board.

  1. Zero or more consumers will receive the message.

  2. There is a timing dependency between publishers and subscribers. The publisher has to create a message topic for clients to subscribe. The subscriber has to remain continuously active to receive messages, unless it has established a durable subscription. In that case, messages published while the subscriber is not connected will be redistributed whenever it reconnects.

JMS provides a way of separating the application from the transport layer of providing data. The same Java classes can be used to communicate with different JMS providers by using the Java Naming and Directory Interface (JNDI) information for the desired provider. The classes first use a connection factory to connect to the queue or topic, and then use populate and send or publish the messages. On the receiving side, the clients then receive or subscribe to the messages.

IF YOU THINK THATS WHAT YOU WANT YOU CAN USE RabbitMQ for android.you can use it to send messages over local network

Here is the link where you can start LINK

Neo
  • 1,359
  • 14
  • 34
  • The thing is I don't have a local network. Both 2 phones turn WiFi on but don't connect to any network. Is this going to work? – Phakin Feb 01 '14 at 20:26
  • can you share the adhoc connection first between 2 devices @Neo? After than the rabbitMQ seems fine to be the 2nd topic. – gumuruh Jun 23 '14 at 07:05
  • Hé didn’t asked about abstraction layers. He asked about the network layer: how to send data over WiFi without a connection. JMS will not help here. – TjerkW May 06 '22 at 06:20