Is it right to send data in J2ME through cable by mean of DatagramConnection? - java-me

I want to send data by using J2ME between a mobile phone and a computer. The two machines are connected by the phone's cable : there is no Wi-Fi , no http connection , no Internet. So is it wrong or correct to use the J2ME DatagramConnection to send data to the computer when the mobile's cable is inserted to the USB port of the computer ?

When you talk about interaction between two systems, first you will need to address the connectivity. In the situation described, the connectivity between the phones is via USB, which is a serial port. So the communication can be done over serial port only.
Datagram can be used over IP networks and other specialized networks.
If for some reason you are unable to communicate via USB, check if you could connect both of them using Bluetooth. If your phone has Bluetooth and the computer doesn't, then you could purchase an USB Bluetooth Dongle for very cheap.
If you are trying to get logs of your application, you can check out Bluetooth loggers for J2ME. There are quite a lot of them. One such library is microlog
Hope this helps.

It depends, if you require high speed of data transfer while can bear some data loss then DatagramConnection is ok, and if you can't bear loss of data packets, then you should use TCPConnection.

Related

Is there a way to relay bluetooth between phones?

I have a device that can only be controlled by bluetooth on a specific phone. Would it be possible to use a second phone to act as a relay or proxy close enough to connect via bluetooth to the device, but kind of feign the connection with the first phone over the network?
You'd want to make a mesh network.
https://www.bluetooth.com/blog/introducing-bluetooth-mesh-networking/

Can i intercept traffic of all nearby bluetooth devices with built into the laptop bluetooth dongle?

I know that bluetooth uses hoping, and because of this difficult to intercept traffic.
Сan i put my dong into monitoring mode?
If for example are 30 devices nearby, and i will always listen just one bluetooth channel, and my dongle works in monitor mode, should i get sometimes some data?
Can i use for these purposes Hcidump or tcpdump?
If I understand correctly, if bluetooth device does not have a password, i can directly interact with its services(with hcitool and tmux).?
I read that i can watch the battery level, device name, and other information.
PS: sorry for bad english.
It is possible to monitor traffic between Bluetooth devices but I am quite sure that your default laptop dongle is not capable of doing that.
Before establishing connection between two Bluetooth devices, they send connection request/response packets on primary advertising channels (37th, 38th, 39th channel). You need to capture these packets to learn hopping pattern, connection interval and etc. After receiving packets, you can monitor insecure Bluetooth connections. However it is hard to monitor 30 device simultaneously because you need to make time division between each connection.
Let's answer your questions.
It might be possible but you need to write driver level code.
It might be possible. As I mentioned, it is good approach to capture connection request/response packets before monitoring devices.
I have no idea about these tools.
To manipulate services, you need to know service handle and duplicate GATT client's mac address. I am not sure that, this method will work.

How to p2p_connect to device with WiFi Direct without MAC Address? (Raspberry Pi and Android)

I have an Android tablet and A Raspberry Pi and I want to established a connection between them automatically when the tablet sends a request to the Pi.
I followed an Android application example here and start discovering any nearby devices. (https://www.youtube.com/watch?v=qnY97iBxp30)
At the same time i run sudo wpa_cli and p2p_find 20. The Android application detects the Pi, and I try to establish connection with the Pi which will display
<3>P2P-GO-NEG-REQUEST TABLET_MAC_ADDRESS dev_passwd_id=4
Normally I would just p2p_connect TABLET_MAC_ADDRESS pbc to successfully connect them together but I find it inefficient if I were to swap to another mobile device.
Are there any other ways to connect the tablet without writing the tablet mac address? For example connecting to that specific device ssid when they send a P2P-GO-NEG-REQUEST to the pi?
TL;DR Nope.
If we look at the OSI ISO 7 layer model for network communication we can see that the Media Access Control (MAC) address is vital for identifying which device is which within a wifi network.
You could try setting up a bluetooth connection or a token-ring, but I suspect that would be more effort than you are looking for.
With IPv6 your devices could use neighbour discovery to automate past the MAC entry to the Internet Protocol, and its possible to connect between devices using their link-local address (fe80::some:thing)
Wifi carries packets of data, that have addresses. By analogy, if I tell you which town I live in, but don't write my building address on the packet, you are going to have a hard time delivering it.

How to communicate with an Arduino circuit using a web app?

I have recently made a Arduino circuit as shown in the link below:
http://www.instructables.com/id/DC-Motor-Control-With-Bluetooth/
As you can see, the person in the video of the above link used a bluetooth controller app to control and send signals to the Arduino board via HC-05 bluetooth board.
Here's the question. How can I use a web app/ web instead of a native app(like the video) to control and send signals to the Arduino board?
It would require the use of additional hardware. It is for connection to the network or broadly web.
Once we consider this we have several options infront of us :
We can use a gsm module. In this hardware we would insert a sim and use its network for connecting to web. But when you buy a GSM module be sure that it got http services as some modules support only message services. ( I would suggest GSM sim 900A module).
We can use a wifi hardware. This would act just same way as wifi on our mobile or laptop. But it requires some hotspot in its range thus restricts portability.
We can connect an ethernet cable to the arduino module and use the network. But thus restricts portability more than wifi. But you can go for that to if that satisfies your need.
Once you get the network for connecting to the web, now comes the point where your device must listen on the web for the requests that come to the device and must act as the inputs. We call it creating a server. The server listens on web and respond to them. As for a beginning you can follow this article.

Can a master Bluetooth device use more than one antenna to connect to slaves?

I'm not sure how to correctly phrase this question, as I'm just starting to learn Bluetooth and its ways, but... imagine holding in an iPhone or Android phone in your hand in a large building with many rooms. You pair your device with a Bluetooth master device via an antenna in that room. Then once you move from room to room, your device communicates with other antennas throughout the building, but the device treats it as one pairing.
Is this at all possible? Was Bluetooth developed with this in mind at all?
Would this still work if the antennas were wireless? My idea is for devices to communicate with nodes via Bluetooth, and nodes interact with central base via wi-fi/local router.
Also, third random question: how does using BLE affect any of this?
Please tell me if I'm crazy! Thanks!
Bluetooth 4.0 BLE allows for a slave to connect to one master. 4.1 BLE allows for more than one connection, but I don't know if anything implements that yet.
Either way, there's no sort of "roaming" method pairing devices like with wifi access points with the same SSID. BLE however doesn't require pairing like regular Bluetooth, so you could just connect to a new access point each time you lose a connection.
You can also communicate via advertising packets from the "antenna" in each room. This would facilitate information being passed from those rooms to the phone, but not the other way around. This is basically how you communicate with BLE when you don't pair/connect devices and is how iBeacons work.
If you're writing the software yourself, and installing it in the building and on the phone, then I think it should be totally possible. Bluetooth devices can detect the distance and direction of other bluetooth devices. So if both devices are running software that is designed to, and grants permission to do so, it should be no-big-deal to programmatically auto-reconnect to the new nearest antenna whenever one becomes significantly closer than the one that your phone is currently connected to. As for software that already does this that you wouldn't have to develop from scratch yourself, no idea.

Resources