StereoPi to Oculus Go direct WiFi connection

StereoPi hardware discussion
Post Reply
eddie
Posts: 4
Joined: Thu Jan 09, 2020 5:39 pm

StereoPi to Oculus Go direct WiFi connection

Post by eddie » Thu Jan 09, 2020 5:56 pm

Hello! I am a new and excited owner of a StereoPi, and an Oculus Go which I bought second-hand for the purpose. So far experimenting has gone really well and I'm really happy with the concept. What a great idea and what a fantastic implementation. Well done StereoPi team.

I was wondering if anyone here has tried a direct WiFi connection between a StereoPi and an Oculus Go? I want to use the pair in areas where there is no accessible wireless LAN. I imagine there are two obvious approaches:

1. Create a mobile hotspot from the Oculus Go: The Oculus Go runs on an Android operating system so if my phone can do it then presumably a (rooted?) Oculus Go must be able to do it somehow. Easy for those that know how, but unfortunately that's not me.

2. Create an access point from the StereoPi: I followed the instructions on the RaspberryPi.org website on how to create a WiFi access point (https://www.raspberrypi.org/documentati ... s-point.md). I couldn't get it to work. The access point is visible from other devices but I can't login to it. I don't know how to go about troubleshooting it as honestly I was following the instructions without really understanding what I was doing.

Is there anyone here that would be willing to share a success story on how they got a direct WiFi connection between the two devices? Or help me troubleshoot the creation of an access point on the StereoPi? That LAN WiFi router is a ball-and-chain!

stereomaton
Posts: 108
Joined: Tue May 21, 2019 12:33 pm
Location: France

Re: StereoPi to Oculus Go direct WiFi connection

Post by stereomaton » Fri Jan 10, 2020 8:24 am

(quick answer)

1. On my Android phone, it is in Parameters>wireless& network>plus...>sharing connection>wifi hotspot (rough translation, my phone is not in English)
Do not know if such feature is available on your device since there is possibly no other network to share on the hotspot.

2. I read the linked article and it sounds good at a first glance. Not all wifi dongles allow to create a hotspot but if the network is listed by other devices, yours should be able. Also because of this, we can determine that the hostapd part is running.
Do you have error details ? In Linux, the dmesg command gives info (client side) but I do not know about other systems.
The first step is probably to determine if this is a problem of authentification or of IP stack (client machine is linked to the host but get no ip)
Stereophotographer and hacker
Despite my quite active participation in the forum, I am not in the StereoPi team
StereoPi Standard Edition + CM3Lite module

User avatar
Realizator
Site Admin
Posts: 356
Joined: Tue Apr 16, 2019 9:23 am
Contact:

Re: StereoPi to Oculus Go direct WiFi connection

Post by Realizator » Fri Jan 10, 2020 12:57 pm

Hi Eddie and Stereomaton,
To say briefly, I'm not recommend to do direct connection. It is better to use external device like router, or you can use your phone as access point to connect both Oculus and StereoPi to phone's access point.

Why it is not a good idea to run access point (according to our experience):
1. Most devices (like Oculus and phones) has a very poor internal WiFi antenna. These antennas are Ok for connection with external routers (as most of routers has 3 or 5 dBi or better good-range antennas), but when you try to connect two devices with a small antennas, you'll get a lot of troubles. Connection lost and low bandwidth is a frequent guests here, so you'll get a laggy and broken video.

2. As Stereomaton mentioned, not all of WiFi dongles support WiFi access point mode.

3. If your WiFi dongle support this, it is a tricky thing to setup it with our S.L.P. image manually. As I already mentioned here on forum, S.L.P. image is highly-optimized and production-ready solution, difficult to hack by beginners. For example, it has read-only filesystem and small free disk space. All logs are disabled, so it is difficult to analyze them after experiments (and you have real-time console only). All that stuff was ported here from our production solutions, where we need extreme robustness (like save micro SD data in a case of power issues, auto-restart all modules in a case of software malfunctions etc.) Also we use some specific WiFi initialization. At the boot SLP tries to detect WiFi module, and if it runs on a classic Raspberry Pi, it names WiFi interface as wifi0 (according to Pi's WiFi hardware id), otherwise it is named as wlan0. We use this for working with 2 WiFi interfaces in some our solutions.

So if you scared by all that I said, it is better to use external router (like portable with internal battery, or your phone). But I see you're brave man, and your access point is about to work. I think next part of my answer will be interesting to you and to Stereomaton too.

We already have access point feature onboard in our SLP. So you don't need to install anything, just use clear SLP image. Please write new image, as your previous installation may broke some settings. I need to check, if we've kept all features, but, as I remember, it should work.

1. In /opt/StereoPi/scripts/ you can find 'wlan-switch.php'. This file is responsible for the network configuration. You can see it uses LAN_stop(); to stop all networks, and LAN_run($LAN_IFACE, $LAN_SSID, $LAN_PASS) to run it. You need to comment all code responsible for the LAN_RUN.

2. This file includes 'wlan.lib.php' sitting nearby. In this file you can find this code:

Code: Select all

/// Run Access Point
function AP_run ($iface, $mode, $channel, $ssid, $pass, $country_code) {...
So you need to use AP_run instead of LAN_run.

3. For initialization, this function uses parameters sitting here:
/run/hostapd.conf
Default settings:
ap name: Cosmostreamer (row 86)
password: 1234512345 (row 1084)

AP_run function is small and simple. What it does:
- copy default AP settings to a separate file /etc/hostapd/hostapd.conf (row 124)
- changes these settings according to parameters passed by user and saves them in a copy of hostapd.conf (row 127)
- kill old AP and run new AP with updated settings (rows 129-135)

So you can either pass all your settings, or pass empty values and comment line 127 - this way you'll have AP with default settings.

Default settings (from hostapd.conf):
$iface - it is wlan0 in our case (line 6 in hostapd.conf)
$mode - g (line 134 hostapd.conf); sets a mode (2.4/5 etc accroding to your dongle, look at row 1486 in hostapd.conf for help)
$channel - 7 (line 144 in hostapd.conf), wifi channel number for access point
$ssid - Cosmostreamer (line 86 in Cosmostreamer), name of your access point
$pass - 1234512345 (line 1084 in Cosmostreamer), password for your access point
$country_code - 00 (line 99 in Cosmostreamer),country settings (affects on WiFi channels, frequency and power)

Hope it helps :-)
Eugene a.k.a. Realizator

eddie
Posts: 4
Joined: Thu Jan 09, 2020 5:39 pm

Re: StereoPi to Oculus Go direct WiFi connection

Post by eddie » Sun Jan 12, 2020 8:18 pm

Hi both, I just wanted to say thanks a lot for the quick replies. I look forward to trying this out soon! It might take a couple more days before I get the chance though, so I'll let you know how it goes as soon as I do.

eddie
Posts: 4
Joined: Thu Jan 09, 2020 5:39 pm

Re: StereoPi to Oculus Go direct WiFi connection

Post by eddie » Tue Jan 14, 2020 8:42 pm

Hi both,

I thought I'd start with Realizator's guide to implementing the existing AP functionality built into the image. Unfortunately I can't seem to get it working. My interpretation of Realizator's instructions was to edit the wlan-switch.php file as follows (you can tell which lines I commented out because my "//" marks are left-aligned):

Code: Select all

#!/usr/bin/php
<?php
require_once('wlan.lib.php');

/// Set Wi-Fi country
shell_exec('iw reg set 00');

@file_put_contents('/run/wlan.update', '');

while (1) {

        /// If needed - reload all params from config file
        if (file_exists('/run/wlan.update')) {

                /// Stop all, for release all interfaces
//              LAN_stop();
                AP_stop();

//              $CONFIG = GetConfig();

                $done = false;

                /// Local Network
//              $LAN_IFACE = GetParam($CONFIG, 'wifi_iface');
//              $LAN_SSID = GetParam($CONFIG, 'wifi_ssid');
//              $LAN_PASS = GetParam($CONFIG, 'wifi_psk');

                /// Access Point
                $iface = "wlan0";
                $mode = "g";
                $channel = "7";
                $ssid = "StereoPi";
                $pass = "stereopitestpass";
                $country_code = "00";


//              if ($LAN_IFACE != "") {
                if ($AP_IFACE != "") {
//                      if (LAN_run($LAN_IFACE, $LAN_SSID, $LAN_PASS)) {
                        if (AP_run($iface, $mode, $channel, $ssid, $pass, $country_code)) {
                            $done = true;
                        }
                }

                /// Clear flag
                if ($done) unlink('/run/wlan.update');
        }

        usleep(1000000);
}

?>
Possibly I am assigning the parameters incorrectly (i.e. maybe they're not supposed to be between ""?). I did try a few combinations to no avail.

How would I go about get some error codes to see what is going wrong? There is no access point created.

Many thanks!

Eddie

P.S. Not sure why the code display is colouring the code as if it were all commented out (in green)... sorry about that.

stereomaton
Posts: 108
Joined: Tue May 21, 2019 12:33 pm
Location: France

Re: StereoPi to Oculus Go direct WiFi connection

Post by stereomaton » Fri Jan 17, 2020 8:58 am

I did not dig into the way proposed by Realizator, but with a quick review of the posted code, I see that you test a probably unset variable AP_IFACE, thus the function AP_run is probably not called.
Stereophotographer and hacker
Despite my quite active participation in the forum, I am not in the StereoPi team
StereoPi Standard Edition + CM3Lite module

User avatar
Realizator
Site Admin
Posts: 356
Joined: Tue Apr 16, 2019 9:23 am
Contact:

Re: StereoPi to Oculus Go direct WiFi connection

Post by Realizator » Fri Jan 17, 2020 2:55 pm

Well, I did some experiments, but no luck at this moment, as my dongle has no AP support.
Will try to find appropriate one and repeat this.
I had tried to run hostapd manually. May be this can help in your case, as your dongle supports AP.
- stop all LAN_run options (comment it in a scriot)
- I did a copy to /run/hostapd.conf (original hostapd.conf is stored here: /etc/hostapd/hostapd.conf)
- changed wifi0 to wlan0 in this file
- run

Code: Select all

hostapd -P /run/hostapd.pid /run/hostapd.conf
- got "Unknown interface wlan0" - so did "ifconfig wlan0 up" and previous command again
- got "nl80211: Unable to configure driver mode"

There are lot of tricks with AP support by different drivers, that's why we did not include this feature as a "default" in SLP. Users may have a very different WiFi hardware, and only few with AP mode is supported "out of the box" by hostapd.
Eugene a.k.a. Realizator

eddie
Posts: 4
Joined: Thu Jan 09, 2020 5:39 pm

Re: StereoPi to Oculus Go direct WiFi connection

Post by eddie » Mon Jan 20, 2020 8:39 pm

Hi both,

Thanks again for your helpful replies!

Faced with the choice of learning about setting variables in the script and copying and pasting a few commands, I opted for the latter - but I'll remember your feedback stereomaton in case I want to revisit this method - thanks.

I went ahead with running hostapd manually and... it worked! I was able to connect to the AP from my PC and stream the video from the browser page. Hooray! :D This is very exciting.

Sadly, when I tried the same from my Oculus Go, it wouldn't connect ("IP Configuration Error"). Looking back at the successful connection with my PC, I can see that there are signs of an insecure connection, so one theory is that maybe the Oculus is simply not allowed to connect to an insecure connection. Here are the signs that the AP being created is insecure:
  1. The linux terminal running hostapd shows a warning before running: "HT (IEEE 802.11n) with WPA/WPA2 requires CCMP/GCMP to be enabled, disabling HT capabilities"
  2. When Windows 10 connects to the AP, I get a warning sign from Windows saying that the network is not secure. (And a link to this page: https://support.microsoft.com/en-us/hel ... not-secure)
I searched for the warning message displayed by hostapd, and the first question people ask is: "are you using the latest version?". Apparently there are bugs being fixed all the time, so maybe it's a bug and maybe it will easily be fixed with an update. Unfortunately the partition is too small to run apt-get update/upgrade, so right now I'm installing Ubuntu so that I can resize the partitions on the SLP image. I'll get back to you once I've shaved this yak!

Best,

Eddie

P.S. I did get another hostapd warning message about not having enough entropy, but installing rng-tools fixed that. Unfortunately this did not fix the problem - but it must have solved something as that warning message doesn't appear any longer, and I thought it worth noting for anyone seeing this in the future.

P.P.S. Do you know why my personalised /run/hostapd.conf file is deleted after a reboot? Is there any way to commit the file and make it survive a reboot? If it's a Linux thing then for sure I can dig further and try to learn about it. I just thought to ask in case it's something to do with the rugged configuration of the SLP image.

User avatar
Realizator
Site Admin
Posts: 356
Joined: Tue Apr 16, 2019 9:23 am
Contact:

Re: StereoPi to Oculus Go direct WiFi connection

Post by Realizator » Wed Jan 22, 2020 7:30 am

Hi Eddie,
I'm glad you have some success here!
I think we'll add AP support in our next SLP release for advanced users, to simplify all that settings.

As for your /run/hostapd.conf question - this is a temporary directory used for the boot process. You can save your config file in another place (like /etc or /opt). As you mentioned, while boot process we're always copy our configuration files from another places to the /run dir (and sometimes we're doing some files modification). But we're not store files here.
Eugene a.k.a. Realizator

Post Reply