Batocera & iPhone hotspot

3 minute read

Anbernic 35xxH
In my previous post, I mentioned that I’m using the Anbernic 35xxh handheld for retrogaming. This device offers a nice, horizontal, compact, and practical form factor, making it perfect for gaming on the go. Additionally, I highlighted how Batocera enhances the overall gaming experience. It provides a much better user interface and fantastic integration with Retroarch, elevating the enjoyment of classic games.

As described on its project homepage, RetroArch is a frontend for emulators, game engines, and media players, allowing you to run classic games on a wide range of devices. These include the Anbernic 35xxh, PS Vita, Nintendo 3DS, or even a computer.

RetroArch also offers several features not available on the original consoles. For example, it allows you to save game states for NES, SNES, GBA, and more. Additionally, you can set up a RetroAchievements account and enhance your gaming experience with community-made achievements similar to those found on modern consoles like Xbox or PlayStation.

Playing on the Anbernic 35xxh at home connected to Wi-Fi is great and works flawlessly; however, while on the go, it might have some challenges. On the one hand, you have to switch between your home Wi-Fi and a hotspot connection on your phone, but Batocera doesn’t offer a pool of connections to choose from, at least from the user interface. On the other hand, even though you can establish a connection to your phone, it might be dropped while playing due to traffic inactivity, as the iPhone tends to do.

To tackle the first issue, I did some research and stumbled upon a Reddit article suggesting a solution. It mentioned that there is a setting you can use to specify a second (and even a third) connection. To do this, you need to connect your SD card to a computer, edit Batocera’s config file called batocera.conf located in the root folder of the SHARED partition, or in case you connect through SSH it’s located at /userdata/system/batocera.conf. Fill it in with your home Wi-FI and hotspot values in the network section as show below:

# ------------ B - Network ------------ #

## Set system hostname, accessible via network share.
## Wi-Fi country code (00 for World), see
## Activate Wi-Fi (0,1)
## Wi-Fi SSID (string)
## Wi-Fi KEY (string)
## Escape your special chars (# ; $) with a backslash. eg. $ becomes \$

## Secondary Wi-Fi (not configurable via the user interface)

## Third Wi-Fi (not configurable via the user interface)

To overcome the second problem, I created a script to generate a small amount of traffic every minute by pinging a well-known server. This prevents the iPhone from dropping the connection. The script needs to be added to Batocera boots scripts by connecting to your device through SSH and copying the following script as /boot/ as suggested by the Batocera documentation:

# Script to keep the network connection active only if not connected to 'HomeWifi'

# IP to ping

# Desired network SSID

# Function to check SSID and ping/reconnect if necessary
keep_network_alive() {
    # Get current SSID
    CURRENT_SSID=$(iw dev wlan1 link | grep 'SSID' | awk '{print $2}')

    # Check if the current SSID is not the desired one
    if [ "$CURRENT_SSID" != "$DESIRED_SSID" ]; then
        echo "Not connected to $DESIRED_SSID, checking internet connection..."
        if ! ping -c 1 $SERVER > /dev/null 2>&1; then
            echo "Internet connection down. Attempting to reconnect..."
            /sbin/ifdown wlan1 && /sbin/ifup wlan1
            echo "Internet connection is active, but not on $DESIRED_SSID."
        echo "Connected to $DESIRED_SSID. No action required."

case "$1" in
    echo "Starting network maintenance..."
    while true; do
      sleep 60  # Check every 60 seconds
    done &
    echo "Stopping network maintenance..."
    # Find the process and kill the loop
    kill $(ps aux | grep '[k]eep_network_alive' | awk '{print $2}')
    "$0" stop
    "$0" start
    echo "Usage: $0 {start|stop|restart}"
    exit 1

exit 0  

Here you have to keep in mind that the script assumes the home Wi-Fi is called “HomeWifi”. You need to adjust it with the name of your home network for it to work, or improve it so that it is dynamically taken from the batocera.conf file, but I’ll leave that part to you.

In summary, with some additional configurations and creative solutions, you can significantly enhance your retrogaming experience on the Anbernic 35xxh. From optimizing Wi-Fi connectivity to ensuring your connection remains stable, these modifications will allow you to enjoy your classic games without interruptions. Happy retrogaming!


Leave a Comment