Bluetooth SPP device on Windows 8 - bluetooth

I've been banging my head against the proverbial wall trying to working out how to talk to a Bluetooth device that uses the Serial Port Profile (SPP) in a Windows 8 Metro-Style App. I'm starting to come to the conclusion that it's not currently possible, but was wondering if anyone else has been able to get this to work, or can think of anything to try.
There doesn't seem to be an API available to do this, but would it be possible to connect to a device at a lower level?

According to a Microsoft rep, this is not possible in Metro:
http://social.msdn.microsoft.com/Forums/en-US/tailoringappsfordevices/thread/0cb2a6c1-d1f1-4872-aa32-709acd90b94d
It should be possible to write a custom driver to accomplish this, but that is significantly more of a challenge than writing a Metro app.

Related

ESP32 Bluetooth Pairing To Phone

I am trying to make it so that my ESP32 board can detect my phone when I approach it based on RSSI. However, the ESP32 cannot see the phone unless the phone is in discovery mode, which is not super useful. To solve this, I was hoping to pair my phone with the ESP32 so that the phone would always be looking for the ESP32, and connect when it is found without any human intervention.
I decided to try the Arduino integration, but as I was working through all of the examples I couldn't find any with this functionality, so I'm kind of lost. If this is not possible or easy with Arduino, I am willing to switch, but I was unable to find anything about pairing in the normal phone interface for ESP-IDF either.
So, basically, using an ESP32, how do I pair to a phone?
The easiest way is to make the esp a gatt server and advertise a specific service. The phone will look for that specific service and connects if found.
You could make an app for your phone, like for ios its pretty easy. But keep in mind for mobile devices a continuous search for devices could be power unfriendly if misused.
If you use esp-idf instead of arduino, some examples are included. (You could use the vscode integrated esp-idd) Check learnesp32.com for an easy step into the basics, coming from Arduino.

What language/libraries best for BLE connectivity?

Operating system: MacOS
Just for some context on what I am trying to do, I have an Ikea standing desk which has bluetooth. I am able to control the desk with a built in app. I want to create a server running on a raspberry pi that connects to desk and controls it, I then want to create an Alexa skill which will control the desk by calling the server endpoints.
What's the best language/library you would suggest I use? Ideally something that would run on MacOS and Ubuntu.
I don't know anything about BLE yet which is why it is hard for me to find a good answer. If you have resources, books or tutorials that will help me get running with BLE please recommend them.
My use case:
Get desk to go up
Get desk to go down
Get current position of desk
If you want to write one app that works for both MacOS and Ubuntu then as ukBaz said, python and Bleak are your best options. If you want to use the native way of writing BLE apps for each OS, then you can use CoreBluetooth on MacOS and BlueZ on Ubuntu. The advantage of the former is that you can get an application up and running quickly, and the advantage of the latter is that you will find a lot more resources and advanced functionality.
Below are some resources that can help you in your development:-
Theoretical Bluetooth:
Bluetooth Low Energy: A Primer
Getting Started with Bluetooth Low Energy
Ellisys Bluetooth Series
CoreBluetooth
Getting Started with CoreBluetooth
Ultimate Guide to Apple's CoreBluetooth
iOS App Full Example
BlueZ
Configuring Bluetooth devices with bluetoothctl
Ubuntu: Accessing GATT services
Python
Ikea IDÅSEN desk API and CLI
Idasen controller example
Using Python for Bluetooth

Bluetooth Find Devices

I building a application that contains bluetooth functionality. Everything works find and to test it.
The question is, is there any way I can simulate a devices bluetooth so that my application can discover it. I need to test it for around 30 devices bluetooth, seems like unreasonable for me to go find 30 real devices.
If someone could point me to an existance app or article to refer would be helpful.

Bluetooth LE from Cordova app to Linux device

I need some guidance. In a nutshell, I need to be able to configure and control a device with the smart phone app over BLE.
For example, change IP address of my Raspberry Pi. To make that happen, I need 2 things.
Simple Android/iOS app that takes IP address parameters as an input, and then communicates over Bluetooth to the RPi. Note that the device needs to be discovered and connected from within the app (without going to "Settings" and pairing).
Build some server process on the Raspberry Pi that listens to USB Bluetooth dongle, receives the command with parameters and acts accordingly.
So I need help building the BLE portion of this project.
I have several years of smartphone app development experience, and 10+ years of Linux system programming. In other words, building a simple Cordova app, as well as Linux process that changes IP address is really not an issue.
However, I am totally new to Bluetooth. Can you point me to the right direction? I am sure this problem has already been solved few thousand times. Is there a tutorial? Or maybe a skeleton code I use as a starting point? Also, any recommendation for BLE USB dongle?
Thanks a lot!
I think it will be harder to find a better guide to implement low energy technology on the RaspberryPi than this one :
https://learn.adafruit.com/downloads/pdf/pibeacon-ibeacon-with-a-raspberry-pi.pdf
After this , you can download a random app on the Playstore/Appstore and check that your RaspberryPi is actually acting as a BLE device.
Finally you can start creating your own app using several available BLE plugins like :
https://github.com/randdusing/BluetoothLE
https://github.com/don/cordova-plugin-ble-central

Auto Detect Windows Mobile Device programmatically

I am writing a windows application (written entirely in C++) which reads files from a storage card on a mobile phone running Windows Mobile. The tough part is, I don't know how to make my application detect the event that a user has connected the mobile phone to the USB of laptop. I did some reading on MSDN and have written a small code using RegisterDeviceNotification, which detects whenever a USB disk is attached/removed from the laptop. However, I am unable to tweak this to make it work for phone type devices. Please help me out through any links/tutroials which explains this(preferrably C++, as I don't know .NET or C#).
Thanks
Alok
According to this article you can use RegisterDeviceNotification to get notifications when activesync detects a device has been plugged/unplugged. (See option 3 at the end of the article)
It may just be a matter of setting up the correct notification filter.
Windows Mobile devices use RNDIS, a network interface protocol behind the scenes. Hence, the RegisterDeviceNotification method still works, but you're looking for a DEV_BROADCAST_DEVICEINTERFACE, not DEV_BROADCAST_VOLUME. (i.e. dbch_devicetype==DBT_DEVTYP_DEVICEINTERFACE)
You can use RAPI or RAPI2 to detect when a Windows Mobile device connects to a PC via Active Sync or Windows Mobile Device Center. RAPI can also be used to read the files on the storage card and much more.
RAPI is simpler to program because it is a C based API. RAPI2 has more functionality than RAPI, but is an object oriented COM API. If your needs are simple and you only care about one device/connection at a time then RAPI is good enough. There are two RAPI functions used to detect connections: CeRapiInit (blocking), and CeRapiInitEx (signals an event upon connection).

Resources