Hello all,
I am looking for some help while trying to setup my Bela to act as a wifi hotspot. I have followed the tutorial in its entirety and everything seems to be properly setup: the wifi access that I have defined does appear to computers around and we can connect to it via the password that I have setup. Furthermore, I can verify that wlan0 has the correct ip address with "ip a" command when I'm connected to 192.168.6.2 via ssh.

The problem is that even when connected to the Bela wifi access point, neither ssh nor browser can actually reach it via the wifi. When I try to access 192.168.30.1 (the address I used, same as in the tutorial) either via browser or ssh, I only ever get a connection timed out message.

I wonder if this may be related to the fact that the following output I get from ifup wlan0 is slightly different from the one in the tutorial:

root@bela:~# ifdown wlan0; ifup wlan0 --verbose

ifup: configuring interface wlan0=wlan0 (inet)
/bin/run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
run-parts: executing /etc/network/if-pre-up.d/hostapd
hostapd: /usr/sbin/hostapd -B -P /run/hostapd.wlan0.pid /etc/hostapd/hostapd.conf
Configuration file: /etc/hostapd/hostapd.conf
wlan0: interface state UNINITIALIZED->COUNTRY_UPDATE
run-parts: executing /etc/network/if-pre-up.d/wireless-tools
run-parts: executing /etc/network/if-pre-up.d/wpasupplicant
/sbin/ip addr add 192.168.30.1/255.255.255.0 broadcast 192.168.30.255     dev wlan0 label wlan0
/sbin/ip link set dev wlan0   up

/bin/run-parts --exit-on-error --verbose /etc/network/if-up.d
run-parts: executing /etc/network/if-up.d/avahi-daemon
run-parts: executing /etc/network/if-up.d/wpasupplicant

It seems to me that two run-parts are missing, compared to the tutorial: openssh and upstart. Upon verification via ls commands no files with those names are present in /etc/network/if-up.d/. Am I simply missing those files (for some obscure reason) or do you think there might be another reason why I can't actually connect to the Bela via the wifi access point?

Thank you for your help.

    what do you get when the hotspot is up and you runip a on the board?

    Here is what I get from ip a:

    root@bela:~# ip a
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
        inet6 ::1/128 scope host
           valid_lft forever preferred_lft forever
    2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
        link/ether e4:15:f6:f3:3c:75 brd ff:ff:ff:ff:ff:ff
    3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
        link/ether e8:4e:06:8a:da:9e brd ff:ff:ff:ff:ff:ff
        inet 192.168.30.1/24 brd 192.168.30.255 scope global wlan0
           valid_lft forever preferred_lft forever
        inet6 fe80::ea4e:6ff:fe8a:da9e/64 scope link
           valid_lft forever preferred_lft forever
    4: usb0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
        link/ether be:1a:f6:f3:3c:77 brd ff:ff:ff:ff:ff:ff
        inet 192.168.6.2/24 brd 192.168.6.255 scope global usb0
           valid_lft forever preferred_lft forever
        inet6 fe80::bc1a:f6ff:fef3:3c77/64 scope link
           valid_lft forever preferred_lft forever
    5: usb1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
        link/ether be:1a:f6:f3:3c:7a brd ff:ff:ff:ff:ff:ff
        inet 192.168.7.2/24 brd 192.168.7.255 scope global usb1
           valid_lft forever preferred_lft forever

    Metakoura It seems to me that two run-parts are missing, compared to the tutorial: openssh and upstart.

    not sure why those would be missing or if that's relevant. I have these:

    openssh-server:

    #! /bin/sh
    # Reload the OpenSSH server when an interface comes up, to allow it to start
    # listening on new addresses.
    
    set -e
    
    # Don't bother to restart sshd when lo is configured.
    if [ "$IFACE" = lo ]; then
    	exit 0
    fi
    
    # Only run from ifup.
    if [ "$MODE" != start ]; then
    	exit 0
    fi
    
    # OpenSSH only cares about inet and inet6. Get ye gone, strange people
    # still using ipx.
    if [ "$ADDRFAM" != inet ] && [ "$ADDRFAM" != inet6 ]; then
    	exit 0
    fi
    
    # Is /usr mounted?
    if [ ! -e /usr/sbin/sshd ]; then
    	exit 0
    fi
    
    if [ ! -f /run/sshd.pid ] || \
       [ "$(ps -p "$(cat /run/sshd.pid)" -o comm=)" != sshd ]; then
    	exit 0
    fi
    
    # We'd like to use 'reload' here, but it has some problems; see #502444.  On
    # the other hand, repeated restarts of ssh make systemd unhappy
    # (#756547/#757822), so use reload in that case.
    if [ -d /run/systemd/system ]; then
    	systemctl reload --no-block ssh.service >/dev/null 2>&1 || true
    else
    	invoke-rc.d ssh restart >/dev/null 2>&1 || true
    fi
    
    exit 0

    upstart:

    #!/bin/sh -e
    MARK_DEV_PREFIX="/run/network/ifup."
    MARK_STATIC_NETWORK_EMITTED="/run/network/static-network-up-emitted"
    
    if [ -e /lib/lsb/init-functions ]; then
        . /lib/lsb/init-functions
    fi
    
    if ! init_is_upstart; then
        exit 0
    fi
    
    # Let's ignore meta entries (ifup -a)
    if [ "$ADDRFAM" = "meta" ]; then
        exit 0
    fi
    
    # lo emission handled by /etc/init/network-interface.conf
    if [ "$IFACE" != lo ]; then
        initctl emit -n net-device-up \
            "IFACE=$IFACE" \
            "LOGICAL=$LOGICAL" \
            "ADDRFAM=$ADDRFAM" \
            "METHOD=$METHOD"
    fi
    
    get_auto_interfaces() {
    	# write to stdout a list of interfaces configured as 'auto' in interfaces(5)
    	local found=""
    	# stderr redirected as it outputs things like:
    	# Ignoring unknown interface eth0=eth0.
    	found=$(ifquery --list --allow auto 2>/dev/null) || return
    	set -- ${found}
    	echo "$@"
    }
    
    all_interfaces_up() {
    	# return true if all interfaces listed in /etc/network/interfaces as 'auto'
    	# are up.  if no interfaces are found there, then "all [given] were up"
    	local prefix="$1" iface=""
    	for iface in $(get_auto_interfaces); do
    		# if cur interface does is not up, then all have not been brought up
    		[ -f "${prefix}${iface}" ] || return 1
    	done
    	return 0
    }
    
    # touch our own "marker" indicating that this interface has been brought up.
    : > "${MARK_DEV_PREFIX}$IFACE"
    
    if all_interfaces_up "${MARK_DEV_PREFIX}" &&
    	mkdir "${MARK_STATIC_NETWORK_EMITTED}" 2>/dev/null; then
    	initctl emit --no-wait static-network-up
    fi

    (these have to be made executable after creation with chmod +x /etc/network/if-up.d/* )

    giuliomoro
    Adding the missing files apparently did not accomplish anything.

    I could not ping the IP address either, but I got strange results:

    • First I got General Failure error messages
    • Then it was timeout error messages with all packets lost
    • Finally, when I tried removing my ethernet internet connection in case there was some kind of weird interference I instantly received can't reach host messages

    I also noticed that during my latest tests ip a would show the wlan0 with an increasingly high rank in the list, although I'm not sure what this means. Example:

    root@bela:~# ip a
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
        inet6 ::1/128 scope host
           valid_lft forever preferred_lft forever
    2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
        link/ether e4:15:f6:f3:3c:75 brd ff:ff:ff:ff:ff:ff
    4: usb0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
        link/ether be:1a:f6:f3:3c:77 brd ff:ff:ff:ff:ff:ff
        inet 192.168.6.2/24 brd 192.168.6.255 scope global usb0
           valid_lft forever preferred_lft forever
        inet6 fe80::bc1a:f6ff:fef3:3c77/64 scope link
           valid_lft forever preferred_lft forever
    5: usb1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
        link/ether be:1a:f6:f3:3c:7a brd ff:ff:ff:ff:ff:ff
        inet 192.168.7.2/24 brd 192.168.7.255 scope global usb1
           valid_lft forever preferred_lft forever
    26: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
        link/ether e8:4e:06:8a:da:9e brd ff:ff:ff:ff:ff:ff
        inet 192.168.30.1/24 brd 192.168.30.255 scope global wlan0
           valid_lft forever preferred_lft forever
        inet6 fe80::ea4e:6ff:fe8a:da9e/64 scope link
           valid_lft forever preferred_lft forever

    What's the IP of your host computer when connected to this wifi network ?

      giuliomoro
      There indeed seems to be something wrong on that front, as (if I understand this correctly) the IP address of the computer connected to the hotspot should be in the range defined 192.168.30.x but it's not that at all. I can add the details tomorrow if necessary but it's something starting with 169 (doesn't even show up in the windows settings, had to run ipconfig). Also when I ran ipconfig there was no default gateway, but I'm not sure whether that's expected with this configuration.

        Metakoura I can add the details tomorrow if necessary but it's something starting with 169

        right that sounds like a self-assigned IP address, so maybe dhcpd on the board is not giving out the correct address. Can you show /etc/dhcp/dhcpd.conf from the board?

          giuliomoro

          Here is /etc/dhcp/dhcpd.conf from the board:

          # dhcpd.conf
          #
          # Sample configuration file for ISC dhcpd
          #
          
          # option definitions common to all supported networks...
          option domain-name "example.org";
          option domain-name-servers ns1.example.org, ns2.example.org;
          
          default-lease-time 600;
          max-lease-time 7200;
          
          # The ddns-updates-style parameter controls whether or not the server will
          # attempt to do a DNS update when a lease is confirmed. We default to the
          # behavior of the version 2 packages ('none', since DHCP v2 didn't
          # have support for DDNS.)
          ddns-update-style none;
          
          # If this DHCP server is the official DHCP server for the local
          # network, the authoritative directive should be uncommented.
          authoritative;
          
          # Use this to send dhcp log messages to a different log file (you also
          # have to hack syslog.conf to complete the redirection).
          #log-facility local7;
          
          # No service will be given on this subnet, but declaring it helps the
          # DHCP server to understand the network topology.
          
          #subnet 10.152.187.0 netmask 255.255.255.0 {
          #}
          
          # This is a very basic subnet declaration.
          
          #subnet 10.254.239.0 netmask 255.255.255.224 {
          #  range 10.254.239.10 10.254.239.20;
          #  option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;
          #}
          
          subnet 192.168.7.0 netmask 255.255.255.0 {
                  range 192.168.7.1;
          }
          
          subnet 192.168.6.0 netmask 255.255.255.0 {
                  range 192.168.6.1;
          }
          # This declaration allows BOOTP clients to get dynamic addresses,
          # which we don't really recommend.
          
          #subnet 10.254.239.32 netmask 255.255.255.224 {
          #  range dynamic-bootp 10.254.239.40 10.254.239.60;
          #  option broadcast-address 10.254.239.31;
          #  option routers rtr-239-32-1.example.org;
          #}
          
          # A slightly different configuration for an internal subnet.
          #subnet 10.5.5.0 netmask 255.255.255.224 {
          #  range 10.5.5.26 10.5.5.30;
          #  option domain-name-servers ns1.internal.example.org;
          #  option domain-name "internal.example.org";
          #  option routers 10.5.5.1;
          #  option broadcast-address 10.5.5.31;
          #  default-lease-time 600;
          #  max-lease-time 7200;
          #}
          
          # Hosts which require special configuration options can be listed in
          # host statements.   If no address is specified, the address will be
          # allocated dynamically (if possible), but the host-specific information
          # will still come from the host declaration.
          
          #host passacaglia {
          #  hardware ethernet 0:0:c0:5d:bd:95;
          #  filename "vmunix.passacaglia";
          #  server-name "toccata.example.com";
          #}
          
          # Fixed IP addresses can also be specified for hosts.   These addresses
          # should not also be listed as being available for dynamic assignment.
          # Hosts for which fixed IP addresses have been specified can boot using
          # BOOTP or DHCP.   Hosts for which no fixed address is specified can only
          # be booted with DHCP, unless there is an address range on the subnet
          # to which a BOOTP client is connected which has the dynamic-bootp flag
          # set.
          #host fantasia {
          #  hardware ethernet 08:00:07:26:c0:a5;
          #  fixed-address fantasia.example.com;
          #}
          
          # You can declare a class of clients and then do address allocation
          # based on that.   The example below shows a case where all clients
          # in a certain class get addresses on the 10.17.224/24 subnet, and all
          # other clients get addresses on the 10.0.29/24 subnet.
          
          #class "foo" {
          #  match if substring (option vendor-class-identifier, 0, 4) = "SUNW";
          #}
          
          #shared-network 224-29 {
          #  subnet 10.17.224.0 netmask 255.255.255.0 {
          #    option routers rtr-224.example.org;
          #  }
          #  subnet 10.0.29.0 netmask 255.255.255.0 {
          #    option routers rtr-29.example.org;
          #  }
          #  pool {
          #    allow members of "foo";
          #    range 10.17.224.10 10.17.224.250;
          #  }
          #  pool {
          #    deny members of "foo";
          #    range 10.0.29.10 10.0.29.230;
          #  }
          #}
          subnet 192.168.30.0 netmask 255.255.255.0 {
             range 192.168.30.2 192.168.30.254;
          }

          That looks good, but still doesn't work. Try assigning yourself an IP in the valid range once you joined the wifi.

          When I assign the IP myself it works, both for the IDE and the ssh! So it seems to imply that it's the process of automatically assigning a correct IP that's not working properly but I have no idea how to go about fixing that.

          You are on Windows, right? What do you get from running ipconfig once you connect to the board if you don't self-assign the IP address?
          ipconfig /renew should force it to request a new IP address ... see if that improves things?

          It does seem like those operations managed to make the wifi assign correct IP addresses. The connection is not very reliable however, we often lose it. But we have identified other problems with i2c devices not being detected properly so we may have some hardware issues to investigate before looking anymore into this. Thank you very much for your help!