Using Bluetooth to RECEIVE file - From Mobile to PC - c#

I took me several time and days to research and try some codes applicable to my problem but unfortunately I wasn't able to see codes that pair and receive files (text, images etc..NOT audio or video in particular) from a mobile device.
Most of the examples found are for SENDING only (From PC to Mobile).
I have bluetooth device (USB) physically attached to my PC.
Summary:
All I need is a sample code that automatically detect/pair when a device is trying to send the file (like in Kodak kiosk but not limited to images only).
I also wanted to understand and study the code.

Perhaps use my 32feet.NET library and its ObexListener class see e.g. http://32feet.codeplex.com/wikipage?title=Server-side&referringTitle=OBEX
For more advanced scenarios use Andy Hume's Brecham.Obex library and his server sample application. See http://inthehand.co.uk/files/folders/objectexchange/entry9942.aspx
Which Bluetooth stack does your PC have installed? Microsoft, Widcomm, BlueSoleil...? See e.g. http://32feet.codeplex.com/wikipage?title=Supported%20Hardware%20and%20Software On Widcomm for instance the build-in OBEX server would have to be disabled to allow your server to get all the incoming connections...

Related

Is there a way use Bluetooth LE libraries C# in Windows 10 to communicate with sensors or micro-controllers?

I spent some time looking for ways to exchange data from a micro-controller Bluno Beetle from DFRobots that uses Bluetooth LE and a desktop application written in C#. DFRobots actually has a code (in Java Android), where they use GATT profiles to exchange data from/to the micro-controller and an Android Phone. I tested this app myself and it works perfectly. I would like to have a similar application written in C# running on a Desktop. I recently bought a BLE dongle (the cheapest option I found on Amazon) which I can pair successfully.
So far, I found solutions that involve using UWP, being one of those an example for exchanging data between a Windows Phone and a Heart Rate monitor, and very little documentation on how to accomplish that for Desktop applications here and here, that involve using System.Runtime.WindowsRuntime but no other information about how to connect to a device or listen to what is being broadcast.
Do any of you guys know if it is really possible to accomplish that? And if so, are you aware of a tutorial I could use to help me?
Thanks!
but no other information about how to connect to a device or listen to what is being broadcast
Here is an official and complete BLE client/server sample which you can use as a starting point
Look into the BTFramework library. We have worked with it for years. It took one afternoon to establish good communication with an ioT device this week. We are using C# NET, by the way. Their libraries have worked well on all platforms from the latest versions of Windows 10 all the way back to barely-functioning XP machines, skipping Vista of course.
As to the dongles you can buy... we support a commercial product using those dongles, and found their marketing claims don't always support their performance. Some work fine for a day, then fail, then work again. And one large batch from one vendor may work fine, but a batch purchased months later may have a high failure rate when you are pushing the envelope.

Which bluetooth connection type is the right one to choose?

I have a Samsung Gear S3 (running Tizen) with a selfmade web-app for logging Data from the heartrate monitor as well as from the Pedometer to a .csv-file. I would like to send each line in the .csv via Bluetooth to an UWP App. As I am a total beginner with C# and Bluetooth connections, I am struggling to understand the basic concepts of the different connection modes.
So here my question: In my specific usecase, would I choose RFCOMM, GATT or LE?
Thanks in advance.
Seems a vast Issue. I would suggest you to check out this post for now:
GATT over SPP profile for bluetooth communication?

Windows iot/apps Programmatic Bluetooth Pairing

I'm trying to broadcast a bluetooth signal from a Raspberry Pi 2 running Windows Iot Core so that I can connect to it from smartphones and other devices, but I've been stuck for the last couple days on actually receiving a pairing signal.
Using the Windows Bluetooth docs I am able to broadcast the signal and I can see it from my desktop as well as from my phone.
However, this is as far as I can get. I want to be able to pair without a PIN (the device will not have a screen), but the pairing fails any time the device is selected.
I am using
SocketProtectionLevel.BluetoothEncryptionAllowNullAuthentication
and
DevicePairingKinds.None
But the connection callback is never hit. I have looked at many similar questions that are either unanswered or do not have the appropriate information since I am using an RPI2 and not a desktop app.
I am not looking to pair via the web interface, but simply through code
.
[UPDATE]
I've tried the 32feet.NET library but it appears to be too old to support the PI2.
I also tried a few NuGet packages, nothing seems to work yet.
I am not master in IoT but recently, I have started exploring it so I know Raspberry Pi 2 is hardware and we can use it to develop some basic IoT device/concepts. I can not help you with the code but may be with some idea.
I remember, for making any embedded system, we used serial port of pc and transferred command to devices. Something similar I found in one of the tutorial from David Jones. It is about to connect Bluetooth to windows 10 using serial port.
In both the explanations, SPP (Serial Port Profile) is used and also Universal Windows App is referenced. May be you get some start point or spark to comlete you work.
Check this and this. It also uses RPi 2.

GPS Windows Mobile 6 (using Microsoft.WindowsMobile.Samples.Location;)

well guys, i am part of one team. (I dont have the project yet, i am new).
They did a application using gps, problem is it fail sometimes...
why? they think gps fails because users has the device in "energy saving" mode; then the device hibernates
after 5 minutes if they dont use it.
GPS brings sometimes bad coordinates (for example coordinate shows users is on "SEA" or in "Japan". I repeat, My partners thinks problem is because device is in "energy saving" mode. how can i change this configuration with C# while application is running (maybe back old configuration when application has been closed).
I am using this library.
using Microsoft.WindowsMobile.Samples.Location;
I can't check if it works because now i dont have a device, and i my computer doesn't have GPS, do you have any idea for i can check the application?.
i am using
`"Windows Mobile 6.0 SDK"`
You can install networking functionality while using the Microsoft Device Emulator. This blog explains how to setup network functionality on Windows 7. Follow the official documentation if you're not using Windows 7.
You can emulate GPS functionality using the FakeGPS program supplied by Microsoft. If you want anything close to real data you'll need a text file containing raw NMEA to feed into FakeGPS. You can simply record bytes passed through the GPS COM port to a file to generate a NMEA file. If fake GPS doesn't like your file then remove the non-standard NMEA lines and try again.
You should do some research on Windows Mobile Power Management first to understand the problem. The quickest hack is to simply call SystemIdleTimerReset() more frequently than the battery idle timeout (use SystemParametersInfo() and SPI_GETBATTERYIDLETIMEOUT) to prevent the device from sleeping. This will decrease the battery life of the device! There are other more elegant solutions available such as using the Power Management API.

Connect and disconnect USB programmaticaly "WITHOUT UNPLUG AND REPLUG"

I need to connect and disconnect USB programmatically. That is, I have inserted the USB device. I need to transfer the file using C#, .NET application. The application will watch the particular folder and transfer the file from that folder to a USB drive. I need to disconnect the USB device after the file is transfered and connect the USB when needed - without unplug and replug.
What would be some code to do it or is there any DLL file available?
Main thing: NOTE, NOTE: Without unplugging and replugging the USB device.
If your goal is to make a certain disk volume unavailable while you're not using it, a more sensible approach might be to use the volume management APIs, e.g. by using the IOCTL_VOLUME_OFFLINE control code. (I'm assuming that you know which drive letter belongs to your USB disk.)
Alternatively, you can disable and enable the volume device programmatically with the CfgMgr / SetupAPI -- the same as right-clicking the volume in Device Manager and choosing Disable would do. (For information about using SetupAPI, please review the DevCon sample code provided with the Windows WDK, and see MSDN for functions such as SetupDiChangeState.)
The latter option might require a privileged user account.
I'm not exactly sure, but it can be done. In Linux, I've experienced certain situations where power is disconnected to a device programmatically. The kernel usually does this if the connected USB device is exhibiting too many errors. So, it should be possible to do this even in Windows. You may need to write your own external DLL to do it though.

Categories