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.

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