Remote bluetooth camera trigger for phone - python

I would like to build a camera trigger for my phone by simulating a BLE keyboard that sends the Volume Up key to the phone connected by Bluetooth. I want this because I want to trigger the native Camera app, and not an embedded camera view.
I'm agnostic about technology used but ideally for simplicity I'd like it to be a command line utility in my Macbook, with something like Go or Node.js.
I've looked into Noble for Node.js, which doesn't seem to be oriented at emitting, and found projects for arduino, and found a couple of StackOverflow questions asking the same, but nothing definitive yet.
Apparently the Bleno project for Node.js could be better suited, but apparently it's very outdated.
Would someone please point me in the right direction?
Thank you
Edit
I was able to use Bleno to emit 0xEA and 0xE9 (Volume Up and Volume Down apparently), and using the LightBlue app I'm able to inspect that receive those messages, however, connecting to the MacBook through the phone's bluetooth does not increase/decrease volume.
Edit
Found this outdated project written in Swift 3 for reference
Edit Apparently the pybluez project looks like it could be a good option

You should be able to use the terminal for that. Eg. in Windows, you can start the camera app using start microsoft.windows:camera
Something similar should be available even in Mac. Try that out. Otherwise, go to the root directory where the camera app is stored. And then trigger that from code.

You need to create a Bluetooth HID (or HID over GATT) peripheral that your phone can connect to and will receive the key commands from.
There is a project here that did it with a Raspberry Pi:
https://gist.github.com/ukBaz/a47e71e7b87fbc851b27cde7d1c0fcf0#gistcomment-2997623
Unfornately the underlaying Bluetooth library will not move across to your Mac Book.
The HID protocol is documented here: https://github.com/jpbrucker/BLE_HID/blob/master/doc/HID.md

In summary, I think what your saying is that you want to make an cli application which is on your laptop/desktop connect to your phone via Bluetooth and simulate a volume key from your laptop/desktop keyboard.
Android:
To do this you will need:
Python 3.5 or above
PyBluez
Keyboard(Python module/API)
Android Studio
Java Development Kit 8 (preferably 11 or 14)
Android BLE
So in order to do this I would create a cli application with python3 and I would record the key presses on the laptop/desktop machine by using the keyboard module this then gets transmitted(bluetooth) via the PyBluez module to your phone. Your phone then accepts the bluetooth data via Android BLE and then simulates the volume button press.
DISCLAIMER:
This only works when the phone is already paired to your pc and only work on android phones 4.4.4 and above.
Some Links That Could Help You:
Bluetooth lib for python 3 ,
detect key press in python? ,
Create a socket for 4.0 bluetooth transmission
IOS:
To do this you will need:
Python 3.5 or above
PyBluez
Keyboard(Python module/API)
XCode
Swift
Core Bluetooth Module
So in order to do this I would create a cli application with python3 and I would record the key presses on the laptop/desktop machine by using the keyboard module this then gets transmitted(bluetooth) via the PyBluez module to your phone. Your phone then accepts the bluetooth data via Core Blutooth Module in swift and then simulates the volume button press.
DISCLAIMER:
The phone and laptop/desktop must be paired before it runs this might sound obvious but some people might ignore this.
Some Links That Could Help You:
iOS use the volume buttons as input ,
https://developer.apple.com/documentation/corebluetooth/transferring_data_between_bluetooth_low_energy_devices

Related

FTDI 232H: USB Port 'Locked' to a physical port under Windows

Working with an Adafruit FTDI 232H Breakout assembly. I've already asked at Adafruit and FTDI and I'm still clueless. Writing in Python using the Adafruit-provided libraries and the FTDI libraries. Very new to Python and the FTDI 232H device...
Using Windows 10 Pro
I am able to successfully install the 'drivers' for the Adafruit based on this tutorial (specifically the Windows portion):
https://learn.adafruit.com/adafruit-ft232h-breakout?view=all
In the end, the interface will work, but what happens is that the device seems to be locked to a physical USB port. If I move the device to another USB port on the same machine, it is not recognized.
Based on some reading I've done, it seems like the driver, although installed in Windows, can only associate with the device on one port. Some say that Windows uses the serial number to keep track of what device uses what driver.
I have observed, using USBDView, that this device is not displaying a S/N. I have other devices that do not display a serial number and they can move from port to port without issue. This leads me to believe that the S/N tracking may not be 100% true in Windows. The Adafruit board does have a S/N in the EEPROM, but for some reason that information is not being provided to Windows / USBDView. I've not been able to successfully access the EEPROM via the FTProg utility.
I suspect that this might have something to to with the libusbK library that is installed via Zadig tool (again in the instructions) but I am not sure. FTDI says that there should not be any issue using the libusbK library.
Can anyone out there give me some pointers on:
Is it accurate that Windows uses the S/N to keep track of what driver goes with what device?
If so, how to get the FTDI device to display the S/N?
Is there some other setting in Windows that needs to be changed to allow this device to be used on other physical ports?
Is there any other utility like FTProg that could be used to work with the EEPROM?
Am I just missing something simple, Noob-style?
Thank you in advance,
I seem to recall a similar case related to COM port enumeration and Windows where the COM port enumeration is a hash of assorted variables including the PCI bus #, device #, etc. We witnessed this through the Microsoft devcon utility which is priceless and is a command line version of Device Manager.
https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/devcon
https://blogs.technet.microsoft.com/deploymentguys/2009/12/16/where-to-find-devcon-exe/
If you google around, you can find the compiled version of this invaluable tool. With confidence, believe this tool will assist you to debug your USB port mystery. Good luck.

How to control Raspberry Pi's GPIO pins from separate PC

In my application I want to turn on certain GPIO pins that are on the Raspberry Pi from my PC's C++ script. My PC is currently running on Windows 10 and my Raspberry Pi on Raspbian.
The general idea I had was to write python scripts on the Raspberry Pi itself and run them somehow from my PC when needed. Although, I am not sure how to do this or if it's possible in C++. I know I can ssh into my Raspberry Pi and run scripts manually but the idea of this application is automation. I am able to connect my PC to the Raspberry Pi either by Ethernet or USB cables.
I have seen USB to GPIO modules that would probably work better although for now I am stuck with my Raspberry Pi.
Any knowledge or resources on how to do this is greatly appreciated.
Maybe be what you need is a client and server program to control your GPIO pins. Check out my client and server programs and dont forget to read the answer and its comments and make the change accordingly for the program to work.(My progams motives is to control an LED through the client and server programs , similar to controlling the GPIO pins )
Program getting stuck at accept statement
PS: I hope you are having some knowledge about Threading and sockets.
This answer will be pretty broad so feel free to leave a comment with questions.
The first things that are needed, are the python scripts on the Pi which control the GPIOs in however fashion we like. From then on we are able to execute these commands via ssh from almost any device. Although, we want this process to be automated. In other words, the user doesn't have to enter credentials to ssh into the Pi but rather have the program automatically do so.
Luckily, this library allows us to do so. -> https://www.libssh.org/
There is nice documentation as to how to create ssh sessions and executing the commands that we want. So I won't go into much detail. Although I will comment on one procedure that the documentation recommends but gave me a problem.
When authenticating the user via password we use method ssh_userauth_password(ssh_session session, const char* username, const char* password). The documentation suggests setting the second parameter to NULL. Which was what was giving me the problem.
Simply change this to the login name you use when you normally ssh into the Raspberry Pi. For most the default name is "pi".
ssh_userauth_password(my_ssh_session, "pi", password);

Macbook Pro 2015 connecting to a TI Sensortag cc2541

Background - What I would like to do is to be able to push buttons on a BT sensor and trigger some actions like tweet or play a particular sound etc. I have a TI CC2541 Sensortag that I would like to control with a python program.
Issue - I am unable to get Mac OS X bluetooth to recognize the BLE on TI Sensortag.
Attempts - I installed lightblue which recognizes the sensor. But I am not sure how that can help control the sensor programmatically.
I heard about Bluez in my research, but I guess it is related to linux only systems. I have used Evothings and that can connect to the sensortag through my phone on the same network. I can make small changes to the javascript on evothings studio to capture events from the Sensortag and affect changes on the evothings app.
I am trying to get my Mac to recognize the BLE Sensortag after which I can control the device programmatically. Do I need to buy one of these pluggable BLE dongles to get this to work? OR am I attempting something wrong.
Please advise.
Oh I see now, I can help you with that.
Here's your recipe to success:
Make sure that your hardware supports BLE 4.x (yours does)
Link your tag through the preferences/Bluetooth widget
Check with lightblue app that you can connect or read some values
If all the above checks out, and it should given the information you provided, then at hardware level you're golden.
At software level, there are many ways to connect and retrieve data. You can use XCODE and build a native OSX app or you can build a NodeJS app to retrieve data from the tag.
On this blog post you find all you need for the Node scenario. It is documented for the Raspberry Pi however, the code for running this elsewhere, including OSX, is exactly the same
The code is hosted here and I keep it up to date as I make more advancements.
https://github.com/kywix/iamsblog/tree/master/SensorTag
Shortly:
Open terminal and git clone that repo
cd into the folder SensorTag
type npm install (to install all the libraries necessary)
node logger.js to run the basic example
turn on your device
btw on the same repo you will find python code as well. I blog regularly about the Sensor Tag.
I will make note of creating a post just for folks like you that seek this type of info, I have been there..

Communicate between iOS app and Raspberry Pi via Bluetooth

I'm trying to communicate between an iOS app and Raspberry Pi using Bluetooth. The Raspberry Pi is using a Python script for this purpose.
I was originally using the PyBluez library, however this does not support Bluetooth LE and thus can't be used with CoreBluetooth on iOS.
My next solution was to use the private BluetoothManager framework to communicate with the Pi, but this doesn't work on iOS 7.
I've researched a bit more and have seen suggestions for manually sending/receiving LE packets with PyBluez, but this seems incredibly complex and I really have no idea where to start.
So at the moment, I'm stuck. I need either:
A solution to communicate with a non-LE Bluetooth device via iOS, or
A solution for advertising and communicating as a LE device on the Raspberry Pi via Python
One option is to buy a USB dongle with a BLE stack in it already.
We have used the Laird BL620-USB, flashed with BL600 firmware to operate as a BLE peripheral.
Having BLE stack in the dongle means it can be communicated with from the Raspberry Pi like a simple USB serial port, without using any linux Bluetooth stack.
BL600 includes the Nordic / Laird proprietary Virtual Serial Port Profile already, so you can achieve the simplicity similar to the classic Bluetooth SPP, even when communicating to an iOS device.
Laird will provide iOS and Android code to use the VSP on the mobile side.
Other BLE module makers probably do the same.
Have you tried this?
By default, the Wheezy distribution comes without a Bluetooth stack. The bluez package is version 4.99, which has patchy support for Low Energy.
Keep in mind at the time of writing Bluetooth Low Energy (BLE) is not well supported by the standard Raspberry Pi distributions. Some work is required to get it working, as described in the link provided above.
NewAer has built a P2P messaging framework to share 500 Bytes (SDK 5) to 15K with certain devices. That being said, we can send 15K between iOS devices, or iOS and the Raspberry Pi 3. As Android gains further OS and hardware support for BLE, we expect to ad that higher file size as well, but at this time it is limited to 500 bytes between Android and iOS.

How to send data from Windows to embedded linux over USB

My setup looks like this: A 64-bit box running Windows 7 Professional is connected to a Beaglebone running Angstrom Linux.
I'm currently controlling the beaglebone via a putty command line on the windows box.
What I'd like to do is run an OpenCV script to pull some vision information, process it on the windows box, and send some lightweight data (e.g a True or False, a triplet, etc.) over the (or another) USB connection to the beaglebone.
My OpenCV program is running using Python bindings, so any piping I can do with python would be preferable. I've played around with pyserial to receive data on a windows box via a COM port, so it seems like I could use that on the windows side... at a total loss though on the embedded linux front
Normally on the linux front, if the usb dongle is of the right type, you will see something like /dev/usbserial or similar device. Maybe check dmesg after plugging the cable.
(on linux you can run find /dev | grep usb to list all usb related devices)
Just a side note, I've seen the beaglebone has an ethernet port, why not just using a network socket? It's all easier than reinventing a protocol on usb.
If you want to use python, take a look o PyUSB, as you can see for example in Sending data via USB using PyUSB. A related post is PyUSB for the Raspberry Pi.

Categories

Resources