pbreneman
Posts: 23
Joined: Thu Jun 07, 2012 12:31 pm

How use phone bluetooth to reboot Zero?

Fri Oct 20, 2017 6:03 pm

I've got several Zeros that send text and emails every 3 hours for temperature and power detection. I'd like to be able to use my Android phone to reboot them about once a week (or change settings later). I'm thinking of using APDE on the phone (see bottom of this page): http://controlpascal.com/self-hosted.htm. When I try to search these forums for "bluetooth" usually the server says it is too busy. Any pointers to examples would be greatly appreciated. Thanks!

User avatar
Douglas6
Posts: 4739
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: How use phone bluetooth to reboot Zero?

Fri Oct 20, 2017 6:47 pm

I've never heard of APDE, so I can't speak to it. You can however run a shell session on the Pi over a Bluetooth serial link, and use a Bluetooth terminal app (or something else) on an Android phone to send a 'sudo reboot' command. Details here: viewtopic.php?p=955425#p955425.

pbreneman
Posts: 23
Joined: Thu Jun 07, 2012 12:31 pm

Re: How use phone bluetooth to reboot Zero?

Sun Oct 22, 2017 10:18 pm

Thank you very much Douglas6 for your help! I copied a bit from the message thread that you posted to here: http://controlpascal.com/self-hosted.htm#RPiZwBluetooth.

Maybe raspi-config will be changed to do this?
Maybe a simple page exists somewhere that is better than my attempt (please reply and let me know if a page exists)?

APDE is the most powerful self-hosted development environment that I've found. Seems pretty easy to write simple Android programs on Android. Writing Windows and Linux simple programs has been easy for a long time. See here for more details: http://www.turbocontrol.com/monitor.htm.

User avatar
omegaman477
Posts: 148
Joined: Tue Feb 28, 2017 1:13 pm
Location: Sydney, Australia

Re: How use phone bluetooth to reboot Zero?

Thu Oct 26, 2017 12:29 pm

A simple approach I used was to BT drop a small file from the phone to the RPI bluetooth share folder. The file had a long password in it, the RPI was configured that files dropped can not be read back.

A simple script in BASH looked for the file, opened it, checked the password, closed and deleted the file and then did a reboot.
..the only thing worse than a stupid question is a question not asked.

User avatar
LetHopeItsSnowing
Posts: 357
Joined: Sat May 26, 2012 6:40 am
Location: UK
Contact: Website

Re: How use phone bluetooth to reboot Zero?

Thu Oct 26, 2017 3:05 pm

You could use bluedot http://bluedot.readthedocs.io/en/latest/ - write a simple python script that issues

Code: Select all

sudo reboot
when the blue dot is pressed.
"am I getting slower, or is stuff more complicated; either way I now have to write it down - stuffaboutcode.com"

pbreneman
Posts: 23
Joined: Thu Jun 07, 2012 12:31 pm

Re: How use phone bluetooth to reboot Zero?

Thu Nov 23, 2017 8:51 pm

Can I hijack my own thread from last month?

I'd like to convert my entire project (on page linked in my previous message) to Python. I'd like to make things as simple as possible to get the Zero Wireless working (headless) using a(n Android) phone or tablet. Therefore I'd like to load Raspbian Lite using NOOBS controlled by a bluetooth terminal. Is there any hope that folks could purchase a SD card with NOOBS Lite and only use their phone to do everything else?

User avatar
Douglas6
Posts: 4739
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: How use phone bluetooth to reboot Zero?

Fri Nov 24, 2017 12:15 am

As I understand it, NOOBS is a minimal OS (basically busybox) which does not include components of a full OS. Things like a Bluetooth stack. So no, you can't control NOOBS via Bluetooth.

User avatar
HermannSW
Posts: 1394
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: How use phone bluetooth to reboot Zero?

Fri Nov 24, 2017 7:37 pm

If the important aspect is "phone to reboot Zero", you may be interested in thread
"Smartphone as terminal for Pi Zero(!)" (over Wifi):
viewtopic.php?f=36&t=196057
Image
⇨https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://gitlab.freedesktop.org/HermannSW/gst-template
https://github.com/Hermann-SW/fork-raspiraw
https://twitter.com/HermannSW

pbreneman
Posts: 23
Joined: Thu Jun 07, 2012 12:31 pm

Re: How use phone bluetooth to reboot Zero?

Tue Nov 28, 2017 1:11 am

Thanks for all of the previous suggestions.

HermannSW:
My ZeroW is already connected to the building WiFi so I just want to use bluetooth to adjust settings or do simple commands. I'm able to use my phone to do that with the bluetooth instructions already on the http://controlpascal.com/self-hosted.htm page.

Douglas6:
Thanks for the NOOBS info. When I move the SD card to a different RPi the bluetooth is no longer discoverable. Is there any way to prevent that from happening?

This (https://ultibo.org/forum/viewtopic.php?f=9&p=5965#p5965) is what I hope to do soon!

User avatar
Douglas6
Posts: 4739
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: How use phone bluetooth to reboot Zero?

Tue Nov 28, 2017 1:24 am

pbreneman wrote:
Tue Nov 28, 2017 1:11 am
When I move the SD card to a different RPi the bluetooth is no longer discoverable. Is there any way to prevent that from happening?
Bluetooth pairings are of course specific to the hardware. The Bluetooth device address is based off of the physical serial number of the Pi. To be discoverable, the Pi needs to be put into discoverable mode. Then you will need to pair that hardware.

pbreneman
Posts: 23
Joined: Thu Jun 07, 2012 12:31 pm

Re: How use phone bluetooth to reboot Zero?

Tue Nov 28, 2017 9:47 am

To be discoverable, the Pi needs to be put into discoverable mode.
Is there any way to do that automatically upon first bootup? I'm trying to see if there is a simple way to bring up a ZeroW without connecting a HDMI monitor and keyboard.

User avatar
Douglas6
Posts: 4739
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: How use phone bluetooth to reboot Zero?

Tue Nov 28, 2017 6:24 pm

If you put the Pi into discoverable mode, you'll also want a pairing agent to handle pairing requests. BlueZ has a simple pairing agent, code here: https://git.kernel.org/pub/scm/bluetoot ... mple-agent. I used that in my own blueplayer script; code here: https://github.com/Douglas6/blueplayer/ ... eplayer.py.

Alternately you can just pipe the 'discoverable on' and 'agent on' commands to bluetoothctl.

pbreneman
Posts: 23
Joined: Thu Jun 07, 2012 12:31 pm

Re: How use phone bluetooth to reboot Zero?

Wed Nov 29, 2017 4:06 pm

Thanks again Douglas6! I'll have to study what you've mentioned and also https://hacks.mozilla.org/2017/02/headl ... bluetooth/.

Just a little note: I'm not wanting the ZeroW to automatically pair with a device (like a speaker), but just to allow later pairing with a phone (running a terminal).

User avatar
Douglas6
Posts: 4739
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: How use phone bluetooth to reboot Zero?

Thu Nov 30, 2017 1:20 am

That's a very interesting link, thanks for sharing that. More so for what it doesn't include than what it does. For example, no pairing agent. Apparently, running 'hciconfig hci0 piscan' does more than simply turning discoverable on. It also seems to handle pairing, and it ignores the standard 3 minute timeout on discoverability (some light testing confirms this). I think you'd do best to ignore my comments and code for a pairing agent, and simply use hciconfig. But be careful of the security issues of leaving your Pi connectable by anyone within Bluetooth range.

Return to “Automation, sensing and robotics”