×

INDI Library v2.0.6 is Released (02 Feb 2024)

Bi-monthly release with minor bug fixes and improvements

VAP Connection Issue

  • Posts: 13
  • Thank you received: 0

Replied by Darren Jehan on topic VAP Connection Issue

Thanks Radek!
5 years 1 week ago #36655

Please Log in or Create an account to join the conversation.

  • Posts: 983
  • Thank you received: 375

Replied by Radek Kaczorek on topic VAP Connection Issue

OK, let's try it out. I have prepared an experimental script, which should work. At boot time it checks if any known wireless network (configured in /etc/wpa_supplicant/wpa_supplicant.conf) is available. If so it connects to known AP, if no it starts VAP.

Step by step instruction how to use it:

1. Edit /etc/network/interfaces so it contains:
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
 
# The loopback network interface
auto lo
iface lo inet loopback

2. Edit /etc/hostapd/hostapd.conf so it contains:
interface=vap0
driver=nl80211
country_code=00
ssid=astroberry
hw_mode=g
ieee80211n=1
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=astroberry
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

3. Edit /etc/rc.local so it contains:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
 
# start Virtual Access Point (VAP) if no active wireless connection
/usr/local/bin/astroberry_wireless > /dev/null 2>&1
 
exit 0

4. Download astroberry_wireless script, copy it to /usr/local/bin and set permissions:
cd /home/astroberry/Download
wget https://raw.githubusercontent.com/rkaczorek/astroberry-server/master/scripts/astroberry_wireless
sudo cp astroberry_wireless /usr/local/bin/
sudo chmod 755 /usr/local/bin/astroberry_wireless

5. Make sure that your /etc/wpa_supplicant/wpa_supplicant.conf contains proper wireless configuration e.g.
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=00
 
network={
scan_ssid=1
ssid="WIRELESS_NAME"
psk="WIRELESS_PASSWORD"
}

6. Reboot

If the wireless network WIRELESS_NAME is available and WIRELESS_PASSWORD is correct, the system should connect to the wireless network at boot time.
If the wireless network is not available or password is not correct it should fall back to Virtual Access Point (VAP), named astroberry with default password astroberry - both can be changed by editing /etc/hostapd/hostapd.conf (see ssid and wpa_passphrase parameters). For many reasons VAP needs to be started in 802.11g mode. You can change it by editing /etc/hostapd/hostapd.conf (see hw_mode=g and channel=6 parameters).

The script runs at boot only, so there is no real time switching between VAP and AP.

Let me know how it goes.
Last edit: 5 years 1 week ago by Radek Kaczorek.
5 years 1 week ago #36660

Please Log in or Create an account to join the conversation.

  • Posts: 13
  • Thank you received: 0

Replied by Darren Jehan on topic VAP Connection Issue

Hi Radek

Step 1 - Check. Removed all other interface lines
Step 2 - Check
Step 3 - Check
Step 4 - Check
Step 5 - Check

And rebooted.

So, the VAP starts, but I still cannot connect to it, and now the WLAN won't connect either.
To see what what was happening, I modified rc.local to:
/usr/local/bin/astroberry_wireless > boot.log 2>&1

Here is the result:
Checking if connected to AP.......... Not connected
Trying to connect to known AP
Wireless network available
Connecting...............................
Can't connect to wireless network. ^[[31mCheck your password and try again^[[0m
Starting Virtual Access Point
Configuration file: /etc/hostapd/hostapd.conf
Failed to create interface mon.vap0: -95 (operation not supported)
vap0: interface state UNINITIALIZED->COUNTRY_UPDATE
vap0: Could not connect to kernel driver
Using interface vap0 with hwaddr b8:27:eb:4f:53:4f and ssid "astroberry"
vap0: interface state COUNTRY_UPDATE->ENABLED
vap0: AP-ENABLED
Virtual Access Point Ready

And again, I can see it listed, but cannot connect to it.

Interesting that the connection to the WLAN failed - I have triple-checked the password and it is correct, as is the spelling of my WLAN ssid = 200% absolutely sure!!!

Sorry to cause you so much grief!
Last edit: 5 years 1 week ago by Darren Jehan. Reason: wrong tags for code!
5 years 1 week ago #36673

Please Log in or Create an account to join the conversation.

  • Posts: 13
  • Thank you received: 0

Replied by Darren Jehan on topic VAP Connection Issue

Doing some more digging to try and assist...

So, this line:
/sbin/wpa_supplicant -s -B -P /run/wpa_supplicant.wlan0.pid -i wlan0 -D nl80211,wext -c /etc/wpa_supplicant/wpa_supplicant.conf

Gives me no output when run at the command-line, however this line:
wpa_cli -i wlan0 status

Gives an error "Failed to connect to non-global ctrl_ifname (nil) error: no such file or directory"

I don't know if that helps, or is even relevant!
5 years 1 week ago #36675

Please Log in or Create an account to join the conversation.

  • Posts: 983
  • Thank you received: 375

Replied by Radek Kaczorek on topic VAP Connection Issue

What you get is:
Wireless network available
Connecting...............................
Can't connect to wireless network. Check your password and try again

This means that the AP is present but the password is not correct. It is case sensitive to please triple check this ;-)

Run these after reboot (note it does not contain -B flag, which sends it to background):
sudo astroberry_vap stop
sudo /sbin/wpa_supplicant -s -P /run/wpa_supplicant.wlan0.pid -i wlan0 -D nl80211,wext -c /etc/wpa_supplicant/wpa_supplicant.conf

Review the output and/or paste it here.
Last edit: 5 years 1 week ago by Radek Kaczorek.
5 years 1 week ago #36678

Please Log in or Create an account to join the conversation.

  • Posts: 13
  • Thank you received: 0

Replied by Darren Jehan on topic VAP Connection Issue

Password checked, double and triple checked. I even changed it, updated my phone, my laptop and tablet - all connected perfectly. Pi does not connect!

Entered that command and it just sits there - no output at all. I left it several minutes just in case, but nothing.
5 years 1 week ago #36729

Please Log in or Create an account to join the conversation.

  • Posts: 13
  • Thank you received: 0

Replied by Darren Jehan on topic VAP Connection Issue

Just wondering Radek, if it would be easier/useful to do a complete refresh, run a complete update and then try the new astroberry_wireless sccript?
I have spare cards so easy to do....

Appreciate your support!
5 years 1 week ago #36740

Please Log in or Create an account to join the conversation.

  • Posts: 983
  • Thank you received: 375

Replied by Radek Kaczorek on topic VAP Connection Issue

Absolutely! Reflash and upgrade the system before further straggle :-)
5 years 1 week ago #36765

Please Log in or Create an account to join the conversation.

  • Posts: 13
  • Thank you received: 0

Replied by Darren Jehan on topic VAP Connection Issue

No worries, will let you go support some other issues :)
5 years 1 week ago #36769

Please Log in or Create an account to join the conversation.

  • Posts: 983
  • Thank you received: 375

Replied by Radek Kaczorek on topic VAP Connection Issue

I meant struggle :D
5 years 1 week ago #36770

Please Log in or Create an account to join the conversation.

  • Posts: 1
  • Thank you received: 0

Replied by Robin on topic VAP Connection Issue

I think I have there same problem but I don't understand the answer - not unix literate!)

I have downloaded the latest astroberry and installed on a Pi3+

VAP is fine and I can connect

Tried , wlanconfig, to set up connection my home 5GHZ network. SSID and password entered correctly. Reboot VAP shows but you can't connect to it. Ethernet gets to the Pi but I can't connect to the server, it fails. Only way out seems to be a reflash.
5 years 1 week ago #36802

Please Log in or Create an account to join the conversation.

  • Posts: 13
  • Thank you received: 0

Replied by Darren Jehan on topic VAP Connection Issue

OK, lengthy note this one!
I reflashed the SD card and started from scratch...
reflashed SD Card with 1.1.0 image
Connect LAN cable
Power on
Ran apt update and apt upgrade
Reboot
Ran apt-get dist-update
Shutdown
Disconnect LAN
Power on
ifconfig and astroberry_vap status confirm VAP has started
Ubuntu 18.04 client connects to astroberry VAP
IP address given as 192.168.10.151
http://astroberry.local shows the welcome page but connection fails (suspect the welcome page is cached?)
http://192.168.10.1 fails to connect
Connect to WLAN using wlanconfig
Confirm connection working OK and IP address is valid
While WLAN connection is valid, go back to post [url=https://indilib.org/forum/astroberry/4829-vap-connection-issue.html?start=0#36660]HERE[/url] and follow instructions
Modify interfaces, rc.local and confirm wpa_supplicant has valid WLAN details
Download astroberry_wireless script, put in /u/l/b and chmod it
Reboot
ifconfig shows VAP up, but no IP address for WLAN
Attempt to redownload the astroberry_wireless - confirms that no network connection is present
Output from astroberry_wireless says that the password is incorrect - [color=orange][b]it is not![/b][/color]
Ubuntu client connects to VAP, but cannot connect to http://astroberry.local or 192.168.10.1
Changed network settings in Ubuntu to manual IP with mask and DNS, no difference
Confirmed astroberry firewall is disabled on all 3 profiles
Retest connection to VAP - no difference
Output of iwconfig shows:
  lo	        no wireless connection
 
  vap0	IEEE 802.11  Mode:Master  Tx-Power=31 dBm
		Retry short limit:7  RTS thr: off  Fragment thr:off
		Power Management:on
 
  wlan0	IEEE 802.11  ESSID:off/any
		Mode:Managed  Access Point:Not Associated  Tx-Power=31 dBm
		Retry short limit:7  RTS thr: off  Fragment thr:off
		Encryption key:off
		Power Management:on		
 
Revert changes to /etc/network/interfaces
Hash out astroberry_wireless from rc.local
Reboot
Device now connects to WLAN again, confirmed by redownloading astroberry_wireless script
Ubuntu client cannot connect to astroberry.local or via IP address
astroberry_vap status confirms VAP is not started
astroberry_vap start to start VAP
Ubuntu client connects to astroberry, gets IP address but cannot connect to astroberry.local or IP addreess

I don't actually mind about the WLAN but I do want the VAP connection to work so I can use in the field - the primary goal. Any updates I need can be done when connected to the ethernet, but VAP is key!

So, I removed the WLAN settings from wpa_supplicant, removed the WLAN settings from /etc/network/interfaces and re-added the astroberry_wireless into rc.local
When I reboot, the VAP comes up, and again, my Ubuntu client connects to it - I assume, because I get an IP address - but I cannot connect to it.

Hope some of this helps!!
5 years 1 week ago #36810

Please Log in or Create an account to join the conversation.

Moderators: Radek Kaczorek
Time to create page: 1.726 seconds