Code Monkey home page Code Monkey logo

Comments (43)

ranch-verdin avatar ranch-verdin commented on July 20, 2024 1

wifi.sh on is not super informative with its output, often displaying a lot of errors.

could you give a detailed example what causes an error? do you mean all the:
Failed to connect to non-global ctrl_ifname: (nil) error: No such file or directory
cruft?

router connection has been flaky in both networks I tested. Would like to try a different usb-wifi dongle, actually. I was seeing the same 'strange jags' - any intermittent behaviour seems to get worse with increasing distance from the router. I can't connect all right now unless I'm in the same room.

On the lua thing:
os.execute("bash /home/pi/norns-image/scripts/wifi.sh on")
actually come to think of it, all the first lines of all our bash scripts should be #!/bin/bash then you don't run into this problem (probably functions are unsupported by sh)

from norns-image.

tehn avatar tehn commented on July 20, 2024 1

i added a dBm readout to the interface and it's very helpful to understand connection dropouts.

mine seems a get unreliable around -61

from norns-image.

ranch-verdin avatar ranch-verdin commented on July 20, 2024 1

@catfact - this is by design. The thinking behind this is that hotspot is more reliable & predictable than norns->router->laptop. Therefore it should be the default. dhcpcd isn't needed for hotspot mode - norns just gets a static ip.

@tehn - yes, agree that the script should have a status feature. Think I need to actually tie these scripts into the lua code somehow:

  • how will the end user enter a wifi password? (e.g hotspot web interface, usb keyboard)

from norns-image.

ranch-verdin avatar ranch-verdin commented on July 20, 2024

made bit of progress on this.

got wifi-scan & wifi-select/on scripts most of the way towards working on my laptop. pushed to my fork, not tested on the norns yet. currently on a long bus journey & about to run out of battery...

won't be difficult now to get the specified off/scan/select/on behaviour working & move onto the hotspot task

from norns-image.

ranch-verdin avatar ranch-verdin commented on July 20, 2024

so... the way I think this should work (at least until hotspot-mode frontpanel UI is done):

  • the norns boots into hotspot by default (the instructions to set this up are in README-WIFI.md)
  • use the wifi-on.sh script to subsequently connect the norns to an external wifi

BUGS:

  • currently when you try to use wifi-on.sh over a hotspot-ssh connection, the ssh session drops out.
  • on my laptop I have to manually retrigger dhcpcd when connecting to the norns hotspot. Would be good to know if others experience this same bug when connecting from a mac or whatever...

from norns-image.

tehn avatar tehn commented on July 20, 2024

looking great so far! just got back and haven't tested anything.

i think it's normal that the hotspot needs to drop out when changing over to a selected network, is that what you mean?

for the hotspot mode i'll check what happens to the IP address with a macos laptop. definitely we can't require any tinkering on the laptop side (and it's probably not required?) i assume the zeroconf address nnnn.local (we should change this to norns.local) works?

from norns-image.

ranch-verdin avatar ranch-verdin commented on July 20, 2024

i think it's normal that the hotspot needs to drop out when changing over to a selected network, is that what you mean?

yea, obviously it would be cool if the norns could simultaneously provide a hotspot & connect to the local wifi using a single usb wifi dongle. But maybe impossible! Not 100% sure but I think the wifi-on.sh script currently fails to complete after the hotspot drops out - think I know the workaround.

and the zeroconf didn't work for me - not something I'm familiar with, will investigate.

from norns-image.

tehn avatar tehn commented on July 20, 2024

avahi (zeroconf) is set up by default on raspbian-- it should work, just broadcasting the hostname.local as the ip address.

also the hotspot should have a default password for security.

from norns-image.

ranch-verdin avatar ranch-verdin commented on July 20, 2024

ok, I can resolve the norns' ip address from my laptop using avahi-resolve-host-name in both norns-hotspot & wifi-broadband-router cases. So as far as I can tell, nnnn.local will just work for mac users. Successfully changed from nnnn.local to norns.local by editing /etc/hostname & /etc/hosts.

I think simultaneous hotspot & wifi-router connection won't be possible, because dropout occurs after wpa_cli enable_network 0...

And the hotspot dhcpcd-restart 'bug' is just a matter of waiting a few more seconds for laptop to get it's ip address.

So the remaining task is to enable clean switching between hotspot & wifi-router modes over ssh despite the dropout.

from norns-image.

tehn avatar tehn commented on July 20, 2024

perfect!

i'm further thinking that it may be conducive to combine all these scripts into one, and have the command be the first arg. what do you think?

from norns-image.

ranch-verdin avatar ranch-verdin commented on July 20, 2024

I like it! nice way to remove some duplicated code

from norns-image.

ranch-verdin avatar ranch-verdin commented on July 20, 2024

consolidated into a single wifi.sh script & 2 helper scripts for switching over from router->hotspot (& vice-versa) whilst ssh-ed in, updated the docs

from norns-image.

tehn avatar tehn commented on July 20, 2024

snag on install:

pi@nnnn:~/norns-image$ systemctl enable dhcpcd.service
Synchronizing state of dhcpcd.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable dhcpcd
Failed to reload daemon: The name org.freedesktop.PolicyKit1 was not provided by any .service files
Failed to reload daemon: The name org.freedesktop.PolicyKit1 was not provided by any .service files
Failed to enable unit: The name org.freedesktop.PolicyKit1 was not provided by any .service files
pi@nnnn:~/norns-image$ systemctl enable hostapd.service
Failed to enable unit: The name org.freedesktop.PolicyKit1 was not provided by any .service files
pi@nnnn:~/norns-image$ systemctl enable dnsmasq.service
Failed to enable unit: The name org.freedesktop.PolicyKit1 was not provided by any .service files
pi@nnnn:~/norns-image$

i shipped you a nearly identical disk image, perhaps you added something else?

from norns-image.

tehn avatar tehn commented on July 20, 2024

and further trouble:

pi@nnnn:~/norns-image/scripts$ ./wifi.sh scan
usage:
./wifi.sh on
./wifi.sh off
./wifi.sh hotspot
./wifi.sh scan
./wifi.sh select "My Wifi SSID" "wifi-password"
pi@nnnn:~/norns-image/scripts$ sudo ./wifi.sh scan
./wifi.sh: 1: ./wifi.sh: function: not found
./wifi.sh: 11: ./wifi.sh: Syntax error: "}" unexpected

are you using a different shell? (edit: i'm using bash, default)

from norns-image.

ranch-verdin avatar ranch-verdin commented on July 20, 2024

forgot to commit a really dumb typo fix in wifi.sh, just opened a new PR for it.

As for adding anything else... hmmm, yes I did. Just added missing apt-get incantations to the new PR

from norns-image.

tehn avatar tehn commented on July 20, 2024

they work! thank you!

so nice to finally have wifi management be less clunky.

from norns-image.

tehn avatar tehn commented on July 20, 2024

what's your take on the reliability of connecting to a router? i have stretches where it works flawlessly for hours, and then strange jags where i get massive 20 seconds long stalls every other minute.

wifi.sh on is not super informative with its output, often displaying a lot of errors.

but most importantly, how can i run these scripts from lua? calling os.execute("~/norns-image/scripts/wifi.sh hotspot &") throws errors i was seeing earlier (ie, the shell doesn't understand function)

does it simply need to be run as user pi?

from norns-image.

tehn avatar tehn commented on July 20, 2024

i'd pushed some tiny fixes, added #!bin/bash to wifi.sh and cleaned up init-norns.sh

here's a fail state, wifi-on didn't reconnect:

pi@nnnn:~$ norns-image/scripts/wifi.sh on
ifdown: interface wlan0 not configured
dhcpcd: no process found
Failed to connect to non-global ctrl_ifname: (nil)  error: No such file or directory
Failed to connect to non-global ctrl_ifname: (nil)  error: No such file or directory
Failed to connect to non-global ctrl_ifname: (nil)  error: No such file or directory
Failed to connect to non-global ctrl_ifname: (nil)  error: No such file or directory
Failed to connect to non-global ctrl_ifname: (nil)  error: No such file or directory
Failed to connect to non-global ctrl_ifname: (nil)  error: No such file or directory
Failed to connect to non-global ctrl_ifname: (nil)  error: No such file or directory
Failed to connect to non-global ctrl_ifname: (nil)  error: No such file or directory
sudo wpa_cli set_network 0 ssid "nnnnnnnn"
Failed to connect to non-global ctrl_ifname: (nil)  error: No such file or directory
Failed to connect to non-global ctrl_ifname: (nil)  error: No such file or directory
Failed to connect to non-global ctrl_ifname: (nil)  error: No such file or directory
wlan0: starting wpa_supplicant
no interfaces have a carrier
forked to background, child pid 2245
ping: monome.org: Temporary failure in name resolution

i've also ordered 3 different brands of wifi dongle. the idea is that the wifi dongle gets embedded (set back) in a 4th port in the final version so it doesn't look like a huge dongle. so i need to find a minimal one that doesn't have any branding.

but i still am not going to strictly blame the dongle. if you google "raspberry pi wifi dropouts" you'll see some suggestions for power management.

FYI the dongle has a RTl8192/8188CUS chipset

from norns-image.

ranch-verdin avatar ranch-verdin commented on July 20, 2024

@tehn I thought that ping was necessary in order to subsequently ssh in to the norns over the external wifi here where I'm staying. Will test to see if that's actually the case, or if I was just getting confused due to a long pause somewhere..

from norns-image.

tehn avatar tehn commented on July 20, 2024

from norns-image.

tehn avatar tehn commented on July 20, 2024

have 3 new different wifi dongles. 1 of 3 had the right drivers default installed, so i'm testing that now to see if it drops out similarly.

from norns-image.

tehn avatar tehn commented on July 20, 2024

my immediate sense is that these new dongles don't work much better, but i'll try to get some qualitative information documented.

@ranch-verdin would you be up for diving a little deeper into wifi-router stability? hotspot seems solid, right? i've read some things about disabling power-save mode but that doesn't seem to fix much.

from norns-image.

ranch-verdin avatar ranch-verdin commented on July 20, 2024

@tehn yes I would be up for investigating wifi instability in coming days & yes, hotspot seems totally solid so far. Right now I'm trying to learn how to run a test program in 'early userspace' (initramfs/initrd) - still hoping that could be a stepping stone to the splash screen.

from norns-image.

ranch-verdin avatar ranch-verdin commented on July 20, 2024

@tehn this is somewhat frustrating - I'm not observing any dropouts today with the supplied wifi dongle.

Ping times are less predictable & longer with the norns wifi dongle, than my laptop's built-in wifi. And the norn's range is not as good. But couldn't say the behaviour is 'faulty' based on today's tests. I don't have a second linux laptop to test the 'snappiness' of ssh laptop->laptop as compared to laptop->norns.

Next time I see the norns being flaky, I will run a router ping test using same wifi dongle on both the laptop & the norns. Weather today is cold & dry - other than that I don't see what's changed compared to when the dropouts were observed.

For the fail-state, I propose making the norns software notify 'unable to connect to network, signal strength = -65' rather than just spewing. I will sit in a corner with bad connection & try to clean up stdout/stderr from those scripts.

from norns-image.

ranch-verdin avatar ranch-verdin commented on July 20, 2024

With norns hotspot, I observe the same occasional dropouts when laptop is in a different room. iw dev wlan0 link gives info on the signal strength:

  • side-by-side on desk (signal: -27dBm) ssh no dropouts, great responsiveness, ping ~ 5.5ms
  • same room (signal: -45dBm) ssh no dropouts, great responsiveness, ping ~ 5.5ms
  • hallway (signal: -56dBm) ssh no dropouts, great responsiveness, ping ~ 6ms
  • end of hallway (signal: -66dBm) ssh ~ 1s dropouts, poor responsiveness, ping ~ 8 - 20ms with occasional 1000ms
  • room at far end of house (signal: -77dBm) ssh drops out entirely - maybe the odd keypress gets through. Connection totally died after a minute or so

from norns-image.

ranch-verdin avatar ranch-verdin commented on July 20, 2024

with laptop->router->norns, here are the same observations/measurements moving from room to room:

  • living room next to router (norns: -58dBm, laptop: -47dBm) ssh: no dropouts, ok responsiveness: ok, ping 20ms - 300ms
  • other end of living room (norns: -45dBm, laptop: -45dBm) ssh: no dropouts, responsiveness: ok ping 20ms - 300ms
  • bottom of stairs (norns: -62dBm, laptop: -61dBm) ssh: no dropouts, responsiveness: ok, ping 50ms - 500ms
  • small room top of stairs (norns: -60dBm, laptop: -66dBm) ssh: no dropouts, responsiveness: ok, ping 50ms - 500ms
  • far end of small room (norns: -66dBm, laptop: -73dBm) ssh: short 50ms dropouts, responsiveness poor, ping 100 - 700ms
  • end of hallway (norns: -68dBm, laptop: -81dBm) ssh: long 1s dropouts, responsiveness bad, ping 200 - 1000ms
  • room at far end of house (norns: lost connection, laptop: -88dBm) connection unusable

from norns-image.

ranch-verdin avatar ranch-verdin commented on July 20, 2024

conclusion:

  • if either party in a wifi network has worse than -65dBm signal, connection won't "feel" solid
  • the 'jags' & flakiness we both observed are due to weak wifi link, not a driver config issue.

prediction (based on above conclusion):

  • future 'jags' & flakiness will never be observed unless signal strength of weakest link drops below -65dBm

further experiment:

  • the above results at 88% battery, (as reported by scripts/battery-check.sh)
  • repeat experiment in low-battery state

so (unless others record new observations contradicting the prediction using iw dev wlan0 link), I think this is resolved!

from norns-image.

tehn avatar tehn commented on July 20, 2024

thank you for the thorough investigation.

i was aware that these little "nub" wifi dongles had bad range, but i'm surprised at how bad their range really is. my router is less than 20 feet away.

good to know the signal strength command. i can add that to the wifi display inside the norns interface.

so i'm not sure there's anything further to do short of a serious hardware rework with a better wifi solution.

from norns-image.

catfact avatar catfact commented on July 20, 2024

heya,
for what it's worth i'm getting the same error as above when trying to use ./wifi.sh on (or ./wifi-router.sh) after calling ./wifi.sh set)

i tried editing wpa_supplicant.conf by hand and rebooting, in the traditional manner. but then i see some dhcpd errors on boot (will post details in a moment) and then its stuck with a nonfunctional IP (127.24.1.1)

(sudo service networking restart also seems to have no effect)

from norns-image.

catfact avatar catfact commented on July 20, 2024

bootup output:

        Starting LSB: Autogenerate and use a swap file...
         Starting Cairo Screentest...
[  OK  ] Started Regular background program processing daemon.
         Starting System Logging Service...
         Starting triggerhappy global hotkey daemon...
         Starting Login Service...
[  OK  ] Started D-Bus System Message Bus.
[  OK  ] Started Avahi mDNS/DNS-SD Stack.
[  OK  ] Reached target System Time Synchronized.
[  OK  ] Started triggerhappy global hotkey daemon.
[  OK  ] Started System Logging Service.
[  OK  ] Started Raise network interfaces.
[  OK  ] Started Save/Restore Sound Card State.
[FAILED] Failed to start Cairo Screentest.
See 'systemctl status cairotest.service' for details.
[  OK  ] Started Login Service.
[  OK  ] Reached target Network.
         Starting OpenBSD Secure Shell server...
         Starting Permit User Sessions...
         Starting A high performance web server and a reverse proxy server...
[  OK  ] Reached target Network is Online.
[  OK  ] Started Daily apt download activities.
[  OK  ] Started Daily apt upgrade and clean activities.
[  OK  ] Reached target Timers.
         Starting /etc/rc.local Compatibility...
[  OK  ] Started LSB: Switch to ondemand cpu …rnor (unless shift key is pressed).
[  OK  ] Started Permit User Sessions.
My IP address is 172.24.1.1 
[  OK  ] Started LSB: Autogenerate and use a swap file.
[  OK  ] Started OpenBSD Secure Shell server.
Simple mixer control 'Master',0
  Capabilities: pvolume pswitch cswitch
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: Playback 0 - 255
  Front Left: Playback 255 [100%] [on] Capture [on]
  Front Right: Playback 255 [100%] [on] Capture [on]
[  OK  ] Created slice User Slice of pi.
         Starting User Manager for UID 1000...
[  OK  ] Started Session c1 of user pi.
[  OK  ] Started A high performance web server and a reverse proxy server.
[  OK  ] Started User Manager for UID 1000.
         Starting LSB: Advanced IEEE 802.11 management daemon...
[  OK  ] Started LSB: Advanced IEEE 802.11 management daemon.
         Starting dnsmasq - A lightweight DHCP and caching DNS server...
[  OK  ] Started dnsmasq - A lightweight DHCP and caching DNS server.
[  OK  ] Reached target Host and Network Name Lookups.
         Starting dhcpcd on all interfaces...
[FAILED] Failed to start dhcpcd on all interfaces.
See 'systemctl status dhcpcd.service' for details.
[   11.524295] rc.local[439]: Job for dhcpcd.service failed because the control process exited with error code.
[   11.525342] rc.local[439]: See "systemctl status dhcpcd.service" and "journalctl -xe" for details.
[FAILED] Failed to start /etc/rc.local Compatibility.
See 'systemctl status rc-local.service' for details.
         Starting Hold until boot process finishes up...
         Starting Terminate Plymouth Boot Screen...

from norns-image.

catfact avatar catfact commented on July 20, 2024

more stuff:

pi@nnnn:~$ systemctl status dhcpcd.service
● dhcpcd.service - dhcpcd on all interfaces
   Loaded: loaded (/lib/systemd/system/dhcpcd.service; disabled; vendor preset: 
   Active: failed (Result: exit-code) since Sun 2018-02-04 23:20:37 EST; 5min ag
  Process: 733 ExecStart=/usr/lib/dhcpcd5/dhcpcd -q -b (code=exited, status=6)

Feb 04 23:20:37 nnnn systemd[1]: Starting dhcpcd on all interfaces...
Feb 04 23:20:37 nnnn dhcpcd[733]: Not running dhcpcd because /etc/network/interf
Feb 04 23:20:37 nnnn dhcpcd[733]: defines some interfaces that will use a
Feb 04 23:20:37 nnnn dhcpcd[733]: DHCP client or static address
Feb 04 23:20:37 nnnn systemd[1]: dhcpcd.service: Control process exited, code=ex
Feb 04 23:20:37 nnnn systemd[1]: Failed to start dhcpcd on all interfaces.
Feb 04 23:20:37 nnnn systemd[1]: dhcpcd.service: Unit entered failed state.
Feb 04 23:20:37 nnnn systemd[1]: dhcpcd.service: Failed with result 'exit-code'.

from norns-image.

catfact avatar catfact commented on July 20, 2024

any ideas? i understand this is the exact same unit that @tehn used on tuesday.

for now i'll try refreshing stuff with rsync in hotspot mode. that should get me through the next tasks even if i can't put norns online, since i still have this other mostly-functional norns that can go online and has a working toolchain for SC ugens.

from norns-image.

tehn avatar tehn commented on July 20, 2024

@ranch-verdin should have a better idea what's going on with the scripts. i used them as describe to set up what i have currently working.

keep in mind that the wifi-to-router range with these little dongles is really bad, if you're far from the router it'll just not work at all.

from norns-image.

tehn avatar tehn commented on July 20, 2024

@ranch-verdin

what do you think of this idea for wifi.sh?

it'd be good to understand what state of execution the script is in. would it make sense to update the contents of ~/status.wifi (or something) with words like:

  • connecting
  • failed
  • starting hotspot

this is to prevent running commands repeatedly before the previous one completes. for example, often trying to connect to the router takes a really long time, like a full minute, and it doesn't always succeed. having an idea about the script status would make sense of what's going on-- make it interactive

from norns-image.

catfact avatar catfact commented on July 20, 2024

ok sorry, i got closer to the router and followed instructions this time :)

key thing is i somehow got into a state where dhcpd service wasn't running and wasn't started on reboot

./wifi.sh on got out of that

it works. but is confusing. then again i'm easily confused

from norns-image.

ranch-verdin avatar ranch-verdin commented on July 20, 2024

having said all this, it would be better if I could manage to implement the hotspot feature without using debian's networking service-cruft to configure it. Because, the way it stands I've kind of broken the canonical way debian's 'networking' service is mostly used...

from norns-image.

tehn avatar tehn commented on July 20, 2024

i think the wifi ssid/password entry will need to be integrated into maiden (norns-web), which has the editor, file selector, etc. and by design is attached to a computer with a keyboard.

my logic with the status.wifi file is that lua can just read the file. really sloppy ipc

from norns-image.

tehn avatar tehn commented on July 20, 2024

also considering if it makes more sense to have wifi off completely by default (in the bootup script). saves battery life.

the the lua could remember what state the wifi was in last, and then attempt to resume whatever state that was, upon booting

from norns-image.

ranch-verdin avatar ranch-verdin commented on July 20, 2024

really sloppy ipc

I've seen a lot worse

from norns-image.

ranch-verdin avatar ranch-verdin commented on July 20, 2024

right, this small pile of hacks is still a little fragile to be used from norns...

You can still get into a buggy state by selecting external wifi, then selecting it again before it's finished setting up.

might try just adding a lockfile, so only one copy of wifi.sh can run at a time

from norns-image.

tehn avatar tehn commented on July 20, 2024

you could also have wifi.sh check status.wifi (oy) before re-executing the router setup

from norns-image.

tehn avatar tehn commented on July 20, 2024

just booted fresh, last night was using router, now it thinks it's still in router mode despite booting to hotspot (maybe not via the script?)

fixed by selecting off menu item then router, but this suggests that the status.wifi is out of date on boot.

also i'm still preferential to wifi being off on boot, as the principal use case will be "playing" and "editing" can be an initiated action-- saving battery power in the meantime and not adding more wifi signals to the air

from norns-image.

ranch-verdin avatar ranch-verdin commented on July 20, 2024

yup - now the wifi scripts are plumbed into the OLED menu interface wifi-off-on-boot seems like the best default. I'll update init-norns.sh to not fire up hotspot & clean up ~/status.wifi....

from norns-image.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.