Fork of the espurna firmware for `mhsw` switches
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

787 lines
22 KiB

8 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
Remove wifi info from File: dir, Node: Top, This is the top of the INFO tree. This is the Info main menu (aka directory node). A few useful Info commands: 'q' quits; '?' lists all Info commands; 'h' starts the Info tutorial; 'mTexinfo RET' visits the Texinfo manual, etc. * Menu: Basics * Common options: (coreutils)Common options. * Coreutils: (coreutils). Core GNU (file, text, shell) utilities. * Date input formats: (coreutils)Date input formats. * Ed: (ed). The GNU line editor * File permissions: (coreutils)File permissions. Access modes. * Finding files: (find). Operating on files matching certain criteria. C++ libraries * autosprintf: (autosprintf). Support for printf format strings in C++. Compression * Gzip: (gzip). General (de)compression of files (lzw). Development * SSIP: (ssip). Speech Synthesis Interface Protocol. * Speech Dispatcher: (speech-dispatcher). Speech Dispatcher. * libffi: (libffi). Portable foreign-function interface library. DOS * Mtools: (mtools). Mtools: utilities to access DOS disks in Unix. Editors * nano: (nano). Small and friendly text editor. General Commands * Screen: (screen). Full-screen window manager. GNU Gettext Utilities * autopoint: (gettext)autopoint Invocation. Copy gettext infrastructure. * envsubst: (gettext)envsubst Invocation. Expand environment variables. * gettextize: (gettext)gettextize Invocation. Prepare a package for gettext. * gettext: (gettext). GNU gettext utilities. * ISO3166: (gettext)Country Codes. ISO 3166 country codes. * ISO639: (gettext)Language Codes. ISO 639 language codes. * msgattrib: (gettext)msgattrib Invocation. Select part of a PO file. * msgcat: (gettext)msgcat Invocation. Combine several PO files. * msgcmp: (gettext)msgcmp Invocation. Compare a PO file and template. * msgcomm: (gettext)msgcomm Invocation. Match two PO files. * msgconv: (gettext)msgconv Invocation. Convert PO file to encoding. * msgen: (gettext)msgen Invocation. Create an English PO file. * msgexec: (gettext)msgexec Invocation. Process a PO file. * msgfilter: (gettext)msgfilter Invocation. Pipe a PO file through a filter. * msgfmt: (gettext)msgfmt Invocation. Make MO files out of PO files. * msggrep: (gettext)msggrep Invocation. Select part of a PO file. * msginit: (gettext)msginit Invocation. Create a fresh PO file. * msgmerge: (gettext)msgmerge Invocation. Update a PO file from template. * msgunfmt: (gettext)msgunfmt Invocation. Uncompile MO file into PO file. * msguniq: (gettext)msguniq Invocation. Unify duplicates for PO file. * ngettext: (gettext)ngettext Invocation. Translate a message with plural. * xgettext: (gettext)xgettext Invocation. Extract strings into a PO file. GNU organization * Maintaining Findutils: (find-maint). Maintaining GNU findutils GNU Utilities * dirmngr-client: (gnupg). X.509 CRL and OCSP client. * dirmngr: (gnupg). X.509 CRL and OCSP server. * gpg: (gnupg1). OpenPGP encryption and signing tool (v1). * gpg-agent: (gnupg). The secret key daemon. * gpg2: (gnupg). OpenPGP encryption and signing tool. * gpgsm: (gnupg). S/MIME encryption and signing tool. Individual utilities * aclocal-invocation: (automake-1.15)aclocal Invocation. Generating aclocal.m4. * arch: (coreutils)arch invocation. Print machine hardware name. * automake-invocation: (automake-1.15)automake Invocation. Generating Makefile.in. * base32: (coreutils)base32 invocation. Base32 encode/decode data. * base64: (coreutils)base64 invocation. Base64 encode/decode data. * basename: (coreutils)basename invocation. Strip directory and suffix. * bibtex: (web2c)bibtex invocation. Maintaining bibliographies. * cat: (coreutils)cat invocation. Concatenate and write files. * chcon: (coreutils)chcon invocation. Change SELinux CTX of files. * chgrp: (coreutils)chgrp invocation. Change file groups. * chmod: (coreutils)chmod invocation. Change access permissions. * chown: (coreutils)chown invocation. Change file owners and groups. * chroot: (coreutils)chroot invocation. Specify the root directory. * cksum: (coreutils)cksum invocation. Print POSIX CRC checksum. * cmp: (diffutils)Invoking cmp. Compare 2 files byte by byte. * comm: (coreutils)comm invocation. Compare sorted files by line. * cp: (coreutils)cp invocation. Copy files. * csplit: (coreutils)csplit invocation. Split by context. * cut: (coreutils)cut invocation. Print selected parts of lines. * date: (coreutils)date invocation. Print/set system date and time. * dd: (coreutils)dd invocation. Copy and convert a file. * df: (coreutils)df invocation. Report file system disk usage. * diff: (diffutils)Invoking diff. Compare 2 files line by line. * diff3: (diffutils)Invoking diff3. Compare 3 files line by line. * dir: (coreutils)dir invocation. List directories briefly. * dircolors: (coreutils)dircolors invocation. Color setup for ls. * dirname: (coreutils)dirname invocation. Strip last file name component. * du: (coreutils)du invocation. Report on disk usage. * dvicopy: (web2c)dvicopy invocation. Virtual font expansion * dvitomp: (web2c)dvitomp invocation. DVI to MPX (MetaPost pictures). * dvitype: (web2c)dvitype invocation. DVI to human-readable text. * echo: (coreutils)echo invocation. Print a line of text. * env: (coreutils)env invocation. Modify the environment. * expand: (coreutils)expand invocation. Convert tabs to spaces. * expr: (coreutils)expr invocation. Evaluate expressions. * factor: (coreutils)factor invocation. Print prime factors * false: (coreutils)false invocation. Do nothing, unsuccessfully. * find: (find)Invoking find. Finding and acting on files. * fmt: (coreutils)fmt invocation. Reformat paragraph text. * fold: (coreutils)fold invocation. Wrap long input lines. * gftodvi: (web2c)gftodvi invocation. Generic font proofsheets. * gftopk: (web2c)gftopk invocation. Generic to packed fonts. * gftype: (web2c)gftype invocation. GF to human-readable text. * groups: (coreutils)groups invocation. Print group names a user is in. * gunzip: (gzip)Overview. Decompression. * gzexe: (gzip)Overview. Compress executables. * head: (coreutils)head invocation. Output the first part of files. * hostid: (coreutils)hostid invocation. Print numeric host identifier. * hostname: (coreutils)hostname invocation. Print or set system name. * id: (coreutils)id invocation. Print user identity. * install: (coreutils)install invocation. Copy files and set attributes. * join: (coreutils)join invocation. Join lines on a common field. * kill: (coreutils)kill invocation. Send a signal to processes. * link: (coreutils)link invocation. Make hard links between files. * ln: (coreutils)ln invocation. Make links between files. * locate: (find)Invoking locate. Finding files in a database. * logname: (coreutils)logname invocation. Print current login name. * ls: (coreutils)ls invocation. List directory contents. * md5sum: (coreutils)md5sum invocation. Print or check MD5 digests. * mf: (web2c)mf invocation. Creating typeface families. * mft: (web2c)mft invocation. Prettyprinting Metafont source. * mkdir: (coreutils)mkdir invocation. Create directories. * mkfifo: (coreutils)mkfifo invocation. Create FIFOs (named pipes). * mknod: (coreutils)mknod invocation. Create special files. * mktemp: (coreutils)mktemp invocation. Create temporary files. * mltex: (web2c)MLTeX. Multi-lingual TeX. * mpost: (web2c)mpost invocation. Creating technical diagrams. * mv: (coreutils)mv invocation. Rename files. * nice: (coreutils)nice invocation. Modify niceness. * nl: (coreutils)nl invocation. Number lines and write files. * nohup: (coreutils)nohup invocation. Immunize to hangups. * nproc: (coreutils)nproc invocation. Print the number of processors. * numfmt: (coreutils)numfmt invocation. Reformat numbers. * od: (coreutils)od invocation. Dump files in octal, etc. * paste: (coreutils)paste invocation. Merge lines of files. * patch: (diffutils)Invoking patch. Apply a patch to a file. * patgen: (web2c)patgen invocation. Creating hyphenation patterns. * pathchk: (coreutils)pathchk invocation. Check file name portability. * pktogf: (web2c)pktogf invocation. Packed to generic fonts. * pktype: (web2c)pktype invocation. PK to human-readable text. * pltotf: (web2c)pltotf invocation. Property list to TFM. * pooltype: (web2c)pooltype invocation. Display WEB pool files. * pr: (coreutils)pr invocation. Paginate or columnate files. * printenv: (coreutils)printenv invocation. Print environment variables. * printf: (coreutils)printf invocation. Format and print data. * ptx: (coreutils)ptx invocation. Produce permuted indexes. * pwd: (coreutils)pwd invocation. Print working directory. * readlink: (coreutils)readlink invocation. Print referent of a symlink. * realpath: (coreutils)realpath invocation. Print resolved file names. * rm: (coreutils)rm invocation. Remove files. * rmdir: (coreutils)rmdir invocation. Remove empty directories. * runcon: (coreutils)runcon invocation. Run in specified SELinux CTX. * sdiff: (diffutils)Invoking sdiff. Merge 2 files side-by-side. * seq: (coreutils)seq invocation. Print numeric sequences * sha1sum: (coreutils)sha1sum invocation. Print or check SHA-1 digests. * sha2: (coreutils)sha2 utilities. Print or check SHA-2 digests. * shred: (coreutils)shred invocation. Remove files more securely. * shuf: (coreutils)shuf invocation. Shuffling text files. * sleep: (coreutils)sleep invocation. Delay for a specified time. * sort: (coreutils)sort invocation. Sort text files. * split: (coreutils)split invocation. Split into pieces. * stat: (coreutils)stat invocation. Report file(system) status. * stdbuf: (coreutils)stdbuf invocation. Modify stdio buffering. * stty: (coreutils)stty invocation. Print/change terminal settings. * sum: (coreutils)sum invocation. Print traditional checksum. * sync: (coreutils)sync invocation. Synchronize memory to disk. * tac: (coreutils)tac invocation. Reverse files. * tail: (coreutils)tail invocation. Output the last part of files. * tangle: (web2c)tangle invocation. WEB to Pascal. * tee: (coreutils)tee invocation. Redirect to multiple files. * test: (coreutils)test invocation. File/string tests. * tex: (web2c)tex invocation. Typesetting. * tftopl: (web2c)tftopl invocation. TFM -> property list. * time: (time). Run programs and summarize system resource usage. * timeout: (coreutils)timeout invocation. Run with time limit. * touch: (coreutils)touch invocation. Change file timestamps. * tr: (coreutils)tr invocation. Translate characters. * true: (coreutils)true invocation. Do nothing, successfully. * truncate: (coreutils)truncate invocation. Shrink/extend size of a file. * tsort: (coreutils)tsort invocation. Topological sort. * tty: (coreutils)tty invocation. Print terminal name. * uname: (coreutils)uname invocation. Print system information. * unexpand: (coreutils)unexpand invocation. Convert spaces to tabs. * uniq: (coreutils)uniq invocation. Uniquify files. * unlink: (coreutils)unlink invocation. Removal via unlink(2). * updatedb: (find)Invoking updatedb. Building the locate database. * uptime: (coreutils)uptime invocation. Print uptime and load. * users: (coreutils)users invocation. Print current user names. * vdir: (coreutils)vdir invocation. List directories verbosely. * vftovp: (web2c)vftovp invocation. Virtual font -> virtual pl. * vptovf: (web2c)vptovf invocation. Virtual pl -> virtual font. * wc: (coreutils)wc invocation. Line, word, and byte counts. * weave: (web2c)weave invocation. WEB to TeX. * who: (coreutils)who invocation. Print who is logged in. * whoami: (coreutils)whoami invocation. Print effective user ID. * xargs: (find)Invoking xargs. Operating on many files. * yes: (coreutils)yes invocation. Print a string indefinitely. * zcat: (gzip)Overview. Decompression to stdout. * zdiff: (gzip)Overview. Compare compressed files. * zforce: (gzip)Overview. Force .gz extension on files. * zgrep: (gzip)Overview. Search compressed files. * zmore: (gzip)Overview. Decompression output by pages. Kernel * GRUB: (grub). The GRand Unified Bootloader * grub-dev: (grub-dev). The GRand Unified Bootloader Dev * grub-install: (grub)Invoking grub-install. Install GRUB on your drive * grub-mkconfig: (grub)Invoking grub-mkconfig. Generate GRUB configuration * grub-mkpasswd-pbkdf2: (grub)Invoking grub-mkpasswd-pbkdf2. * grub-mkrelpath: (grub)Invoking grub-mkrelpath. * grub-mkrescue: (grub)Invoking grub-mkrescue. Make a GRUB rescue image * grub-mount: (grub)Invoking grub-mount. Mount a file system using GRUB * grub-probe: (grub)Invoking grub-probe. Probe device information * grub-script-check: (grub)Invoking grub-script-check. Libraries * RLuserman: (rluserman). The GNU readline library User's Manual. Man-pages * Latex2man: (latex2man). Its Man-Page Math * bc: (bc). An arbitrary precision calculator language. * dc: (dc). Arbitrary precision RPN "Desktop Calculator". Network applications * Wget: (wget). Non-interactive network downloader. Programming * flex: (flex). Fast lexical analyzer generator (lex replacement). * gnucash: (gnucash-design). Design of the GnuCash program Programming Tools * Gperf: (gperf). Perfect Hash Function Generator. Software development * Autoconf Archive: (autoconf-archive). A collection of re-usable Autoconf macros. * Automake: (automake-1.15). Making GNU standards-compliant Makefiles. Sound * SSIP: (ssip). Speech Synthesis Interface Protocol. * Say for Speech Dispatcher: (spd-say). Say. * Speech Dispatcher: (speech-dispatcher). Speech Dispatcher. TeX * DVI-to-PNG: (dvipng). Translating TeX DVI files to Portable Network Graphics (PNG). * DVI-to-Postscript: (dvips). Translating TeX DVI files to PostScript. * Eplain: (eplain). Expanding on plain Tex. * EpsPDF: (epspdf). Portable GUI- and command-line EPS/PS/PDF conversion * Kpathsea: (kpathsea). File lookup along search paths. * LaTeX2e: (latex2e). Unofficial LaTeX reference manual. * LaTeX2e-es: (latex2e-es). Manual de extraoficial de LaTeX. * Naming TeX fonts: (fontname). Filenames for TeX fonts. * TL-build: (tlbuild). TeX Live configuration and development. * TeX Directories: (tds). A directory structure for TeX files. * TeXdraw: (texdraw). A system for producing PostScript drawings from TeX. * Web2c: (web2c). TeX, Metafont, and companion programs. * afm2tfm: (dvips)Invoking afm2tfm. Making Type 1 fonts available to TeX. * dvipng: (dvipng). A DVI-to-PNG translator. * dvips: (dvips)Invoking Dvips. DVI-to-PostScript translator. * kpsewhich: (kpathsea)Invoking kpsewhich. TeX file searching. * mf2pt1: (mf2pt1). PostScript Type 1 fonts from Metafont source. * mktexfmt: (kpathsea)mktex scripts. Format (fmt/base/mem) generation. * mktexlsr: (kpathsea)Filename database. Update ls-R. * mktexmf: (kpathsea)mktex scripts. MF source generation. * mktexpk: (kpathsea)mktex scripts. PK bitmap generation. * mktextex: (kpathsea)mktex scripts. TeX source generation. * mktextfm: (kpathsea)mktex scripts. TeX font metric generation. Text creation and manipulation * Diffutils: (diffutils). Comparing and merging files. * M4: (m4). A powerful macro processor. * grep: (grep). Print lines matching a pattern. * sed: (sed). Stream EDitor. command. Use * SSID MODE CHAN RATE SIGNAL BARS SECURITY to get current connections
6 years ago
Remove wifi info from File: dir, Node: Top, This is the top of the INFO tree. This is the Info main menu (aka directory node). A few useful Info commands: 'q' quits; '?' lists all Info commands; 'h' starts the Info tutorial; 'mTexinfo RET' visits the Texinfo manual, etc. * Menu: Basics * Common options: (coreutils)Common options. * Coreutils: (coreutils). Core GNU (file, text, shell) utilities. * Date input formats: (coreutils)Date input formats. * Ed: (ed). The GNU line editor * File permissions: (coreutils)File permissions. Access modes. * Finding files: (find). Operating on files matching certain criteria. C++ libraries * autosprintf: (autosprintf). Support for printf format strings in C++. Compression * Gzip: (gzip). General (de)compression of files (lzw). Development * SSIP: (ssip). Speech Synthesis Interface Protocol. * Speech Dispatcher: (speech-dispatcher). Speech Dispatcher. * libffi: (libffi). Portable foreign-function interface library. DOS * Mtools: (mtools). Mtools: utilities to access DOS disks in Unix. Editors * nano: (nano). Small and friendly text editor. General Commands * Screen: (screen). Full-screen window manager. GNU Gettext Utilities * autopoint: (gettext)autopoint Invocation. Copy gettext infrastructure. * envsubst: (gettext)envsubst Invocation. Expand environment variables. * gettextize: (gettext)gettextize Invocation. Prepare a package for gettext. * gettext: (gettext). GNU gettext utilities. * ISO3166: (gettext)Country Codes. ISO 3166 country codes. * ISO639: (gettext)Language Codes. ISO 639 language codes. * msgattrib: (gettext)msgattrib Invocation. Select part of a PO file. * msgcat: (gettext)msgcat Invocation. Combine several PO files. * msgcmp: (gettext)msgcmp Invocation. Compare a PO file and template. * msgcomm: (gettext)msgcomm Invocation. Match two PO files. * msgconv: (gettext)msgconv Invocation. Convert PO file to encoding. * msgen: (gettext)msgen Invocation. Create an English PO file. * msgexec: (gettext)msgexec Invocation. Process a PO file. * msgfilter: (gettext)msgfilter Invocation. Pipe a PO file through a filter. * msgfmt: (gettext)msgfmt Invocation. Make MO files out of PO files. * msggrep: (gettext)msggrep Invocation. Select part of a PO file. * msginit: (gettext)msginit Invocation. Create a fresh PO file. * msgmerge: (gettext)msgmerge Invocation. Update a PO file from template. * msgunfmt: (gettext)msgunfmt Invocation. Uncompile MO file into PO file. * msguniq: (gettext)msguniq Invocation. Unify duplicates for PO file. * ngettext: (gettext)ngettext Invocation. Translate a message with plural. * xgettext: (gettext)xgettext Invocation. Extract strings into a PO file. GNU organization * Maintaining Findutils: (find-maint). Maintaining GNU findutils GNU Utilities * dirmngr-client: (gnupg). X.509 CRL and OCSP client. * dirmngr: (gnupg). X.509 CRL and OCSP server. * gpg: (gnupg1). OpenPGP encryption and signing tool (v1). * gpg-agent: (gnupg). The secret key daemon. * gpg2: (gnupg). OpenPGP encryption and signing tool. * gpgsm: (gnupg). S/MIME encryption and signing tool. Individual utilities * aclocal-invocation: (automake-1.15)aclocal Invocation. Generating aclocal.m4. * arch: (coreutils)arch invocation. Print machine hardware name. * automake-invocation: (automake-1.15)automake Invocation. Generating Makefile.in. * base32: (coreutils)base32 invocation. Base32 encode/decode data. * base64: (coreutils)base64 invocation. Base64 encode/decode data. * basename: (coreutils)basename invocation. Strip directory and suffix. * bibtex: (web2c)bibtex invocation. Maintaining bibliographies. * cat: (coreutils)cat invocation. Concatenate and write files. * chcon: (coreutils)chcon invocation. Change SELinux CTX of files. * chgrp: (coreutils)chgrp invocation. Change file groups. * chmod: (coreutils)chmod invocation. Change access permissions. * chown: (coreutils)chown invocation. Change file owners and groups. * chroot: (coreutils)chroot invocation. Specify the root directory. * cksum: (coreutils)cksum invocation. Print POSIX CRC checksum. * cmp: (diffutils)Invoking cmp. Compare 2 files byte by byte. * comm: (coreutils)comm invocation. Compare sorted files by line. * cp: (coreutils)cp invocation. Copy files. * csplit: (coreutils)csplit invocation. Split by context. * cut: (coreutils)cut invocation. Print selected parts of lines. * date: (coreutils)date invocation. Print/set system date and time. * dd: (coreutils)dd invocation. Copy and convert a file. * df: (coreutils)df invocation. Report file system disk usage. * diff: (diffutils)Invoking diff. Compare 2 files line by line. * diff3: (diffutils)Invoking diff3. Compare 3 files line by line. * dir: (coreutils)dir invocation. List directories briefly. * dircolors: (coreutils)dircolors invocation. Color setup for ls. * dirname: (coreutils)dirname invocation. Strip last file name component. * du: (coreutils)du invocation. Report on disk usage. * dvicopy: (web2c)dvicopy invocation. Virtual font expansion * dvitomp: (web2c)dvitomp invocation. DVI to MPX (MetaPost pictures). * dvitype: (web2c)dvitype invocation. DVI to human-readable text. * echo: (coreutils)echo invocation. Print a line of text. * env: (coreutils)env invocation. Modify the environment. * expand: (coreutils)expand invocation. Convert tabs to spaces. * expr: (coreutils)expr invocation. Evaluate expressions. * factor: (coreutils)factor invocation. Print prime factors * false: (coreutils)false invocation. Do nothing, unsuccessfully. * find: (find)Invoking find. Finding and acting on files. * fmt: (coreutils)fmt invocation. Reformat paragraph text. * fold: (coreutils)fold invocation. Wrap long input lines. * gftodvi: (web2c)gftodvi invocation. Generic font proofsheets. * gftopk: (web2c)gftopk invocation. Generic to packed fonts. * gftype: (web2c)gftype invocation. GF to human-readable text. * groups: (coreutils)groups invocation. Print group names a user is in. * gunzip: (gzip)Overview. Decompression. * gzexe: (gzip)Overview. Compress executables. * head: (coreutils)head invocation. Output the first part of files. * hostid: (coreutils)hostid invocation. Print numeric host identifier. * hostname: (coreutils)hostname invocation. Print or set system name. * id: (coreutils)id invocation. Print user identity. * install: (coreutils)install invocation. Copy files and set attributes. * join: (coreutils)join invocation. Join lines on a common field. * kill: (coreutils)kill invocation. Send a signal to processes. * link: (coreutils)link invocation. Make hard links between files. * ln: (coreutils)ln invocation. Make links between files. * locate: (find)Invoking locate. Finding files in a database. * logname: (coreutils)logname invocation. Print current login name. * ls: (coreutils)ls invocation. List directory contents. * md5sum: (coreutils)md5sum invocation. Print or check MD5 digests. * mf: (web2c)mf invocation. Creating typeface families. * mft: (web2c)mft invocation. Prettyprinting Metafont source. * mkdir: (coreutils)mkdir invocation. Create directories. * mkfifo: (coreutils)mkfifo invocation. Create FIFOs (named pipes). * mknod: (coreutils)mknod invocation. Create special files. * mktemp: (coreutils)mktemp invocation. Create temporary files. * mltex: (web2c)MLTeX. Multi-lingual TeX. * mpost: (web2c)mpost invocation. Creating technical diagrams. * mv: (coreutils)mv invocation. Rename files. * nice: (coreutils)nice invocation. Modify niceness. * nl: (coreutils)nl invocation. Number lines and write files. * nohup: (coreutils)nohup invocation. Immunize to hangups. * nproc: (coreutils)nproc invocation. Print the number of processors. * numfmt: (coreutils)numfmt invocation. Reformat numbers. * od: (coreutils)od invocation. Dump files in octal, etc. * paste: (coreutils)paste invocation. Merge lines of files. * patch: (diffutils)Invoking patch. Apply a patch to a file. * patgen: (web2c)patgen invocation. Creating hyphenation patterns. * pathchk: (coreutils)pathchk invocation. Check file name portability. * pktogf: (web2c)pktogf invocation. Packed to generic fonts. * pktype: (web2c)pktype invocation. PK to human-readable text. * pltotf: (web2c)pltotf invocation. Property list to TFM. * pooltype: (web2c)pooltype invocation. Display WEB pool files. * pr: (coreutils)pr invocation. Paginate or columnate files. * printenv: (coreutils)printenv invocation. Print environment variables. * printf: (coreutils)printf invocation. Format and print data. * ptx: (coreutils)ptx invocation. Produce permuted indexes. * pwd: (coreutils)pwd invocation. Print working directory. * readlink: (coreutils)readlink invocation. Print referent of a symlink. * realpath: (coreutils)realpath invocation. Print resolved file names. * rm: (coreutils)rm invocation. Remove files. * rmdir: (coreutils)rmdir invocation. Remove empty directories. * runcon: (coreutils)runcon invocation. Run in specified SELinux CTX. * sdiff: (diffutils)Invoking sdiff. Merge 2 files side-by-side. * seq: (coreutils)seq invocation. Print numeric sequences * sha1sum: (coreutils)sha1sum invocation. Print or check SHA-1 digests. * sha2: (coreutils)sha2 utilities. Print or check SHA-2 digests. * shred: (coreutils)shred invocation. Remove files more securely. * shuf: (coreutils)shuf invocation. Shuffling text files. * sleep: (coreutils)sleep invocation. Delay for a specified time. * sort: (coreutils)sort invocation. Sort text files. * split: (coreutils)split invocation. Split into pieces. * stat: (coreutils)stat invocation. Report file(system) status. * stdbuf: (coreutils)stdbuf invocation. Modify stdio buffering. * stty: (coreutils)stty invocation. Print/change terminal settings. * sum: (coreutils)sum invocation. Print traditional checksum. * sync: (coreutils)sync invocation. Synchronize memory to disk. * tac: (coreutils)tac invocation. Reverse files. * tail: (coreutils)tail invocation. Output the last part of files. * tangle: (web2c)tangle invocation. WEB to Pascal. * tee: (coreutils)tee invocation. Redirect to multiple files. * test: (coreutils)test invocation. File/string tests. * tex: (web2c)tex invocation. Typesetting. * tftopl: (web2c)tftopl invocation. TFM -> property list. * time: (time). Run programs and summarize system resource usage. * timeout: (coreutils)timeout invocation. Run with time limit. * touch: (coreutils)touch invocation. Change file timestamps. * tr: (coreutils)tr invocation. Translate characters. * true: (coreutils)true invocation. Do nothing, successfully. * truncate: (coreutils)truncate invocation. Shrink/extend size of a file. * tsort: (coreutils)tsort invocation. Topological sort. * tty: (coreutils)tty invocation. Print terminal name. * uname: (coreutils)uname invocation. Print system information. * unexpand: (coreutils)unexpand invocation. Convert spaces to tabs. * uniq: (coreutils)uniq invocation. Uniquify files. * unlink: (coreutils)unlink invocation. Removal via unlink(2). * updatedb: (find)Invoking updatedb. Building the locate database. * uptime: (coreutils)uptime invocation. Print uptime and load. * users: (coreutils)users invocation. Print current user names. * vdir: (coreutils)vdir invocation. List directories verbosely. * vftovp: (web2c)vftovp invocation. Virtual font -> virtual pl. * vptovf: (web2c)vptovf invocation. Virtual pl -> virtual font. * wc: (coreutils)wc invocation. Line, word, and byte counts. * weave: (web2c)weave invocation. WEB to TeX. * who: (coreutils)who invocation. Print who is logged in. * whoami: (coreutils)whoami invocation. Print effective user ID. * xargs: (find)Invoking xargs. Operating on many files. * yes: (coreutils)yes invocation. Print a string indefinitely. * zcat: (gzip)Overview. Decompression to stdout. * zdiff: (gzip)Overview. Compare compressed files. * zforce: (gzip)Overview. Force .gz extension on files. * zgrep: (gzip)Overview. Search compressed files. * zmore: (gzip)Overview. Decompression output by pages. Kernel * GRUB: (grub). The GRand Unified Bootloader * grub-dev: (grub-dev). The GRand Unified Bootloader Dev * grub-install: (grub)Invoking grub-install. Install GRUB on your drive * grub-mkconfig: (grub)Invoking grub-mkconfig. Generate GRUB configuration * grub-mkpasswd-pbkdf2: (grub)Invoking grub-mkpasswd-pbkdf2. * grub-mkrelpath: (grub)Invoking grub-mkrelpath. * grub-mkrescue: (grub)Invoking grub-mkrescue. Make a GRUB rescue image * grub-mount: (grub)Invoking grub-mount. Mount a file system using GRUB * grub-probe: (grub)Invoking grub-probe. Probe device information * grub-script-check: (grub)Invoking grub-script-check. Libraries * RLuserman: (rluserman). The GNU readline library User's Manual. Man-pages * Latex2man: (latex2man). Its Man-Page Math * bc: (bc). An arbitrary precision calculator language. * dc: (dc). Arbitrary precision RPN "Desktop Calculator". Network applications * Wget: (wget). Non-interactive network downloader. Programming * flex: (flex). Fast lexical analyzer generator (lex replacement). * gnucash: (gnucash-design). Design of the GnuCash program Programming Tools * Gperf: (gperf). Perfect Hash Function Generator. Software development * Autoconf Archive: (autoconf-archive). A collection of re-usable Autoconf macros. * Automake: (automake-1.15). Making GNU standards-compliant Makefiles. Sound * SSIP: (ssip). Speech Synthesis Interface Protocol. * Say for Speech Dispatcher: (spd-say). Say. * Speech Dispatcher: (speech-dispatcher). Speech Dispatcher. TeX * DVI-to-PNG: (dvipng). Translating TeX DVI files to Portable Network Graphics (PNG). * DVI-to-Postscript: (dvips). Translating TeX DVI files to PostScript. * Eplain: (eplain). Expanding on plain Tex. * EpsPDF: (epspdf). Portable GUI- and command-line EPS/PS/PDF conversion * Kpathsea: (kpathsea). File lookup along search paths. * LaTeX2e: (latex2e). Unofficial LaTeX reference manual. * LaTeX2e-es: (latex2e-es). Manual de extraoficial de LaTeX. * Naming TeX fonts: (fontname). Filenames for TeX fonts. * TL-build: (tlbuild). TeX Live configuration and development. * TeX Directories: (tds). A directory structure for TeX files. * TeXdraw: (texdraw). A system for producing PostScript drawings from TeX. * Web2c: (web2c). TeX, Metafont, and companion programs. * afm2tfm: (dvips)Invoking afm2tfm. Making Type 1 fonts available to TeX. * dvipng: (dvipng). A DVI-to-PNG translator. * dvips: (dvips)Invoking Dvips. DVI-to-PostScript translator. * kpsewhich: (kpathsea)Invoking kpsewhich. TeX file searching. * mf2pt1: (mf2pt1). PostScript Type 1 fonts from Metafont source. * mktexfmt: (kpathsea)mktex scripts. Format (fmt/base/mem) generation. * mktexlsr: (kpathsea)Filename database. Update ls-R. * mktexmf: (kpathsea)mktex scripts. MF source generation. * mktexpk: (kpathsea)mktex scripts. PK bitmap generation. * mktextex: (kpathsea)mktex scripts. TeX source generation. * mktextfm: (kpathsea)mktex scripts. TeX font metric generation. Text creation and manipulation * Diffutils: (diffutils). Comparing and merging files. * M4: (m4). A powerful macro processor. * grep: (grep). Print lines matching a pattern. * sed: (sed). Stream EDitor. command. Use * SSID MODE CHAN RATE SIGNAL BARS SECURITY to get current connections
6 years ago
8 years ago
8 years ago
6 years ago
6 years ago
  1. /*
  2. WIFI MODULE
  3. Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com>
  4. */
  5. #include <JustWifi.h>
  6. #include <Ticker.h>
  7. #include "ws.h"
  8. bool _wifi_wps_running = false;
  9. bool _wifi_smartconfig_running = false;
  10. bool _wifi_smartconfig_initial = false;
  11. uint8_t _wifi_ap_mode = WIFI_AP_FALLBACK;
  12. #if WIFI_GRATUITOUS_ARP_SUPPORT
  13. unsigned long _wifi_gratuitous_arp_interval = 0;
  14. unsigned long _wifi_gratuitous_arp_last = 0;
  15. #endif
  16. // -----------------------------------------------------------------------------
  17. // PRIVATE
  18. // -----------------------------------------------------------------------------
  19. struct wifi_scan_info_t {
  20. String ssid_scan;
  21. int32_t rssi_scan;
  22. uint8_t sec_scan;
  23. uint8_t* BSSID_scan;
  24. int32_t chan_scan;
  25. bool hidden_scan;
  26. char buffer[128];
  27. };
  28. void _wifiUpdateSoftAP() {
  29. if (WiFi.softAPgetStationNum() == 0) {
  30. #if USE_PASSWORD
  31. jw.setSoftAP(getSetting("hostname").c_str(), getAdminPass().c_str());
  32. #else
  33. jw.setSoftAP(getSetting("hostname").c_str());
  34. #endif
  35. }
  36. }
  37. void _wifiCheckAP() {
  38. if (
  39. (WIFI_AP_FALLBACK == _wifi_ap_mode)
  40. && ((WiFi.getMode() & WIFI_AP) > 0)
  41. && jw.connected()
  42. && (WiFi.softAPgetStationNum() == 0)
  43. ) {
  44. jw.enableAP(false);
  45. }
  46. }
  47. void _wifiConfigure() {
  48. jw.setHostname(getSetting("hostname").c_str());
  49. _wifiUpdateSoftAP();
  50. jw.setConnectTimeout(WIFI_CONNECT_TIMEOUT);
  51. wifiReconnectCheck();
  52. jw.enableAPFallback(WIFI_FALLBACK_APMODE);
  53. jw.cleanNetworks();
  54. _wifi_ap_mode = getSetting("apmode", WIFI_AP_FALLBACK).toInt();
  55. // If system is flagged unstable we do not init wifi networks
  56. #if SYSTEM_CHECK_ENABLED
  57. if (!systemCheck()) return;
  58. #endif
  59. // Clean settings
  60. _wifiClean(WIFI_MAX_NETWORKS);
  61. int i;
  62. for (i = 0; i< WIFI_MAX_NETWORKS; i++) {
  63. if (!hasSetting("ssid", i)) break;
  64. if (!hasSetting("ip", i)) {
  65. jw.addNetwork(
  66. getSetting("ssid", i, "").c_str(),
  67. getSetting("pass", i, "").c_str()
  68. );
  69. } else {
  70. jw.addNetwork(
  71. getSetting("ssid", i, "").c_str(),
  72. getSetting("pass", i, "").c_str(),
  73. getSetting("ip", i, "").c_str(),
  74. getSetting("gw", i, "").c_str(),
  75. getSetting("mask", i, "").c_str(),
  76. getSetting("dns", i, "").c_str()
  77. );
  78. }
  79. }
  80. #if JUSTWIFI_ENABLE_SMARTCONFIG
  81. if (i == 0) _wifi_smartconfig_initial = true;
  82. #endif
  83. jw.enableScan(getSetting("wifiScan", WIFI_SCAN_NETWORKS).toInt() == 1);
  84. unsigned char sleep_mode = getSetting("wifiSleep", WIFI_SLEEP_MODE).toInt();
  85. sleep_mode = constrain(sleep_mode, 0, 2);
  86. WiFi.setSleepMode(static_cast<WiFiSleepType_t>(sleep_mode));
  87. #if WIFI_GRATUITOUS_ARP_SUPPORT
  88. _wifi_gratuitous_arp_last = millis();
  89. _wifi_gratuitous_arp_interval = getSetting("wifiGarpIntvl", secureRandom(
  90. WIFI_GRATUITOUS_ARP_INTERVAL_MIN, WIFI_GRATUITOUS_ARP_INTERVAL_MAX
  91. )).toInt();
  92. #endif
  93. const auto tx_power = getSetting("wifiTxPwr", WIFI_OUTPUT_POWER_DBM).toFloat();
  94. WiFi.setOutputPower(tx_power);
  95. }
  96. void _wifiScan(wifi_scan_f callback = nullptr) {
  97. DEBUG_MSG_P(PSTR("[WIFI] Start scanning\n"));
  98. unsigned char result = WiFi.scanNetworks();
  99. if (result == WIFI_SCAN_FAILED) {
  100. DEBUG_MSG_P(PSTR("[WIFI] Scan failed\n"));
  101. return;
  102. } else if (result == 0) {
  103. DEBUG_MSG_P(PSTR("[WIFI] No networks found\n"));
  104. return;
  105. }
  106. DEBUG_MSG_P(PSTR("[WIFI] %d networks found:\n"), result);
  107. // Populate defined networks with scan data
  108. wifi_scan_info_t info;
  109. for (unsigned char i = 0; i < result; ++i) {
  110. WiFi.getNetworkInfo(i, info.ssid_scan, info.sec_scan, info.rssi_scan, info.BSSID_scan, info.chan_scan, info.hidden_scan);
  111. snprintf_P(info.buffer, sizeof(info.buffer),
  112. PSTR("BSSID: %02X:%02X:%02X:%02X:%02X:%02X SEC: %s RSSI: %3d CH: %2d SSID: %s"),
  113. info.BSSID_scan[0], info.BSSID_scan[1], info.BSSID_scan[2], info.BSSID_scan[3], info.BSSID_scan[4], info.BSSID_scan[5],
  114. (info.sec_scan != ENC_TYPE_NONE ? "YES" : "NO "),
  115. info.rssi_scan,
  116. info.chan_scan,
  117. info.ssid_scan.c_str()
  118. );
  119. if (callback) {
  120. callback(info);
  121. } else {
  122. DEBUG_MSG_P(PSTR("[WIFI] > %s\n"), info.buffer);
  123. }
  124. }
  125. WiFi.scanDelete();
  126. }
  127. bool _wifiClean(unsigned char num) {
  128. bool changed = false;
  129. int i = 0;
  130. // Clean defined settings
  131. while (i < num) {
  132. // Skip on first non-defined setting
  133. if (!hasSetting("ssid", i)) {
  134. delSetting("ssid", i);
  135. break;
  136. }
  137. // Delete empty values
  138. if (!hasSetting("pass", i)) delSetting("pass", i);
  139. if (!hasSetting("ip", i)) delSetting("ip", i);
  140. if (!hasSetting("gw", i)) delSetting("gw", i);
  141. if (!hasSetting("mask", i)) delSetting("mask", i);
  142. if (!hasSetting("dns", i)) delSetting("dns", i);
  143. ++i;
  144. }
  145. // Delete all other settings
  146. while (i < WIFI_MAX_NETWORKS) {
  147. changed = hasSetting("ssid", i);
  148. delSetting("ssid", i);
  149. delSetting("pass", i);
  150. delSetting("ip", i);
  151. delSetting("gw", i);
  152. delSetting("mask", i);
  153. delSetting("dns", i);
  154. ++i;
  155. }
  156. return changed;
  157. }
  158. // Inject hardcoded networks
  159. void _wifiInject() {
  160. if (strlen(WIFI1_SSID)) {
  161. if (!hasSetting("ssid", 0)) {
  162. setSetting("ssid", 0, F(WIFI1_SSID));
  163. setSetting("pass", 0, F(WIFI1_PASS));
  164. setSetting("ip", 0, F(WIFI1_IP));
  165. setSetting("gw", 0, F(WIFI1_GW));
  166. setSetting("mask", 0, F(WIFI1_MASK));
  167. setSetting("dns", 0, F(WIFI1_DNS));
  168. }
  169. if (strlen(WIFI2_SSID)) {
  170. if (!hasSetting("ssid", 1)) {
  171. setSetting("ssid", 1, F(WIFI2_SSID));
  172. setSetting("pass", 1, F(WIFI2_PASS));
  173. setSetting("ip", 1, F(WIFI2_IP));
  174. setSetting("gw", 1, F(WIFI2_GW));
  175. setSetting("mask", 1, F(WIFI2_MASK));
  176. setSetting("dns", 1, F(WIFI2_DNS));
  177. }
  178. if (strlen(WIFI3_SSID)) {
  179. if (!hasSetting("ssid", 2)) {
  180. setSetting("ssid", 2, F(WIFI3_SSID));
  181. setSetting("pass", 2, F(WIFI3_PASS));
  182. setSetting("ip", 2, F(WIFI3_IP));
  183. setSetting("gw", 2, F(WIFI3_GW));
  184. setSetting("mask", 2, F(WIFI3_MASK));
  185. setSetting("dns", 2, F(WIFI3_DNS));
  186. }
  187. if (strlen(WIFI4_SSID)) {
  188. if (!hasSetting("ssid", 3)) {
  189. setSetting("ssid", 3, F(WIFI4_SSID));
  190. setSetting("pass", 3, F(WIFI4_PASS));
  191. setSetting("ip", 3, F(WIFI4_IP));
  192. setSetting("gw", 3, F(WIFI4_GW));
  193. setSetting("mask", 3, F(WIFI4_MASK));
  194. setSetting("dns", 3, F(WIFI4_DNS));
  195. }
  196. }
  197. }
  198. }
  199. }
  200. }
  201. void _wifiCallback(justwifi_messages_t code, char * parameter) {
  202. if (MESSAGE_WPS_START == code) {
  203. _wifi_wps_running = true;
  204. }
  205. if (MESSAGE_SMARTCONFIG_START == code) {
  206. _wifi_smartconfig_running = true;
  207. }
  208. if (MESSAGE_WPS_ERROR == code || MESSAGE_SMARTCONFIG_ERROR == code) {
  209. _wifi_wps_running = false;
  210. _wifi_smartconfig_running = false;
  211. }
  212. if (MESSAGE_WPS_SUCCESS == code || MESSAGE_SMARTCONFIG_SUCCESS == code) {
  213. String ssid = WiFi.SSID();
  214. String pass = WiFi.psk();
  215. // Look for the same SSID
  216. uint8_t count = 0;
  217. while (count < WIFI_MAX_NETWORKS) {
  218. if (!hasSetting("ssid", count)) break;
  219. if (ssid.equals(getSetting("ssid", count, ""))) break;
  220. count++;
  221. }
  222. // If we have reached the max we overwrite the first one
  223. if (WIFI_MAX_NETWORKS == count) count = 0;
  224. setSetting("ssid", count, ssid);
  225. setSetting("pass", count, pass);
  226. _wifi_wps_running = false;
  227. _wifi_smartconfig_running = false;
  228. }
  229. }
  230. #if WIFI_AP_CAPTIVE
  231. #include "DNSServer.h"
  232. DNSServer _wifi_dnsServer;
  233. void _wifiCaptivePortal(justwifi_messages_t code, char * parameter) {
  234. if (MESSAGE_ACCESSPOINT_CREATED == code) {
  235. _wifi_dnsServer.setErrorReplyCode(DNSReplyCode::NoError);
  236. _wifi_dnsServer.start(53, "*", WiFi.softAPIP());
  237. DEBUG_MSG_P(PSTR("[WIFI] Captive portal enabled\n"));
  238. }
  239. if (MESSAGE_CONNECTED == code) {
  240. _wifi_dnsServer.stop();
  241. DEBUG_MSG_P(PSTR("[WIFI] Captive portal disabled\n"));
  242. }
  243. }
  244. #endif // WIFI_AP_CAPTIVE
  245. #if DEBUG_SUPPORT
  246. void _wifiDebugCallback(justwifi_messages_t code, char * parameter) {
  247. // -------------------------------------------------------------------------
  248. if (code == MESSAGE_SCANNING) {
  249. DEBUG_MSG_P(PSTR("[WIFI] Scanning\n"));
  250. }
  251. if (code == MESSAGE_SCAN_FAILED) {
  252. DEBUG_MSG_P(PSTR("[WIFI] Scan failed\n"));
  253. }
  254. if (code == MESSAGE_NO_NETWORKS) {
  255. DEBUG_MSG_P(PSTR("[WIFI] No networks found\n"));
  256. }
  257. if (code == MESSAGE_NO_KNOWN_NETWORKS) {
  258. DEBUG_MSG_P(PSTR("[WIFI] No known networks found\n"));
  259. }
  260. if (code == MESSAGE_FOUND_NETWORK) {
  261. DEBUG_MSG_P(PSTR("[WIFI] %s\n"), parameter);
  262. }
  263. // -------------------------------------------------------------------------
  264. if (code == MESSAGE_CONNECTING) {
  265. DEBUG_MSG_P(PSTR("[WIFI] Connecting to %s\n"), parameter);
  266. }
  267. if (code == MESSAGE_CONNECT_WAITING) {
  268. // too much noise
  269. }
  270. if (code == MESSAGE_CONNECT_FAILED) {
  271. DEBUG_MSG_P(PSTR("[WIFI] Could not connect to %s\n"), parameter);
  272. }
  273. if (code == MESSAGE_CONNECTED) {
  274. wifiDebug(WIFI_STA);
  275. }
  276. if (code == MESSAGE_DISCONNECTED) {
  277. DEBUG_MSG_P(PSTR("[WIFI] Disconnected\n"));
  278. }
  279. // -------------------------------------------------------------------------
  280. if (code == MESSAGE_ACCESSPOINT_CREATING) {
  281. DEBUG_MSG_P(PSTR("[WIFI] Creating access point\n"));
  282. }
  283. if (code == MESSAGE_ACCESSPOINT_CREATED) {
  284. wifiDebug(WIFI_AP);
  285. }
  286. if (code == MESSAGE_ACCESSPOINT_FAILED) {
  287. DEBUG_MSG_P(PSTR("[WIFI] Could not create access point\n"));
  288. }
  289. if (code == MESSAGE_ACCESSPOINT_DESTROYED) {
  290. _wifiUpdateSoftAP();
  291. DEBUG_MSG_P(PSTR("[WIFI] Access point destroyed\n"));
  292. }
  293. // -------------------------------------------------------------------------
  294. if (code == MESSAGE_WPS_START) {
  295. DEBUG_MSG_P(PSTR("[WIFI] WPS started\n"));
  296. }
  297. if (code == MESSAGE_WPS_SUCCESS) {
  298. DEBUG_MSG_P(PSTR("[WIFI] WPS succeded!\n"));
  299. }
  300. if (code == MESSAGE_WPS_ERROR) {
  301. DEBUG_MSG_P(PSTR("[WIFI] WPS failed\n"));
  302. }
  303. // ------------------------------------------------------------------------
  304. if (code == MESSAGE_SMARTCONFIG_START) {
  305. DEBUG_MSG_P(PSTR("[WIFI] Smart Config started\n"));
  306. }
  307. if (code == MESSAGE_SMARTCONFIG_SUCCESS) {
  308. DEBUG_MSG_P(PSTR("[WIFI] Smart Config succeded!\n"));
  309. }
  310. if (code == MESSAGE_SMARTCONFIG_ERROR) {
  311. DEBUG_MSG_P(PSTR("[WIFI] Smart Config failed\n"));
  312. }
  313. }
  314. #endif // DEBUG_SUPPORT
  315. // -----------------------------------------------------------------------------
  316. // SETTINGS
  317. // -----------------------------------------------------------------------------
  318. #if TERMINAL_SUPPORT
  319. void _wifiInitCommands() {
  320. terminalRegisterCommand(F("WIFI"), [](Embedis* e) {
  321. wifiDebug();
  322. terminalOK();
  323. });
  324. terminalRegisterCommand(F("WIFI.RESET"), [](Embedis* e) {
  325. _wifiConfigure();
  326. wifiDisconnect();
  327. terminalOK();
  328. });
  329. terminalRegisterCommand(F("WIFI.STA"), [](Embedis* e) {
  330. wifiStartSTA();
  331. terminalOK();
  332. });
  333. terminalRegisterCommand(F("WIFI.AP"), [](Embedis* e) {
  334. wifiStartAP();
  335. terminalOK();
  336. });
  337. #if defined(JUSTWIFI_ENABLE_WPS)
  338. terminalRegisterCommand(F("WIFI.WPS"), [](Embedis* e) {
  339. wifiStartWPS();
  340. terminalOK();
  341. });
  342. #endif // defined(JUSTWIFI_ENABLE_WPS)
  343. #if defined(JUSTWIFI_ENABLE_SMARTCONFIG)
  344. terminalRegisterCommand(F("WIFI.SMARTCONFIG"), [](Embedis* e) {
  345. wifiStartSmartConfig();
  346. terminalOK();
  347. });
  348. #endif // defined(JUSTWIFI_ENABLE_SMARTCONFIG)
  349. terminalRegisterCommand(F("WIFI.SCAN"), [](Embedis* e) {
  350. _wifiScan();
  351. terminalOK();
  352. });
  353. }
  354. #endif
  355. // -----------------------------------------------------------------------------
  356. // WEB
  357. // -----------------------------------------------------------------------------
  358. #if WEB_SUPPORT
  359. bool _wifiWebSocketOnKeyCheck(const char * key, JsonVariant& value) {
  360. if (strncmp(key, "wifi", 4) == 0) return true;
  361. if (strncmp(key, "ssid", 4) == 0) return true;
  362. if (strncmp(key, "pass", 4) == 0) return true;
  363. if (strncmp(key, "ip", 2) == 0) return true;
  364. if (strncmp(key, "gw", 2) == 0) return true;
  365. if (strncmp(key, "mask", 4) == 0) return true;
  366. if (strncmp(key, "dns", 3) == 0) return true;
  367. return false;
  368. }
  369. void _wifiWebSocketOnConnected(JsonObject& root) {
  370. root["maxNetworks"] = WIFI_MAX_NETWORKS;
  371. root["wifiScan"] = getSetting("wifiScan", WIFI_SCAN_NETWORKS).toInt() == 1;
  372. JsonArray& wifi = root.createNestedArray("wifi");
  373. for (byte i=0; i<WIFI_MAX_NETWORKS; i++) {
  374. if (!hasSetting("ssid", i)) break;
  375. JsonObject& network = wifi.createNestedObject();
  376. network["ssid"] = getSetting("ssid", i, "");
  377. network["pass"] = getSetting("pass", i, "");
  378. network["ip"] = getSetting("ip", i, "");
  379. network["gw"] = getSetting("gw", i, "");
  380. network["mask"] = getSetting("mask", i, "");
  381. network["dns"] = getSetting("dns", i, "");
  382. }
  383. }
  384. void _wifiWebSocketScan(JsonObject& root) {
  385. JsonArray& scanResult = root.createNestedArray("scanResult");
  386. _wifiScan([&scanResult](wifi_scan_info_t& info) {
  387. scanResult.add(info.buffer);
  388. });
  389. }
  390. void _wifiWebSocketOnAction(uint32_t client_id, const char * action, JsonObject& data) {
  391. if (strcmp(action, "scan") == 0) wsPost(client_id, _wifiWebSocketScan);
  392. }
  393. #endif
  394. // -----------------------------------------------------------------------------
  395. // SUPPORT
  396. // -----------------------------------------------------------------------------
  397. #if WIFI_GRATUITOUS_ARP_SUPPORT
  398. // ref: lwip src/core/netif.c netif_issue_reports(...)
  399. // ref: esp-lwip/core/ipv4/etharp.c garp_tmr()
  400. // TODO: only for ipv4, need (?) a different method with ipv6
  401. bool _wifiSendGratuitousArp() {
  402. bool result = false;
  403. for (netif* interface = netif_list; interface != nullptr; interface = interface->next) {
  404. if (
  405. (interface->flags & NETIF_FLAG_ETHARP)
  406. && (interface->hwaddr_len == ETHARP_HWADDR_LEN)
  407. #if LWIP_VERSION_MAJOR == 1
  408. && (!ip_addr_isany(&interface->ip_addr))
  409. #else
  410. && (!ip4_addr_isany_val(*netif_ip4_addr(interface)))
  411. #endif
  412. && (interface->flags & NETIF_FLAG_LINK_UP)
  413. && (interface->flags & NETIF_FLAG_UP)
  414. ) {
  415. etharp_gratuitous(interface);
  416. result = true;
  417. }
  418. }
  419. return result;
  420. }
  421. void _wifiSendGratuitousArp(unsigned long interval) {
  422. if (millis() - _wifi_gratuitous_arp_last > interval) {
  423. _wifi_gratuitous_arp_last = millis();
  424. _wifiSendGratuitousArp();
  425. }
  426. }
  427. #endif // WIFI_GRATUITOUS_ARP_SUPPORT
  428. // -----------------------------------------------------------------------------
  429. // INFO
  430. // -----------------------------------------------------------------------------
  431. // backported WiFiAPClass methods
  432. String _wifiSoftAPSSID() {
  433. struct softap_config config;
  434. wifi_softap_get_config(&config);
  435. char* name = reinterpret_cast<char*>(config.ssid);
  436. char ssid[sizeof(config.ssid) + 1];
  437. memcpy(ssid, name, sizeof(config.ssid));
  438. ssid[sizeof(config.ssid)] = '\0';
  439. return String(ssid);
  440. }
  441. String _wifiSoftAPPSK() {
  442. struct softap_config config;
  443. wifi_softap_get_config(&config);
  444. char* pass = reinterpret_cast<char*>(config.password);
  445. char psk[sizeof(config.password) + 1];
  446. memcpy(psk, pass, sizeof(config.password));
  447. psk[sizeof(config.password)] = '\0';
  448. return String(psk);
  449. }
  450. void wifiDebug(WiFiMode_t modes) {
  451. #if DEBUG_SUPPORT
  452. bool footer = false;
  453. if (((modes & WIFI_STA) > 0) && ((WiFi.getMode() & WIFI_STA) > 0)) {
  454. DEBUG_MSG_P(PSTR("[WIFI] ------------------------------------- MODE STA\n"));
  455. DEBUG_MSG_P(PSTR("[WIFI] SSID %s\n"), WiFi.SSID().c_str());
  456. DEBUG_MSG_P(PSTR("[WIFI] IP %s\n"), WiFi.localIP().toString().c_str());
  457. DEBUG_MSG_P(PSTR("[WIFI] MAC %s\n"), WiFi.macAddress().c_str());
  458. DEBUG_MSG_P(PSTR("[WIFI] GW %s\n"), WiFi.gatewayIP().toString().c_str());
  459. DEBUG_MSG_P(PSTR("[WIFI] DNS %s\n"), WiFi.dnsIP().toString().c_str());
  460. DEBUG_MSG_P(PSTR("[WIFI] MASK %s\n"), WiFi.subnetMask().toString().c_str());
  461. DEBUG_MSG_P(PSTR("[WIFI] HOST http://%s.local\n"), WiFi.hostname().c_str());
  462. DEBUG_MSG_P(PSTR("[WIFI] BSSID %s\n"), WiFi.BSSIDstr().c_str());
  463. DEBUG_MSG_P(PSTR("[WIFI] CH %d\n"), WiFi.channel());
  464. DEBUG_MSG_P(PSTR("[WIFI] RSSI %d\n"), WiFi.RSSI());
  465. footer = true;
  466. }
  467. if (((modes & WIFI_AP) > 0) && ((WiFi.getMode() & WIFI_AP) > 0)) {
  468. DEBUG_MSG_P(PSTR("[WIFI] -------------------------------------- MODE AP\n"));
  469. DEBUG_MSG_P(PSTR("[WIFI] SSID %s\n"), _wifiSoftAPSSID().c_str());
  470. DEBUG_MSG_P(PSTR("[WIFI] PASS %s\n"), _wifiSoftAPPSK().c_str());
  471. DEBUG_MSG_P(PSTR("[WIFI] IP %s\n"), WiFi.softAPIP().toString().c_str());
  472. DEBUG_MSG_P(PSTR("[WIFI] MAC %s\n"), WiFi.softAPmacAddress().c_str());
  473. footer = true;
  474. }
  475. if (WiFi.getMode() == 0) {
  476. DEBUG_MSG_P(PSTR("[WIFI] ------------------------------------- MODE OFF\n"));
  477. DEBUG_MSG_P(PSTR("[WIFI] No connection\n"));
  478. footer = true;
  479. }
  480. if (footer) {
  481. DEBUG_MSG_P(PSTR("[WIFI] ----------------------------------------------\n"));
  482. }
  483. #endif //DEBUG_SUPPORT
  484. }
  485. void wifiDebug() {
  486. wifiDebug(WIFI_AP_STA);
  487. }
  488. // -----------------------------------------------------------------------------
  489. // API
  490. // -----------------------------------------------------------------------------
  491. String getIP() {
  492. if (WiFi.getMode() == WIFI_AP) {
  493. return WiFi.softAPIP().toString();
  494. }
  495. return WiFi.localIP().toString();
  496. }
  497. String getNetwork() {
  498. if (WiFi.getMode() == WIFI_AP) {
  499. return jw.getAPSSID();
  500. }
  501. return WiFi.SSID();
  502. }
  503. bool wifiConnected() {
  504. return jw.connected();
  505. }
  506. void wifiDisconnect() {
  507. jw.disconnect();
  508. }
  509. void wifiStartSTA() {
  510. jw.disconnect();
  511. jw.enableSTA(true);
  512. jw.enableAP(false);
  513. }
  514. void wifiStartAP(bool only) {
  515. if (only) {
  516. jw.enableSTA(false);
  517. jw.disconnect();
  518. jw.resetReconnectTimeout();
  519. }
  520. jw.enableAP(true);
  521. }
  522. void wifiStartAP() {
  523. wifiStartAP(true);
  524. }
  525. #if defined(JUSTWIFI_ENABLE_WPS)
  526. void wifiStartWPS() {
  527. jw.enableAP(false);
  528. jw.disconnect();
  529. jw.startWPS();
  530. }
  531. #endif // defined(JUSTWIFI_ENABLE_WPS)
  532. #if defined(JUSTWIFI_ENABLE_SMARTCONFIG)
  533. void wifiStartSmartConfig() {
  534. jw.enableAP(false);
  535. jw.disconnect();
  536. jw.startSmartConfig();
  537. }
  538. #endif // defined(JUSTWIFI_ENABLE_SMARTCONFIG)
  539. void wifiReconnectCheck() {
  540. bool connected = false;
  541. #if WEB_SUPPORT
  542. if (wsConnected()) connected = true;
  543. #endif
  544. #if TELNET_SUPPORT
  545. if (telnetConnected()) connected = true;
  546. #endif
  547. jw.enableSTA(true);
  548. jw.setReconnectTimeout(connected ? 0 : WIFI_RECONNECT_INTERVAL);
  549. }
  550. uint8_t wifiState() {
  551. uint8_t state = 0;
  552. if (jw.connected()) state += WIFI_STATE_STA;
  553. if (jw.connectable()) state += WIFI_STATE_AP;
  554. if (_wifi_wps_running) state += WIFI_STATE_WPS;
  555. if (_wifi_smartconfig_running) state += WIFI_STATE_SMARTCONFIG;
  556. return state;
  557. }
  558. void wifiRegister(wifi_callback_f callback) {
  559. jw.subscribe(callback);
  560. }
  561. // -----------------------------------------------------------------------------
  562. // INITIALIZATION
  563. // -----------------------------------------------------------------------------
  564. void wifiSetup() {
  565. _wifiInject();
  566. _wifiConfigure();
  567. #if JUSTWIFI_ENABLE_SMARTCONFIG
  568. if (_wifi_smartconfig_initial) jw.startSmartConfig();
  569. #endif
  570. // Message callbacks
  571. wifiRegister(_wifiCallback);
  572. #if WIFI_AP_CAPTIVE
  573. wifiRegister(_wifiCaptivePortal);
  574. #endif
  575. #if DEBUG_SUPPORT
  576. wifiRegister(_wifiDebugCallback);
  577. #endif
  578. #if WEB_SUPPORT
  579. wsRegister()
  580. .onAction(_wifiWebSocketOnAction)
  581. .onConnected(_wifiWebSocketOnConnected)
  582. .onKeyCheck(_wifiWebSocketOnKeyCheck);
  583. #endif
  584. #if TERMINAL_SUPPORT
  585. _wifiInitCommands();
  586. #endif
  587. // Main callbacks
  588. espurnaRegisterLoop(wifiLoop);
  589. espurnaRegisterReload(_wifiConfigure);
  590. }
  591. void wifiLoop() {
  592. // Main wifi loop
  593. jw.loop();
  594. // Process captrive portal DNS queries if in AP mode only
  595. #if WIFI_AP_CAPTIVE
  596. if ((WiFi.getMode() & WIFI_AP) == WIFI_AP) {
  597. _wifi_dnsServer.processNextRequest();
  598. }
  599. #endif
  600. // Only send out gra arp when in STA mode
  601. #if WIFI_GRATUITOUS_ARP_SUPPORT
  602. if (_wifi_gratuitous_arp_interval) {
  603. _wifiSendGratuitousArp(_wifi_gratuitous_arp_interval);
  604. }
  605. #endif
  606. // Check if we should disable AP
  607. static unsigned long last = 0;
  608. if (millis() - last > 60000) {
  609. last = millis();
  610. _wifiCheckAP();
  611. }
  612. }