Turn off Bluetooth and WiFi on a running device

Hi all…

As a previous RPi user I am used to the raspi-config command and sudo nano to edit the configuration of the device.

I have a few devices deployed and have a situation where I would like to disable the WiFi adapter, Bluetooth and set manual IP addresses in stead of DHCP.

Traditionally I would access my RPi devices and run the ‘sudo raspi-config’ command and change the desired settings.

These obviously are not available on my BalenaIO build devices.

I can run the Terminal to the ‘Host OS’

Can anyone give any advice how I may achieve the reconfiguration via the command line in the Host OS terminal screen please?

Any help would be greatly appreciated.

Thank you.

1 Like

Hello,

I think this doc would help you:
https://www.balena.io/docs/reference/OS/network/2.x/#changing-the-network-at-runtime

Cheers…

Thank you for the reply @gelbal although unfortunately it does not help…

The guide talks about creating a wireless access point…

All I want to do is turn off the Bluetooth and the wireless on the RPi unit which is running out in the field.

The directories and commands in the guide do not exist or work on the BalenaIO build.
It gives an example :-

#!/usr/bin/env python
import dbus, uuid

Not meaning to sound blunt, I appreciate it is my understanding of the BalenaIO OS at fault here but the guide is of no use for what I am trying to achieve and does not work to turn off bluetooth and wifi.

I need to understand the setup in more detail and where I am used to a simple configuration file command like the following:-

sudo nano /etc/network/interfaces

or editing config.txt to add the following:-

dtoverlay=pi3-disable-wifi
dtoverlay=pi3-disable-bt

What would the equivalent be in the BalenaIO deployed device please?

Thank you for any help it is much appreciated…

Hi @devsterp,

balenaOS uses NetworkManager to manage the connection. The documentation explains in detail on how you could manage the connections. If the documentation is not helpful or lacking, your feedback is appreciated.

As detailed in the doc, once you ssh into host OS, you could edit NetworkManager’s configuration to change the connection to be ethernet only (or in other ways). To edit the file:
vi /etc/NetworkManager/system-connections/resin-wifi-01

Before you turn off the wifi connection, make sure you have other ways of accessing the device via a direct physical connection or another networking setup in place (like ethernet conection). Else, you will lose remote access to the device.

Then also use NetworkManager’s nmcli to disable the wifi if you don’t want to persist the configuration:
nmcli radio wifi off

Next, you are right, I don’t see any mention of bluetooth in that documentation. So hcitool dev will output the bluetooth devices and systemctl status bluetooth shows the running bluetooth service. You could turn off the bluetooth via:
systemctl stop bluetooth.service
and disable it:
systemctl disable bluetooth.service

A reboot might be necessary for the disabling. Hope these are helpful.

Cheers…

Thank you @gelbal, that information is much appreciated…

I am trying to follow those instructions however I do not find those directories in my HostOS

Are these elements I need to create from new?

Thank you for your help and time.

The commands to turn off the WiFi and BlueTooth work however the disable BlueTooth command is failing with this error…

Thank you @gelbal , that information is much appreciated…

I am trying to follow those instructions however I do not find those directories in my HostOS

Are these elements I need to create from new?

Thank you for your help and time.

Hi @devsterp,

Thanks to my teammate, I just learned that actually there is an easier way to handle this. You could edit the config.txt file just like you were doing it earlier. These doc pages explain in detail:
https://www.balena.io/docs/reference/OS/advanced/
https://www.balena.io/docs/learn/manage/configuration/

The config.txt is on the boot partition so it can be modified without issues. The easiest way to modify it is through the dashboard as explained in the second link. Then balena supervisor will handle the definitions from the dashboard and apply the changes to config.txt. This way you could setup these variables once for your whole fleet instead of editing these one by one on each device.

Hope these help you.

1 Like

If you just want to get rid of BalenaWifi hotspot:

/etc/NetworkManager/system-connections# mv balenaWiFi.nmconnection balenaWiFi.ignore

Thank you for your solution and welcome to the balena community @jclb :slight_smile: