9

I have two Android-Devices, i have no IP-Addresses the Mac-Addresses are

 d0:e7:82:fa:90:33 (a)
 8c:bf:a6:a8:77:8f (b)

how to send a byte from a to b? Is it possible?

EDIT: droped DatagramSocket-Sources because its packed-based.

By the way: Wifi-Direct or Bluetooth is not supported by the devices.

Grim
  • 1,938
  • 10
  • 56
  • 123
  • 1
    Broadcast your message using UDP. – Sarim Sidd May 15 '15 at 12:58
  • But in http://tutorials.jenkov.com/java-networking/udp-datagram-sockets.html they wrote "*With UDP you just send packets of data (datagrams) to some IP address on the network.*". But i have no ip address. – Grim May 15 '15 at 13:02
  • UDP simply broadcast the message and every device on the networks get it, whereas, in TCP you have to have the IP of the receiver device and TCP does not broadcast it unicast the message to the specific device. – Sarim Sidd May 15 '15 at 13:04
  • Got it, thank you, even the sender recivies the message! – Grim May 15 '15 at 13:16
  • Yes, Glad it helps. Posting it as answer so it helps others. Please take a moment to accept it. – Sarim Sidd May 15 '15 at 13:20

6 Answers6

3

You can use UDP to broadcast message. It simply broadcast the message and every device on the networks gets it, even the sender. However, message delivery in UDP is not guaranteed, it may drop. So you need to handle that on client side.

Sarim Sidd
  • 2,166
  • 2
  • 22
  • 31
  • No, the UDP broadcast message does not reaches the other android device. – Grim May 15 '15 at 20:02
  • As i said, message delivery is not guaranteed, it may drop. But its not like the other device will never receive it. Can you please explain what are you trying. – Sarim Sidd May 15 '15 at 21:03
  • To use UDP i need the `DatagramPacket`, but i must specify a ip-address here what i do not have. – Grim May 19 '15 at 09:00
  • 3
    How without maintaining any network you are looking to send message? I think you need to re-asses your requirement. – Sarim Sidd May 19 '15 at 12:54
1

As some mentioned, this is not possible without an active connection!

Because any other way will loose support and warranty:

I realy was able to send packages between those devices in 802.11(by filter uninterresting octets) without beeing connected but all devices must be rooted!

Another solution i successfully handled: was to download the Android OS-Sources and compile a realy own OS having modified permission-checks (loose of warranty).

Grim
  • 1,938
  • 10
  • 56
  • 123
1

Can you use wifi Hotspot technology? Make adhoc network. See Create Wifi Hotspot Configuration or Programmatically Turn on WiFi hotspot or Android turn On/Off WiFi HotSpot programmatically

Community
  • 1
  • 1
0

Your 2 devices should be connected via any network, then we can communicate over UDP protocol using DatagramPaket and more from java.net.DatagramPacket

Note : If we can communicate between 2 devices only knowing their MAC physical address then what is need of network !!

This is contradiction against Network Layer definition

EDIT :

You can use JPcap application but there also your 2 devices should be connected via Ethernet. Check Tutorial and More information

Kushal
  • 8,100
  • 9
  • 63
  • 82
  • *should be* ... but they arent. Did i used the word "network"? – Grim May 19 '15 at 09:17
  • Wait wait, if i ever connect the two devices in a "network" my code works great! No problem here. But i need to message without Network!!!!! – Grim May 19 '15 at 09:20
  • So you need to use network.. this is what i want to say.. without using network, packets cannot be transferred.. Check JPcap application also and pre-requisite for running application – Kushal May 19 '15 at 09:20
  • I dont need a packets, plain octests may enougth. – Grim May 19 '15 at 09:21
  • It is not possible. You are asking to break `Network Layer` ! Please think again – Kushal May 19 '15 at 09:39
  • More.. You written in code `BROADCAST = Inet4Address.getByName("255.255.255.255"); – Kushal May 19 '15 at 09:44
  • Ah, ok, so how to communicate without broadcast? Maybe using a IBSS? – Grim May 19 '15 at 09:51
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/78169/discussion-between-kushal-and-peter-rader). – Kushal May 19 '15 at 10:16
  • I think without network, you cannot send message.. you need any way to communicate between 2 system.. the way is `network` The network may be ad-hoc, may be without internet service anything – Kushal May 19 '15 at 10:46
0

What you looking for is the rich wifi p2p api that android offers. Please see https://developer.android.com/guide/topics/connectivity/wifip2p.html

or for close range small packets: http://developer.android.com/guide/topics/connectivity/nfc/index.html

or for larger range if bluetooth supported: http://developer.android.com/guide/topics/connectivity/bluetooth.html

Steven Mark Ford
  • 3,372
  • 21
  • 32
0

Thats what we have BlueTooth Data Transfer .

Accordning to your criteria you should go for data transfer using BlueTooth .

Here is nice answer clarifies the use of Mac Address .

Here is sample project for Android BlueTooth chat

Community
  • 1
  • 1
Don Chakkappan
  • 7,397
  • 5
  • 44
  • 59