Android app Http requests communication over USB OTG with Arduino - java

My Android App is communicating with Arduino HTTP server over WiFi. I need to change communication way from WiFi to USB OTG. I'm beginner in this area so my question is: When I change to USB OTG can I still use http request from Android app to Arduino server ? It will be working as before or is it not possible ?

surely it won't be working out-of-the-box, USB isn't IP protocol, thus HTTP isn't applicable to this transport. use UsbDeviceConnection and UsbInterface, still you can use currenlty used data structure, only transport will change. some DOCs about USB in HERE

Related

Make an Android App receive data from a non-Android App using Wifi

I am working on an app that will act as a dashboard for an electronic card installed in cars and trucks.
I need the application to be able to receive data from this card, so I can display it in various ways on the app.
We chose Wifi for the communication method. To access the card, my app is able to connect to a Wifi network created by it.
I would like to receive JSON sent by the card every second.
I need help on where to start to make the two devices communicate, and what are the good practices on implementing this kind of communication.
The app basically act as a client, and the card as a server.
I found something about sockets, but it seemed to use two Android devices, a server and a client, so I'm kinda stuck here.
I use Android Studio 2.1.2 with the Android APIs ranging from 19 to latest.
One option is to broadcast with UDP the data within the local network. The moment the android device connects to the wifi network it will be in its local network. So the data can be received at the android end with a multicast receiver(check out http://jgroups.org/ ).
Refer example
It may also use the p2p sharing with TCP and bind the device with static IPs for communication. Create a simple socket receiver at the android end and a service at the device end. Depends on the way you choose it.

Creating a Wifi peer to peer connection between Android and PC

I have a question about the p2p functionality of Android OS (4.x and higher). I have a PC program that makes use of the Boost C++ library that can function as a server or as a client. Now i have a Android app that has a server using Java sockets. This program need a accesspoint to connect to each other.
I'm looking for a way to connect the Android server and the PC client program without a accesspoint. After looking around i found out that Android has a p2p library.
Android P2P
As a read it you can only connect two Android devices with each other, my question is if it is possible to use this library to connect the Android device to the PC using wifi p2p? Or if there is a other possiblity? All suggestions are welcome!
Roy, have a look at this: http://en.wikipedia.org/wiki/Wi-Fi_Direct
WiFi P2P is now called WiFi Direct, and it is indeed possible to connect two devices as long as one of the devices supports it. So Android device in P2P mode and a PC without any special configuraiton should work fine. However, the PC can (probably) only connect to one access point at a time, from its perspective the Android device is the access point, it would have to disconnect from its usual access point to connect to the Android device.
Also check out SoftAP.

WiFi connection via android

I need a tutorial on how to process data on android via wifi. F.e., I need to send some message to PC and receive some other message. How should I establish the connection? What should I do to be able to transfer data and how?
Sorry for the dummy question, but I can't find good manual. I'll be grateful for as detailed manual as possible, or for ome simple example on etablishing wifi connection and sending/receiving simple mesages.
You don't have to use any API for connect to wifi its only requires if you want to manually start your wifi in device,
Just make sure your device has a WiFi enable, and make a simple TCP/IP Socket application. With this you can communication with your system and device, And Use System's public IP to connect with your system.
Also don't forget to give permission Internet in your manifest file..
Here some nice links for Socket Programing in Android..
Simple connection example part II - TCP communication
Networking with Android
Simple communication using java.net.Socket
http://www.anddev.org/tcp_sockets-t276.html
http://www.anddev.org/socket_programming-t325-s30.html
EDIT:: Android WiFi examples,
Scan for Wireless Networks
Using WiFi API
SO Question Android: Is there any way to get notified when known wifi networks get in/out of range?

sms through usb port using java

I have connected my nokia through data cable to USB port. I need a program in java to access the gsm module of my mobile and send text messages.
which API i need to use for it? communication need to be taken place through USB port.
Thanks & Regards,
Sri
You can use smslib. It is a very reliable solution. It supports GSM phones and GSM modems connected via serial port interfaces or IP interfaces.
Look here for more.
Have a look at Kannel. It is not a Java application, BTW.
Java API for Kannel
An Example
Sending SMS with SMPP, Kannel and Java
The phone needs to be hooked up via a serial port for RS-232. Using either a USB data cable or a USB-to-RS232 adapter and a serial data cable.
Use Java Communications API to connect to the Phone.
Then use the AT command to send and receive SMS messages. There is and example here. It is not specific to Nokia, but it is pretty much a standard command set.

HTTP interface for Android application

Hi: I want to implement a http remote control for an Android application: From a browser on a computer in the local area network the application running on the Android device should be controlled.
Are there any recommendation how to implement this? I heard about i-jetty but it is not uncomplex to integrate it into an existing app.
The problem you're going to run into here are:
Android devices are mobile. They do not have a fixed IP address or DNS address. You'd need to implement some sort of discovery service.
Android devices move between networks, and some networks will have NAT. You won't always be able to contact the device.
My advice here would be to use the new Android C2DM service and push a command down to the device telling your application that there's a request waiting. Once the notification arrives, have your application contact a web server at a known address to see what the request actually is.
In other words, you'd be running an intermediary web server that proxies requests on behalf of your Android device.
More information about C2DM can be found here:
http://code.google.com/android/c2dm/

Categories