blob: 5370ee71eab52977c69be8e67790b480c3401806 [file] [log] [blame]
Paul Sokolovskyb639ce22016-04-29 00:17:11 +03001/*
2 * This file is part of the MicroPython project, http://micropython.org/
3 *
4 * The MIT License (MIT)
5 *
6 * Copyright (c) 2013-2016 Damien P. George
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 */
26
27#include <stdio.h>
28
29#include "lib/utils/pyhelp.h"
30
31STATIC const char *help_text =
32"Welcome to MicroPython!\n"
33"\n"
34"For online docs please visit http://docs.micropython.org/en/latest/esp8266/ .\n"
Damien George496a6012016-05-03 15:54:57 +010035"For diagnostic information to include in bug reports execute 'import port_diag'.\n"
Paul Sokolovskyb639ce22016-04-29 00:17:11 +030036"\n"
Paul Sokolovsky22050a32016-04-29 00:34:08 +030037"Basic WiFi configuration:\n"
38"\n"
39"import network\n"
Paul Sokolovskyd60cb8e2016-05-10 23:21:32 +030040"sta_if = network.WLAN(network.STA_IF); sta_if.active(True)\n"
Damien George496a6012016-05-03 15:54:57 +010041"sta_if.scan() # Scan for available access points\n"
42"sta_if.connect(\"<AP_name>\", \"<password>\") # Connect to an AP\n"
43"sta_if.isconnected() # Check for successful connection\n"
Paul Sokolovsky22050a32016-04-29 00:34:08 +030044"# Change name/password of ESP8266's AP:\n"
45"ap_if = network.WLAN(network.AP_IF)\n"
46"ap_if.config(essid=\"<AP_NAME>\", authmode=network.AUTH_WPA_WPA2_PSK, password=\"<password>\")\n"
47"\n"
Paul Sokolovskyb639ce22016-04-29 00:17:11 +030048"Control commands:\n"
49" CTRL-A -- on a blank line, enter raw REPL mode\n"
50" CTRL-B -- on a blank line, enter normal REPL mode\n"
51" CTRL-C -- interrupt a running program\n"
52" CTRL-D -- on a blank line, do a soft reset of the board\n"
53" CTRL-E -- on a blank line, enter paste mode\n"
54"\n"
55"For further help on a specific object, type help(obj)\n"
56;
57
58STATIC mp_obj_t builtin_help(uint n_args, const mp_obj_t *args) {
59 if (n_args == 0) {
60 // print a general help message
61 printf("%s", help_text);
62
63 } else {
64 // try to print something sensible about the given object
65 pyhelp_print_obj(args[0]);
66 }
67
68 return mp_const_none;
69}
70MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_help_obj, 0, 1, builtin_help);