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.

742 lines
20 KiB

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
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 "wifi.h"
  6. #include "wifi_config.h"
  7. #include "telnet.h"
  8. #include "ws.h"
  9. bool _wifi_wps_running = false;
  10. bool _wifi_smartconfig_running = false;
  11. bool _wifi_smartconfig_initial = false;
  12. int _wifi_ap_mode = WIFI_AP_FALLBACK;
  13. #if WIFI_GRATUITOUS_ARP_SUPPORT
  14. unsigned long _wifi_gratuitous_arp_interval = 0;
  15. unsigned long _wifi_gratuitous_arp_last = 0;
  16. #endif
  17. // -----------------------------------------------------------------------------
  18. // PRIVATE
  19. // -----------------------------------------------------------------------------
  20. struct wifi_scan_info_t {
  21. String ssid_scan;
  22. int32_t rssi_scan;
  23. uint8_t sec_scan;
  24. uint8_t* BSSID_scan;
  25. int32_t chan_scan;
  26. bool hidden_scan;
  27. char buffer[128];
  28. };
  29. using wifi_scan_f = std::function<void(wifi_scan_info_t& info)>;
  30. void _wifiUpdateSoftAP() {
  31. if (WiFi.softAPgetStationNum() == 0) {
  32. #if USE_PASSWORD
  33. jw.setSoftAP(getSetting("hostname").c_str(), getAdminPass().c_str());
  34. #else
  35. jw.setSoftAP(getSetting("hostname").c_str());
  36. #endif
  37. }
  38. }
  39. void _wifiCheckAP() {
  40. if (
  41. (WIFI_AP_FALLBACK == _wifi_ap_mode)
  42. && ((WiFi.getMode() & WIFI_AP) > 0)
  43. && jw.connected()
  44. && (WiFi.softAPgetStationNum() == 0)
  45. ) {
  46. jw.enableAP(false);
  47. }
  48. }
  49. WiFiSleepType_t _wifiSleepModeConvert(const String& value) {
  50. switch (value.toInt()) {
  51. case 2:
  52. return WIFI_MODEM_SLEEP;
  53. case 1:
  54. return WIFI_LIGHT_SLEEP;
  55. case 0:
  56. default:
  57. return WIFI_NONE_SLEEP;
  58. }
  59. }
  60. void _wifiConfigure() {
  61. jw.setHostname(getSetting("hostname").c_str());
  62. _wifiUpdateSoftAP();
  63. jw.setConnectTimeout(WIFI_CONNECT_TIMEOUT);
  64. wifiReconnectCheck();
  65. jw.enableAPFallback(WIFI_FALLBACK_APMODE);
  66. jw.cleanNetworks();
  67. _wifi_ap_mode = getSetting("apmode", WIFI_AP_FALLBACK);
  68. // If system is flagged unstable we do not init wifi networks
  69. #if SYSTEM_CHECK_ENABLED
  70. if (!systemCheck()) return;
  71. #endif
  72. unsigned char index = 0;
  73. for (index = 0; index < WIFI_MAX_NETWORKS; index++) {
  74. const auto ssid = getSetting({"ssid", index}, _wifiSSID(index));
  75. const auto pass = getSetting({"pass", index}, _wifiPass(index));
  76. if (!ssid.length()) {
  77. auto current = index;
  78. do {
  79. delSetting({"ssid", index});
  80. delSetting({"pass", index});
  81. delSetting({"ip", index});
  82. delSetting({"gw", index});
  83. delSetting({"mask", index});
  84. delSetting({"dns", index});
  85. } while (++index < WIFI_MAX_NETWORKS);
  86. index = current;
  87. break;
  88. }
  89. bool result = false;
  90. if (ssid.length() && pass.length()) {
  91. result = jw.addNetwork(
  92. ssid.c_str(),
  93. pass.c_str(),
  94. getSetting({"ip", index}, _wifiIP(index)).c_str(),
  95. getSetting({"gw", index}, _wifiGateway(index)).c_str(),
  96. getSetting({"mask", index}, _wifiNetmask(index)).c_str(),
  97. getSetting({"dns", index}, _wifiDNS(index)).c_str()
  98. );
  99. } else if (ssid.length()) {
  100. result = jw.addNetwork(ssid.c_str(), pass.c_str());
  101. }
  102. if (!result) break;
  103. }
  104. #if JUSTWIFI_ENABLE_SMARTCONFIG
  105. if (index == 0) _wifi_smartconfig_initial = true;
  106. #endif
  107. jw.enableScan(getSetting("wifiScan", 1 == WIFI_SCAN_NETWORKS));
  108. const auto sleep_mode = getSetting<WiFiSleepType_t, _wifiSleepModeConvert>("wifiSleep", WIFI_SLEEP_MODE);
  109. WiFi.setSleepMode(sleep_mode);
  110. #if WIFI_GRATUITOUS_ARP_SUPPORT
  111. _wifi_gratuitous_arp_last = millis();
  112. _wifi_gratuitous_arp_interval = getSetting("wifiGarpIntvl", secureRandom(
  113. WIFI_GRATUITOUS_ARP_INTERVAL_MIN, WIFI_GRATUITOUS_ARP_INTERVAL_MAX
  114. ));
  115. #endif
  116. const auto tx_power = getSetting("wifiTxPwr", WIFI_OUTPUT_POWER_DBM);
  117. WiFi.setOutputPower(tx_power);
  118. }
  119. void _wifiScan(wifi_scan_f callback = nullptr) {
  120. DEBUG_MSG_P(PSTR("[WIFI] Start scanning\n"));
  121. unsigned char result = WiFi.scanNetworks();
  122. if (result == WIFI_SCAN_FAILED) {
  123. DEBUG_MSG_P(PSTR("[WIFI] Scan failed\n"));
  124. return;
  125. } else if (result == 0) {
  126. DEBUG_MSG_P(PSTR("[WIFI] No networks found\n"));
  127. return;
  128. }
  129. DEBUG_MSG_P(PSTR("[WIFI] %d networks found:\n"), result);
  130. // Populate defined networks with scan data
  131. wifi_scan_info_t info;
  132. for (unsigned char i = 0; i < result; ++i) {
  133. WiFi.getNetworkInfo(i, info.ssid_scan, info.sec_scan, info.rssi_scan, info.BSSID_scan, info.chan_scan, info.hidden_scan);
  134. snprintf_P(info.buffer, sizeof(info.buffer),
  135. PSTR("BSSID: %02X:%02X:%02X:%02X:%02X:%02X SEC: %s RSSI: %3d CH: %2d SSID: %s"),
  136. info.BSSID_scan[0], info.BSSID_scan[1], info.BSSID_scan[2], info.BSSID_scan[3], info.BSSID_scan[4], info.BSSID_scan[5],
  137. (info.sec_scan != ENC_TYPE_NONE ? "YES" : "NO "),
  138. info.rssi_scan,
  139. info.chan_scan,
  140. info.ssid_scan.c_str()
  141. );
  142. if (callback) {
  143. callback(info);
  144. } else {
  145. DEBUG_MSG_P(PSTR("[WIFI] > %s\n"), info.buffer);
  146. }
  147. }
  148. WiFi.scanDelete();
  149. }
  150. void _wifiCallback(justwifi_messages_t code, char * parameter) {
  151. if (MESSAGE_WPS_START == code) {
  152. _wifi_wps_running = true;
  153. return;
  154. }
  155. if (MESSAGE_SMARTCONFIG_START == code) {
  156. _wifi_smartconfig_running = true;
  157. return;
  158. }
  159. if (MESSAGE_WPS_ERROR == code || MESSAGE_SMARTCONFIG_ERROR == code) {
  160. _wifi_wps_running = false;
  161. _wifi_smartconfig_running = false;
  162. return;
  163. }
  164. if (MESSAGE_WPS_SUCCESS == code || MESSAGE_SMARTCONFIG_SUCCESS == code) {
  165. _wifi_wps_running = false;
  166. _wifi_smartconfig_running = false;
  167. const String current_ssid = WiFi.SSID();
  168. const String current_pass = WiFi.psk();
  169. // Write current ssid & pass at the end of the networks list
  170. unsigned char count;
  171. for (count = 0; count < WIFI_MAX_NETWORKS; count++) {
  172. const auto ssid = getSetting({"ssid", count}, _wifiSSID(count));
  173. const auto pass = getSetting({"pass", count}, _wifiPass(count));
  174. // Ignore existing network settings
  175. if (current_ssid.equals(ssid) && current_pass.equals(pass)) {
  176. return;
  177. }
  178. if (current_ssid.equals(ssid)) break;
  179. if (!ssid.length()) break;
  180. }
  181. // If we have reached the max we overwrite the first one
  182. if (WIFI_MAX_NETWORKS == count) count = 0;
  183. setSetting({"ssid", count}, current_ssid);
  184. setSetting({"pass", count}, current_pass);
  185. return;
  186. }
  187. }
  188. #if WIFI_AP_CAPTIVE
  189. #include "DNSServer.h"
  190. DNSServer _wifi_dnsServer;
  191. void _wifiCaptivePortal(justwifi_messages_t code, char * parameter) {
  192. if (MESSAGE_ACCESSPOINT_CREATED == code) {
  193. _wifi_dnsServer.setErrorReplyCode(DNSReplyCode::NoError);
  194. _wifi_dnsServer.start(53, "*", WiFi.softAPIP());
  195. DEBUG_MSG_P(PSTR("[WIFI] Captive portal enabled\n"));
  196. }
  197. if (MESSAGE_CONNECTED == code) {
  198. _wifi_dnsServer.stop();
  199. DEBUG_MSG_P(PSTR("[WIFI] Captive portal disabled\n"));
  200. }
  201. }
  202. #endif // WIFI_AP_CAPTIVE
  203. #if DEBUG_SUPPORT
  204. void _wifiDebugCallback(justwifi_messages_t code, char * parameter) {
  205. // -------------------------------------------------------------------------
  206. if (code == MESSAGE_SCANNING) {
  207. DEBUG_MSG_P(PSTR("[WIFI] Scanning\n"));
  208. }
  209. if (code == MESSAGE_SCAN_FAILED) {
  210. DEBUG_MSG_P(PSTR("[WIFI] Scan failed\n"));
  211. }
  212. if (code == MESSAGE_NO_NETWORKS) {
  213. DEBUG_MSG_P(PSTR("[WIFI] No networks found\n"));
  214. }
  215. if (code == MESSAGE_NO_KNOWN_NETWORKS) {
  216. DEBUG_MSG_P(PSTR("[WIFI] No known networks found\n"));
  217. }
  218. if (code == MESSAGE_FOUND_NETWORK) {
  219. DEBUG_MSG_P(PSTR("[WIFI] %s\n"), parameter);
  220. }
  221. // -------------------------------------------------------------------------
  222. if (code == MESSAGE_CONNECTING) {
  223. DEBUG_MSG_P(PSTR("[WIFI] Connecting to %s\n"), parameter);
  224. }
  225. if (code == MESSAGE_CONNECT_WAITING) {
  226. // too much noise
  227. }
  228. if (code == MESSAGE_CONNECT_FAILED) {
  229. DEBUG_MSG_P(PSTR("[WIFI] Could not connect to %s\n"), parameter);
  230. }
  231. if (code == MESSAGE_CONNECTED) {
  232. wifiDebug(WIFI_STA);
  233. }
  234. if (code == MESSAGE_DISCONNECTED) {
  235. DEBUG_MSG_P(PSTR("[WIFI] Disconnected\n"));
  236. }
  237. // -------------------------------------------------------------------------
  238. if (code == MESSAGE_ACCESSPOINT_CREATING) {
  239. DEBUG_MSG_P(PSTR("[WIFI] Creating access point\n"));
  240. }
  241. if (code == MESSAGE_ACCESSPOINT_CREATED) {
  242. wifiDebug(WIFI_AP);
  243. }
  244. if (code == MESSAGE_ACCESSPOINT_FAILED) {
  245. DEBUG_MSG_P(PSTR("[WIFI] Could not create access point\n"));
  246. }
  247. if (code == MESSAGE_ACCESSPOINT_DESTROYED) {
  248. _wifiUpdateSoftAP();
  249. DEBUG_MSG_P(PSTR("[WIFI] Access point destroyed\n"));
  250. }
  251. // -------------------------------------------------------------------------
  252. if (code == MESSAGE_WPS_START) {
  253. DEBUG_MSG_P(PSTR("[WIFI] WPS started\n"));
  254. }
  255. if (code == MESSAGE_WPS_SUCCESS) {
  256. DEBUG_MSG_P(PSTR("[WIFI] WPS succeded!\n"));
  257. }
  258. if (code == MESSAGE_WPS_ERROR) {
  259. DEBUG_MSG_P(PSTR("[WIFI] WPS failed\n"));
  260. }
  261. // ------------------------------------------------------------------------
  262. if (code == MESSAGE_SMARTCONFIG_START) {
  263. DEBUG_MSG_P(PSTR("[WIFI] Smart Config started\n"));
  264. }
  265. if (code == MESSAGE_SMARTCONFIG_SUCCESS) {
  266. DEBUG_MSG_P(PSTR("[WIFI] Smart Config succeded!\n"));
  267. }
  268. if (code == MESSAGE_SMARTCONFIG_ERROR) {
  269. DEBUG_MSG_P(PSTR("[WIFI] Smart Config failed\n"));
  270. }
  271. }
  272. #endif // DEBUG_SUPPORT
  273. // -----------------------------------------------------------------------------
  274. // SETTINGS
  275. // -----------------------------------------------------------------------------
  276. #if TERMINAL_SUPPORT
  277. void _wifiInitCommands() {
  278. terminalRegisterCommand(F("WIFI"), [](Embedis* e) {
  279. wifiDebug();
  280. terminalOK();
  281. });
  282. terminalRegisterCommand(F("WIFI.RESET"), [](Embedis* e) {
  283. _wifiConfigure();
  284. wifiDisconnect();
  285. terminalOK();
  286. });
  287. terminalRegisterCommand(F("WIFI.STA"), [](Embedis* e) {
  288. wifiStartSTA();
  289. terminalOK();
  290. });
  291. terminalRegisterCommand(F("WIFI.AP"), [](Embedis* e) {
  292. wifiStartAP();
  293. terminalOK();
  294. });
  295. #if defined(JUSTWIFI_ENABLE_WPS)
  296. terminalRegisterCommand(F("WIFI.WPS"), [](Embedis* e) {
  297. wifiStartWPS();
  298. terminalOK();
  299. });
  300. #endif // defined(JUSTWIFI_ENABLE_WPS)
  301. #if defined(JUSTWIFI_ENABLE_SMARTCONFIG)
  302. terminalRegisterCommand(F("WIFI.SMARTCONFIG"), [](Embedis* e) {
  303. wifiStartSmartConfig();
  304. terminalOK();
  305. });
  306. #endif // defined(JUSTWIFI_ENABLE_SMARTCONFIG)
  307. terminalRegisterCommand(F("WIFI.SCAN"), [](Embedis* e) {
  308. _wifiScan();
  309. terminalOK();
  310. });
  311. }
  312. #endif
  313. // -----------------------------------------------------------------------------
  314. // WEB
  315. // -----------------------------------------------------------------------------
  316. #if WEB_SUPPORT
  317. bool _wifiWebSocketOnKeyCheck(const char * key, JsonVariant& value) {
  318. if (strncmp(key, "wifi", 4) == 0) return true;
  319. if (strncmp(key, "ssid", 4) == 0) return true;
  320. if (strncmp(key, "pass", 4) == 0) return true;
  321. if (strncmp(key, "ip", 2) == 0) return true;
  322. if (strncmp(key, "gw", 2) == 0) return true;
  323. if (strncmp(key, "mask", 4) == 0) return true;
  324. if (strncmp(key, "dns", 3) == 0) return true;
  325. return false;
  326. }
  327. void _wifiWebSocketOnConnected(JsonObject& root) {
  328. root["wifiScan"] = getSetting("wifiScan", 1 == WIFI_SCAN_NETWORKS);
  329. JsonObject& wifi = root.createNestedObject("wifi");
  330. root["max"] = WIFI_MAX_NETWORKS;
  331. const char* keys[] = {
  332. "ssid", "pass", "ip", "gw", "mask", "dns", "stored"
  333. };
  334. JsonArray& schema = wifi.createNestedArray("schema");
  335. schema.copyFrom(keys, 7);
  336. JsonArray& networks = wifi.createNestedArray("networks");
  337. for (unsigned char index = 0; index < WIFI_MAX_NETWORKS; ++index) {
  338. if (!getSetting({"ssid", index}, _wifiSSID(index)).length()) break;
  339. JsonArray& network = networks.createNestedArray();
  340. network.add(getSetting({"ssid", index}, _wifiSSID(index)));
  341. network.add(getSetting({"pass", index}, _wifiPass(index)));
  342. network.add(getSetting({"ip", index}, _wifiIP(index)));
  343. network.add(getSetting({"gw", index}, _wifiGateway(index)));
  344. network.add(getSetting({"mask", index}, _wifiNetmask(index)));
  345. network.add(getSetting({"dns", index}, _wifiDNS(index)));
  346. network.add(_wifiHasSSID(index));
  347. }
  348. }
  349. void _wifiWebSocketScan(JsonObject& root) {
  350. JsonArray& scanResult = root.createNestedArray("scanResult");
  351. _wifiScan([&scanResult](wifi_scan_info_t& info) {
  352. scanResult.add(info.buffer);
  353. });
  354. }
  355. void _wifiWebSocketOnAction(uint32_t client_id, const char * action, JsonObject& data) {
  356. if (strcmp(action, "scan") == 0) wsPost(client_id, _wifiWebSocketScan);
  357. }
  358. #endif
  359. // -----------------------------------------------------------------------------
  360. // SUPPORT
  361. // -----------------------------------------------------------------------------
  362. #if WIFI_GRATUITOUS_ARP_SUPPORT
  363. // ref: lwip src/core/netif.c netif_issue_reports(...)
  364. // ref: esp-lwip/core/ipv4/etharp.c garp_tmr()
  365. // TODO: only for ipv4, need (?) a different method with ipv6
  366. bool _wifiSendGratuitousArp() {
  367. bool result = false;
  368. for (netif* interface = netif_list; interface != nullptr; interface = interface->next) {
  369. if (
  370. (interface->flags & NETIF_FLAG_ETHARP)
  371. && (interface->hwaddr_len == ETHARP_HWADDR_LEN)
  372. #if LWIP_VERSION_MAJOR == 1
  373. && (!ip_addr_isany(&interface->ip_addr))
  374. #else
  375. && (!ip4_addr_isany_val(*netif_ip4_addr(interface)))
  376. #endif
  377. && (interface->flags & NETIF_FLAG_LINK_UP)
  378. && (interface->flags & NETIF_FLAG_UP)
  379. ) {
  380. etharp_gratuitous(interface);
  381. result = true;
  382. }
  383. }
  384. return result;
  385. }
  386. void _wifiSendGratuitousArp(unsigned long interval) {
  387. if (millis() - _wifi_gratuitous_arp_last > interval) {
  388. _wifi_gratuitous_arp_last = millis();
  389. _wifiSendGratuitousArp();
  390. }
  391. }
  392. #endif // WIFI_GRATUITOUS_ARP_SUPPORT
  393. // -----------------------------------------------------------------------------
  394. // INFO
  395. // -----------------------------------------------------------------------------
  396. // backported WiFiAPClass methods
  397. String _wifiSoftAPSSID() {
  398. struct softap_config config;
  399. wifi_softap_get_config(&config);
  400. char* name = reinterpret_cast<char*>(config.ssid);
  401. char ssid[sizeof(config.ssid) + 1];
  402. memcpy(ssid, name, sizeof(config.ssid));
  403. ssid[sizeof(config.ssid)] = '\0';
  404. return String(ssid);
  405. }
  406. String _wifiSoftAPPSK() {
  407. struct softap_config config;
  408. wifi_softap_get_config(&config);
  409. char* pass = reinterpret_cast<char*>(config.password);
  410. char psk[sizeof(config.password) + 1];
  411. memcpy(psk, pass, sizeof(config.password));
  412. psk[sizeof(config.password)] = '\0';
  413. return String(psk);
  414. }
  415. void wifiDebug(WiFiMode_t modes) {
  416. #if DEBUG_SUPPORT
  417. bool footer = false;
  418. if (((modes & WIFI_STA) > 0) && ((WiFi.getMode() & WIFI_STA) > 0)) {
  419. DEBUG_MSG_P(PSTR("[WIFI] ------------------------------------- MODE STA\n"));
  420. DEBUG_MSG_P(PSTR("[WIFI] SSID %s\n"), WiFi.SSID().c_str());
  421. DEBUG_MSG_P(PSTR("[WIFI] IP %s\n"), WiFi.localIP().toString().c_str());
  422. DEBUG_MSG_P(PSTR("[WIFI] MAC %s\n"), WiFi.macAddress().c_str());
  423. DEBUG_MSG_P(PSTR("[WIFI] GW %s\n"), WiFi.gatewayIP().toString().c_str());
  424. DEBUG_MSG_P(PSTR("[WIFI] DNS %s\n"), WiFi.dnsIP().toString().c_str());
  425. DEBUG_MSG_P(PSTR("[WIFI] MASK %s\n"), WiFi.subnetMask().toString().c_str());
  426. DEBUG_MSG_P(PSTR("[WIFI] HOST http://%s.local\n"), WiFi.hostname().c_str());
  427. DEBUG_MSG_P(PSTR("[WIFI] BSSID %s\n"), WiFi.BSSIDstr().c_str());
  428. DEBUG_MSG_P(PSTR("[WIFI] CH %d\n"), WiFi.channel());
  429. DEBUG_MSG_P(PSTR("[WIFI] RSSI %d\n"), WiFi.RSSI());
  430. footer = true;
  431. }
  432. if (((modes & WIFI_AP) > 0) && ((WiFi.getMode() & WIFI_AP) > 0)) {
  433. DEBUG_MSG_P(PSTR("[WIFI] -------------------------------------- MODE AP\n"));
  434. DEBUG_MSG_P(PSTR("[WIFI] SSID %s\n"), _wifiSoftAPSSID().c_str());
  435. DEBUG_MSG_P(PSTR("[WIFI] PASS %s\n"), _wifiSoftAPPSK().c_str());
  436. DEBUG_MSG_P(PSTR("[WIFI] IP %s\n"), WiFi.softAPIP().toString().c_str());
  437. DEBUG_MSG_P(PSTR("[WIFI] MAC %s\n"), WiFi.softAPmacAddress().c_str());
  438. footer = true;
  439. }
  440. if (WiFi.getMode() == 0) {
  441. DEBUG_MSG_P(PSTR("[WIFI] ------------------------------------- MODE OFF\n"));
  442. DEBUG_MSG_P(PSTR("[WIFI] No connection\n"));
  443. footer = true;
  444. }
  445. if (footer) {
  446. DEBUG_MSG_P(PSTR("[WIFI] ----------------------------------------------\n"));
  447. }
  448. #endif //DEBUG_SUPPORT
  449. }
  450. void wifiDebug() {
  451. wifiDebug(WIFI_AP_STA);
  452. }
  453. // -----------------------------------------------------------------------------
  454. // API
  455. // -----------------------------------------------------------------------------
  456. String getIP() {
  457. if (WiFi.getMode() == WIFI_AP) {
  458. return WiFi.softAPIP().toString();
  459. }
  460. return WiFi.localIP().toString();
  461. }
  462. String getNetwork() {
  463. if (WiFi.getMode() == WIFI_AP) {
  464. return jw.getAPSSID();
  465. }
  466. return WiFi.SSID();
  467. }
  468. bool wifiConnected() {
  469. return jw.connected();
  470. }
  471. void wifiDisconnect() {
  472. jw.disconnect();
  473. }
  474. void wifiStartSTA() {
  475. jw.disconnect();
  476. jw.enableSTA(true);
  477. jw.enableAP(false);
  478. }
  479. void wifiStartAP(bool only) {
  480. if (only) {
  481. jw.enableSTA(false);
  482. jw.disconnect();
  483. jw.resetReconnectTimeout();
  484. }
  485. jw.enableAP(true);
  486. }
  487. void wifiStartAP() {
  488. wifiStartAP(true);
  489. }
  490. #if defined(JUSTWIFI_ENABLE_WPS)
  491. void wifiStartWPS() {
  492. jw.enableAP(false);
  493. jw.disconnect();
  494. jw.startWPS();
  495. }
  496. #endif // defined(JUSTWIFI_ENABLE_WPS)
  497. #if defined(JUSTWIFI_ENABLE_SMARTCONFIG)
  498. void wifiStartSmartConfig() {
  499. jw.enableAP(false);
  500. jw.disconnect();
  501. jw.startSmartConfig();
  502. }
  503. #endif // defined(JUSTWIFI_ENABLE_SMARTCONFIG)
  504. void wifiReconnectCheck() {
  505. bool connected = false;
  506. #if WEB_SUPPORT
  507. if (wsConnected()) connected = true;
  508. #endif
  509. #if TELNET_SUPPORT
  510. if (telnetConnected()) connected = true;
  511. #endif
  512. jw.enableSTA(true);
  513. jw.setReconnectTimeout(connected ? 0 : WIFI_RECONNECT_INTERVAL);
  514. }
  515. uint8_t wifiState() {
  516. uint8_t state = 0;
  517. if (jw.connected()) state += WIFI_STATE_STA;
  518. if (jw.connectable()) state += WIFI_STATE_AP;
  519. if (_wifi_wps_running) state += WIFI_STATE_WPS;
  520. if (_wifi_smartconfig_running) state += WIFI_STATE_SMARTCONFIG;
  521. return state;
  522. }
  523. void wifiRegister(wifi_callback_f callback) {
  524. jw.subscribe(callback);
  525. }
  526. // -----------------------------------------------------------------------------
  527. // INITIALIZATION
  528. // -----------------------------------------------------------------------------
  529. void wifiSetup() {
  530. _wifiConfigure();
  531. #if JUSTWIFI_ENABLE_SMARTCONFIG
  532. if (_wifi_smartconfig_initial) jw.startSmartConfig();
  533. #endif
  534. // Message callbacks
  535. wifiRegister(_wifiCallback);
  536. #if WIFI_AP_CAPTIVE
  537. wifiRegister(_wifiCaptivePortal);
  538. #endif
  539. #if DEBUG_SUPPORT
  540. wifiRegister(_wifiDebugCallback);
  541. #endif
  542. #if WEB_SUPPORT
  543. wsRegister()
  544. .onAction(_wifiWebSocketOnAction)
  545. .onConnected(_wifiWebSocketOnConnected)
  546. .onKeyCheck(_wifiWebSocketOnKeyCheck);
  547. #endif
  548. #if TERMINAL_SUPPORT
  549. _wifiInitCommands();
  550. #endif
  551. // Main callbacks
  552. espurnaRegisterLoop(wifiLoop);
  553. espurnaRegisterReload(_wifiConfigure);
  554. }
  555. void wifiLoop() {
  556. // Main wifi loop
  557. jw.loop();
  558. // Process captrive portal DNS queries if in AP mode only
  559. #if WIFI_AP_CAPTIVE
  560. if ((WiFi.getMode() & WIFI_AP) == WIFI_AP) {
  561. _wifi_dnsServer.processNextRequest();
  562. }
  563. #endif
  564. // Only send out gra arp when in STA mode
  565. #if WIFI_GRATUITOUS_ARP_SUPPORT
  566. if (_wifi_gratuitous_arp_interval) {
  567. _wifiSendGratuitousArp(_wifi_gratuitous_arp_interval);
  568. }
  569. #endif
  570. // Check if we should disable AP
  571. static unsigned long last = 0;
  572. if (millis() - last > 60000) {
  573. last = millis();
  574. _wifiCheckAP();
  575. }
  576. }