How can i send data by USB port in Android C#? - c#

I am developed a app in Visual Studio with mono for android. C#
So. How can i send data by USB port in Android. C#?
The type serialPort1.Write("1");

Long story short - you can not do it the way you intended. USB is not a serial port that you can just write to and data comes out on the other side.
Serial ports can be emulated over USB, but Android does not support that. Android typically can act as device that offers different profiles: disk, camera and proprietary debug (if enabled on device).
Since Android 3.1 you also have two special modes: host mode where Android device acts as a host to usb devices (much like PC does) and special proprietary accessory mode. Read more about it here: http://developer.android.com/guide/topics/usb/index.html

Start here: Android USB Api

Related

Discover Nearby Smartphone Devices on Android

Problem Statement
I am trying to make an application for Android that can detect nearby smartphone devices. I need to discover smartphone devices regardless of their connection to a WLAN or their operating system. The only requirement is that their bluetooth or wifi setting is enabled. I am trying to capture the MAC Address and maybe RSSI of these devices. An example of an application I am trying to emulate is Meshlium.
Methods Already Considered
Android Classic Bluetooth:
I have followed the guide to discover devices that aren't currently paired with my device.
The smartphones I am trying to discover need to be in "discovery" mode in order to be found. For most modern phones that means they need to be on their bluetooth settings page.
Android P2P (Wifi Direct):
I have followed the guide again and can't discover smartphones nearby.
Similar to bluetooth, both devices (mine and the device I am trying to find) need to be both trying to discover wifi direct devices.
Also it seems iOS doesn't support wifi direct anyways.
Google Nearby:
Nearby Connections works only with devices running an application that is using the nearby connections api. So only devices with the app currently running the advertising or discovery feature will be available for detection.
Wifi Network Service Discovery:
This lets me see devices that are currently advertising services on a network and not the actual devices themselves.
Device Specifications
The device I am using is running android version 6.0.1 and Model number rk3368-box. The device also has root permissions.
Question
Is there a way on my android device to discover the nearby smartphones with the only requirement being their wifi or bluetooth is enabled? Perhaps packet sniffing the probe requests of the devices? I have researched packet sniffing but can't find any solid resources for Android. Also I would love to be able to do so in c# and Xamarin.Android if possible.
Update
Is a custom ROM an option? I am not looking to make an application for the play store, but one for custom hardware. Perhaps when I enable the wifi hotspot on the device it logs the probe requests from the devices nearby and saves as a file to export later?
There is no way to do this. And there shouldn't be- unless I'm working with you (in which case multiple of the above will work) its a massive invasion of my privacy for you to be able to detect my device.
If you are able to find mac address for WLAN adaptor of a device than try to search for bluetooth devices having mac address same as WLAN adaptor but last digit changed by 1.
This way you can find a Bluetooth device even if it's visibility is hidden

Can two .NET apps on same Windows 10 computer communicate by USB with each other without a USB loopback cable?

So, the 1st app is the USB host, and the 2nd app simulates a USB device.
After that, I would then like to test using a USB loopback cable, which it seems needs a USB bridge -- sometimes called a USB to USB adapter.
Next, I'll test same app running on two computers.
And, ultimately I need to test communication between GUI .NET app on Windows 10 (the USB host) with USB-2 connection to an embedded ARM (the USB device). And, the embedded is not avail yet.

Stream audio from device to computer (Windows 10) via bluetooth & 32feet lib

I would like stream audio from a smartphone-device to the computerspeakers(Windows 10)
So far, I can make a connection between the two devices with the Bluetooth headset-service. Whilst the sound on the smartphone is muted because of the active Bluetooth-connection I can't hear any sound coming out of the computer. I don't receive a bitstream with the 32feet getStream-method either.
Windows 10 does not support the Bluetooth A2DP SNK profile, so streaming music will not work unless you build the profile yourself.
When audio is streaming between to Bluetooth devices, the host (in your case the smartphone) uses A2DP SRC to send the audio. The endpoint (Windows 10) has to support A2DP SNK to correctly receive the audio. You can find the full specification for A2DP here.
Finally. Here's the solution I found:
First, pair your android to your PC, then, make sure that audio stream option is enabled in bluetooth preferences (this is in the Android device. You might need to change some stuff in developer options for bluetooth).
Finally, install Bluetooth Audio Receiver from Microsoft store. Open it, select your android device and click on "open connection" and you're done!

Bluetooth connection with Unity 3D c#

For a medical application I have sensors that can send (HEX) data over Bluetooth. I would like to use this data in Unity to give visual feedback to users. I already have a working Bluetooth connection via Serial Port but the Program should search and connect the device dynamically. I also build a Visual Studio application by using the 32feet.net API and it works fine. But it should work with Unity in C#. Is there an API like the 32feet.net in VS for Unity? I am not sure if the 32feet.net API runs with Unity as well, but I was not able to make it work. If there is a documentation how to implement 32feet in Unity it would be great. Otherwise I need another opportunity to communicate with my bluetooth device (except using serial port).
EDIT: SocketException: An address incompatible with the requested protocol was used.

Can I use the Bluetooth serial port in Windows Phone 7.1 and up?

I want to develop an app for the Windows Phone app store that communicates with my car's OBD2 port via Bluetooth.
Long story short, the app will use the bluetooth serial port to send a hex value and retrieve the corresponding value in the ECU's register. There's an android app called Torque which does this.
I can't figure out how to use the serial port though. The only bluetooth functionality mentioned is high-level stuff like pushing objects, pairing, etc. But nothing about setting baud rates or writing to a specific COM port.
Is this possible on WP7/*? Or alternatively, how can I make this possible and get my app approved for distribution?
UPDATE: I haven't been able to get my hands on a WP8 device yet, so I can't verify whether or not this is possible using SSP.
As a bonus note in case you came here looking for alternatives: you can also NOT connect to ad-hoc wifi connections, so the wife-based OBD2 adapters are no good either. There is an ugly way of connecting to the latter which involves having a laptop in your car which is simultaneously connected in ad-hoc mode the the device and is also acting as a wifi hotspot. It is utterly impractical.
Using the Bluetooth Serial Port (SSP) is not possible with public APIs of Windows Phone 7.x. As you've kind of guessed already, the app will likely not be approved for the marketplace if private APIs are P/invoked or otherwise used.
Consider upgrading to Windows Phone 8 as the Bluetooth SSP is partially available there, see Nokias Developer site for example.

Categories