Theoretical maximum deep sleep duration can be found with [`node.dsleepMax()`](#nodedsleepmax). ["Max deep sleep for ESP8266"](https://thingpulse.com/max-deep-sleep-for-esp8266/) claims the realistic maximum be around 3.5h.
!!! caution
This function can only be used in the condition that esp8266 PIN32(RST) and PIN8(XPD_DCDC aka GPIO16) are connected together. Using sleep(0) will set no wake up timer, connect a GPIO to pin RST, the chip will wake up by a falling-edge on pin RST.
...
...
@@ -147,7 +147,7 @@ Returns the current theoretical maximum deep sleep duration.
<!--- timed light_sleep currently does not work, the 'duration' parameter is here as a place holder--->
<!--- timed light_sleep currently does not work, the 'duration' parameter is here as a place holder--->
<!--- * `duration` Sleep duration in microseconds(μs). If a sleep duration of `0` is specified, suspension will be indefinite (Range: 0 or 50000 - 268435454 μs (0:4:28.000454))--->
*`wake_pin` 1-12, pin to attach wake interrupt to. Note that pin 0(GPIO 16) does not support interrupts.
*`wake_pin` 1-12, pin to attach wake interrupt to. Note that pin 0(GPIO 16) does not support interrupts.
<!---* If sleep duration is indefinite, `wake_pin` must be specified--->
* Please refer to the [`GPIO module`](gpio.md) for more info on the pin map.
*`int_type` type of interrupt that you would like to wake on. (Optional, Default: `node.INT_LOW`)
...
...
@@ -437,7 +437,7 @@ Put NodeMCU in light sleep mode to reduce current consumption.
*`node.INT_LOW` Low level
*`node.INT_HIGH` High level
*`resume_cb` Callback to execute when WiFi wakes from suspension. (Optional)
*`preserve_mode` preserve current WiFi mode through node sleep. (Optional, Default: true)
*`preserve_mode` preserve current WiFi mode through node sleep. (Optional, Default: true)
* If true, Station and StationAP modes will automatically reconnect to previously configured Access Point when NodeMCU resumes.
* If false, discard WiFi mode and leave NodeMCU in `wifi.NULL_MODE`. WiFi mode will be restored to original mode on restart.
...
...
@@ -529,10 +529,10 @@ node.osprint(true)
## node.random()
This behaves like math.random except that it uses true random numbers derived from the ESP8266 hardware. It returns uniformly distributed
numbers in the required range. It also takes care to get large ranges correct.
numbers in the required range. It also takes care to get large ranges correct.
It can be called in three ways. Without arguments in the floating point build of NodeMCU, it returns a random real number with uniform distribution in the interval [0,1).
When called with only one argument, an integer n, it returns an integer random number x such that 1 <= x <= n. For instance, you can simulate the result of a die with random(6).
It can be called in three ways. Without arguments in the floating point build of NodeMCU, it returns a random real number with uniform distribution in the interval [0,1).
When called with only one argument, an integer n, it returns an integer random number x such that 1 <= x <= n. For instance, you can simulate the result of a die with random(6).
Finally, random can be called with two integer arguments, l and u, to get a pseudo-random integer x such that l <= x <= u.
#### Syntax
...
...
@@ -566,11 +566,11 @@ provides more detailed information on the EGC.
#### Parameters
-`mode`
-`node.egc.NOT_ACTIVE` EGC inactive, no collection cycle will be forced in low memory situations
-`node.egc.ON_ALLOC_FAILURE` Try to allocate a new block of memory, and run the garbage collector if the allocation fails. If the allocation fails even after running the garbage collector, the allocator will return with error.
-`node.egc.ON_ALLOC_FAILURE` Try to allocate a new block of memory, and run the garbage collector if the allocation fails. If the allocation fails even after running the garbage collector, the allocator will return with error.
-`node.egc.ON_MEM_LIMIT` Run the garbage collector when the memory used by the Lua script goes beyond an upper `limit`. If the upper limit can't be satisfied even after running the garbage collector, the allocator will return with error. If the given limit is negative, it is interpreted as the desired amount of heap which should be left available. Whenever the free heap (as reported by `node.heap()` falls below the requested limit, the garbage collector will be run.
-`node.egc.ALWAYS` Run the garbage collector before each memory allocation. If the allocation fails even after running the garbage collector, the allocator will return with error. This mode is very efficient with regards to memory savings, but it's also the slowest.
-`level` in the case of `node.egc.ON_MEM_LIMIT`, this specifies the memory limit.
#### Returns
`nil`
...
...
@@ -600,11 +600,11 @@ None.
## node.task.post()
Enable a Lua callback or task to post another task request. Note that as per the
example multiple tasks can be posted in any task, but the highest priority is
Enable a Lua callback or task to post another task request. Note that as per the
example multiple tasks can be posted in any task, but the highest priority is
always delivered first.
If the task queue is full then a queue full error is raised.
If the task queue is full then a queue full error is raised.
####Syntax
`node.task.post([task_priority], function)`
...
...
@@ -614,7 +614,7 @@ If the task queue is full then a queue full error is raised.
-`node.task.LOW_PRIORITY` = 0
-`node.task.MEDIUM_PRIORITY` = 1
-`node.task.HIGH_PRIORITY` = 2
-`function` a callback function to be executed when the task is run.
-`function` a callback function to be executed when the task is run.
If the priority is omitted then this defaults to `node.task.MEDIUM_PRIORITY`
...
...
@@ -623,12 +623,12 @@ If the priority is omitted then this defaults to `node.task.MEDIUM_PRIORITY`
@@ -8,7 +8,7 @@ This module provides simple performance measurement for an application. It sampl
of memory to store the histogram, the user can specify which area of code is of interest. The default is the entire flash which contains code. Once the hotspots are identified, then the run can then be repeated with different areas and at different resolutions to get as much information as required.
## perf.start()
Starts a performance monitoring session.
Starts a performance monitoring session.
#### Syntax
`perf.start([start[, end[, nbins]]])`
...
...
@@ -16,7 +16,7 @@ Starts a performance monitoring session.
#### Parameters
-`start` (optional) The lowest PC address for the histogram. Default is 0x40000000.
-`end` (optional) The highest address for the histogram. Default is the end of the used space in the flash memory.
-`nbins` (optional) The number of bins in the histogram. Keep this reasonable otherwise
-`nbins` (optional) The number of bins in the histogram. Keep this reasonable otherwise
you will run out of memory. Default is 1024.
Note that the number of bins is an upper limit. The size of each bin is set to be the smallest power of two
...
...
@@ -60,4 +60,4 @@ Terminates a performance monitoring session and returns the histogram.
This runs a loop creating strings 100 times and then prints out the histogram (after sorting it).
This takes around 2,500 samples and provides a good indication of where all the CPU time is
This module can read the state of cheap rotary encoder switches. These are available at all the standard places for a dollar or two. They are five pin devices where three are used for a gray code encoder for rotation, and two are used for the push switch. These switches are commonly used in car audio systems.
This module can read the state of cheap rotary encoder switches. These are available at all the standard places for a dollar or two. They are five pin devices where three are used for a gray code encoder for rotation, and two are used for the push switch. These switches are commonly used in car audio systems.
These switches do not have absolute positioning, but only encode the number of positions rotated clockwise / anti-clockwise. To make use of this module, connect the common pin on the quadrature encoder to ground and the A and B phases to the NodeMCU. One pin of the push switch should also be grounded and the other pin connected to the NodeMCU.
...
...
@@ -15,8 +15,8 @@ These switches do not have absolute positioning, but only encode the number of p
- Aliexpress: This [search](http://www.aliexpress.com/wholesale?catId=0&initiative_id=SB_20160217173657&SearchText=rotary+encoder+push+button) reveals all sorts of shapes and sizes.
There is also a switch mounted on a board with standard 0.1" pins.
This is the KY-040, and can also be found at [lots of places](https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=ky-040%20rotary%20encoder).
There is also a switch mounted on a board with standard 0.1" pins.
This is the KY-040, and can also be found at [lots of places](https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=ky-040%20rotary%20encoder).
Note that the pins are named somewhat eccentrically, and I suspect that it really does need the VCC connected.
## Constants
...
...
@@ -60,12 +60,12 @@ Sets a callback on specific events.
#### Parameters
-`channel` The rotary module supports three switches. The channel is either 0, 1 or 2.
-`eventtype` This defines the type of event being registered. This is the logical or of one or more of `PRESS`, `LONGPRESS`, `RELEASE`, `TURN`, `CLICK` or `DBLCLICK`.
-`callback` This is a function that will be invoked when the specified event happens.
-`callback` This is a function that will be invoked when the specified event happens.
If the callback is None or omitted, then the registration is cancelled.
The callback will be invoked with three arguments when the event happens. The first argument is the eventtype,
the second is the current position of the rotary switch, and the third is the time when the event happened.
The callback will be invoked with three arguments when the event happens. The first argument is the eventtype,
the second is the current position of the rotary switch, and the third is the time when the event happened.
The position is tracked
and is represented as a signed 32-bit integer. Increasing values indicate clockwise motion. The time is the number of microseconds represented
...
...
@@ -73,14 +73,14 @@ in a 32-bit integer. Note that this wraps every hour or so.
#### Example
rotary.on(0, rotary.ALL, function (type, pos, when)
rotary.on(0, rotary.ALL, function (type, pos, when)
print "Position=" .. pos .. " event type=" .. type .. " time=" .. when
end)
#### Notes
Events will be delivered in order, but there may be missing TURN events. If there is a long
queue of events, then PRESS and RELEASE events may also be missed. Multiple pending TURN events
Events will be delivered in order, but there may be missing TURN events. If there is a long
queue of events, then PRESS and RELEASE events may also be missed. Multiple pending TURN events
are typically dispatched as one TURN callback with the final position as its parameter.
Some switches have 4 steps per detent. This means that, in practice, the application
The rtctime module provides advanced timekeeping support for NodeMCU, including keeping time across deep sleep cycles (provided [`rtctime.dsleep()`](#rtctimedsleep) is used instead of [`node.dsleep()`](node.md#nodedsleep)). This can be used to significantly extend battery life on battery powered sensor nodes, as it is no longer necessary to fire up the RF module each wake-up in order to obtain an accurate timestamp.
This module is intended for use together with [NTP](https://en.wikipedia.org/wiki/Network_Time_Protocol)(Network Time Protocol) for keeping highly accurate real time at all times. Timestamps are available with microsecond precision, based on the Unix Epoch (1970/01/01 00:00:00). However, the accuracy is (in practice) no better then 1ms, and often worse than that.
This module is intended for use together with [NTP](https://en.wikipedia.org/wiki/Network_Time_Protocol)(Network Time Protocol) for keeping highly accurate real time at all times. Timestamps are available with microsecond precision, based on the Unix Epoch (1970/01/01 00:00:00). However, the accuracy is (in practice) no better then 1ms, and often worse than that.
Time keeping on the ESP8266 is technically quite challenging. Despite being named [RTC](https://en.wikipedia.org/wiki/Real-time_clock), the RTC is not really a Real Time Clock in the normal sense of the word. While it does keep a counter ticking while the module is sleeping, the accuracy with which it does so is *highly* dependent on the temperature of the chip. Said temperature changes significantly between when the chip is running and when it is sleeping, meaning that any calibration performed while the chip is active becomes useless mere moments after the chip has gone to sleep. As such, calibration values need to be deduced across sleep cycles in order to enable accurate time keeping. This is one of the things this module does.
...
...
@@ -18,11 +18,11 @@ Note that while the rtctime module can keep time across deep sleeps, it *will* l
This module can compensate for the underlying clock not running at exactly the required rate. The adjustment is in steps of 1 part in 2^32 (i.e. around 0.25 ppb). This adjustment
is done automatically if the [`sntp.sync()`](sntp.md#sntpsync) is called with the `autorepeat` flag set. The rate is settable using the [`set()`](#rtctimeset) function below. When the platform
is booted, it defaults to 0 (i.e. nominal). A sample of modules shows that the actual clock rate is temperature dependant, but is normally within 5ppm of the nominal rate. This translates to around 15 seconds per month.
is booted, it defaults to 0 (i.e. nominal). A sample of modules shows that the actual clock rate is temperature dependant, but is normally within 5ppm of the nominal rate. This translates to around 15 seconds per month.
In the automatic update mode it can take a couple of hours for the clock rate to settle down to the correct value. After that, how well it tracks will depend on the amount
of variation in timestamps from the NTP servers. If they are close, then the time will track to within a millisecond or so. If they are further away (say 100ms round trip), then
time tracking is somewhat worse, but normally within 10ms.
time tracking is somewhat worse, but normally within 10ms.
!!! important
...
...
@@ -160,7 +160,7 @@ rtctime.set(1436430589, 0)
## rtctime.adjust_delta()
This takes a time interval in 'system clock microseconds' based on the timestamps returned by `tmr.now` and returns
This takes a time interval in 'system clock microseconds' based on the timestamps returned by `tmr.now` and returns
an adjusted time interval in 'wall clock microseconds'. The size of the adjustment is typically pretty small as it (roughly) the error in the
crystal clock rate. This function is useful in some precision timing applications.
@@ -128,7 +128,7 @@ There are two principal methods that are invoked in the metatable (if it is pres
-`__newindex` this is the standard method invoked whenever a new table element is created.
-`checkpath` this is invoked (if defined) whenever a new table is created. It is invoked with two arguments:
-`table` this is the newly created table
-`path` this is a list of the keys from the root.
-`path` this is a list of the keys from the root.
It must return `true` if this object is wanted in the result, or `false` otherwise.
For example, when decoding `{ "foo": [1, 2, []] }` the checkpath will be invoked as follows:
...
...
@@ -141,7 +141,7 @@ When the `checkpath` method is called, the metatable has already be associated w
if desired. For example, if you are decoding `{ "foo": { "bar": [1,2,3,4], "cat": [5] } }` and, for some reason, you did not want to capture the
value of the `"bar"` key, then there are various ways to do this:
* In the `__newindex` metamethod, just check for the value of the key and skip the `rawset` if the key is `"bar"`. This only works if you want to skip all the
* In the `__newindex` metamethod, just check for the value of the key and skip the `rawset` if the key is `"bar"`. This only works if you want to skip all the
`"bar"` keys.
* In the `checkpath` method, if the path is `["foo"]`, then return `false`.
...
...
@@ -149,8 +149,8 @@ value of the `"bar"` key, then there are various ways to do this:
* Use the following `checkpath`: `checkpath=function(tab, path) tab['__json_path'] = path return true end` This will save the path in each constructed object. Now the `__newindex` method can perform more sophisticated filtering.
The reason for being able to filter is that it enables processing of very large JSON responses on a memory constrained platform. Many APIs return lots of information
which would exceed the memory budget of the platform. For example, `https://api.github.com/repos/nodemcu/nodemcu-firmware/contents` is over 13kB, and yet, if
you only need the `download_url` keys, then the total size is around 600B. This can be handled with a simple `__newindex` method.
which would exceed the memory budget of the platform. For example, `https://api.github.com/repos/nodemcu/nodemcu-firmware/contents` is over 13kB, and yet, if
you only need the `download_url` keys, then the total size is around 600B. This can be handled with a simple `__newindex` method.
## sjson.decoder:write
...
...
@@ -172,7 +172,7 @@ If a parse error occurrs during this decode, then an error is thrown and the par
## sjson.decoder:result
This gets the decoded Lua object, or raises an error if the decode is not yet complete. This can be called multiple times and will return the
This gets the decoded Lua object, or raises an error if the decode is not yet complete. This can be called multiple times and will return the
@@ -11,22 +11,22 @@ When compiled together with the [rtctime](rtctime.md) module it also offers seam
## sntp.sync()
Attempts to obtain time synchronization.
Attempts to obtain time synchronization.
For best results you may want to to call this periodically in order to compensate for internal clock drift. As stated in the [rtctime](rtctime.md) module documentation it's advisable to sync time after deep sleep and it's necessary to sync after module reset (add it to [`init.lua`](../upload.md#initlua) after WiFi initialization).
Note that either a single server can be provided as an argument (name or address), or a list (table) of servers can be provided.
Note that either a single server can be provided as an argument (name or address), or a list (table) of servers can be provided.
If *all* of the supplied host names/addresses are invalid, then the error callback will be called with argument type 1. Otherwise, if
there is at least one valid name/address, then then sync will be performed.
If any sync operation fails (maybe the device is disconnected from the internet), then all the names will be looked up again.
If any sync operation fails (maybe the device is disconnected from the internet), then all the names will be looked up again.
-`server_ip` if non-`nil`, that server is used. If `nil`, then the last contacted server is used. If there is no previous server, then the pool ntp servers are used. If the anycast server was used, then the first responding server will be saved.
-`server_ip` if non-`nil`, that server is used. If `nil`, then the last contacted server is used. If there is no previous server, then the pool ntp servers are used. If the anycast server was used, then the first responding server will be saved.
-`server1`, `server2` these are either the ip address or dns name of one or more servers to try.
-`callback` if provided it will be invoked on a successful synchronization, with four parameters: seconds, microseconds, server and info. Note that when the [rtctime](rtctime.md) module is available, there is no need to explicitly call [`rtctime.set()`](rtctime.md#rtctimeset) - this module takes care of doing so internally automatically, for best accuracy. The info parameter is a table of (semi) interesting values. These are described below.
-`errcallback` failure callback with two parameters. The first is an integer describing the type of error. The module automatically performs a number of retries before giving up and reporting the error. The second is a string containing supplementary information (if any). Error codes:
...
...
@@ -43,9 +43,9 @@ If any sync operation fails (maybe the device is disconnected from the internet)
This is passed to the success callback and contains useful information about the time synch that just completed. The keys in this table are:
-`offset_s` This is an optional field and contains the number of seconds that the clock was adjusted. This is only present for large (many second) adjustments. Typically, this is only present on the initial sync call.
-`offset_us` This is an optional field (but one of `offset_s` and `offset_us` will always be present). This contains the number of microseconds that the clock was adjusted.
-`offset_us` This is an optional field (but one of `offset_s` and `offset_us` will always be present). This contains the number of microseconds that the clock was adjusted.
-`delay_us` This is the round trip delay to the server in microseconds. This setting uncertainty is somewhat less than this value.
-`stratum` This is the stratum of the server.
-`stratum` This is the stratum of the server.
-`leap` This contains the leap bits from the NTP protocol. 0 means that no leap second is pending, 1 is a pending extra leap second at the end of the UTC month, and 2 is a pending leap second removal at the end of the UTC month.
#### Example
...
...
@@ -69,7 +69,7 @@ sntp.sync("224.0.1.1",
## sntp.setoffset
Sets the offset between the rtc clock and the NTP time. Note that NTP time has leap seconds in it and hence it runs slow when a leap second is
Sets the offset between the rtc clock and the NTP time. Note that NTP time has leap seconds in it and hence it runs slow when a leap second is
inserted. The `setoffset` call enables explicit leap second tracking and causes the rtc clock to tick more evenly -- but it gets out of step
with wall clock time. The number of seconds is the offset.
This module provides a simple interface to control Somfy blinds via an RF transmitter (433.42 MHz). It is based on [Nickduino Somfy Remote Arduino skecth](https://github.com/Nickduino/Somfy_Remote).
This module provides a simple interface to control Somfy blinds via an RF transmitter (433.42 MHz). It is based on [Nickduino Somfy Remote Arduino skecth](https://github.com/Nickduino/Somfy_Remote).
The hardware used is the standard 433 MHz RF transmitter. Unfortunately these chips are usually transmitting at he frequency of 433.92MHz so the crystal resonator should be replaced with the 433.42 MHz resonator though some reporting that it is working even with the original crystal.
...
...
@@ -30,7 +30,7 @@ My original remote is [TELIS 4 MODULIS RTS](https://www.somfy.co.uk/products/181
When I send the `somfy.DOWN` command, repeating the frame twice (which seems to be the standard for a short button press), i.e. `repeat_count` equal to 2, the blinds go only 1 step down. This corresponds to the movement of the wheel on the original remote. The down button on the original remote sends also `somfy.DOWN` command but the additional info is different and this makes the blinds go full down. Fortunately it seems that repeating the frame 16 times makes the blinds go fully down.
-`country_info` this table contains the current country info configuration
-`country` Country code, 2 character string.
-`start_ch` Starting channel.
-`start_ch` Starting channel.
-`end_ch` Ending channel.
-`policy` The policy parameter determines which country info configuration to use, country info given to station by AP or local configuration.
-`0` Country policy is auto, NodeMCU will use the country info provided by AP that the station is connected to.
-`1` Country policy is manual, NodeMCU will use locally configured country info.
#### Example
```lua
...
...
@@ -166,13 +166,13 @@ Wake up WiFi from suspended state or cancel pending wifi suspension.
This is disabled by default. Modify `PMSLEEP_ENABLE` in `app/include/user_config.h` to enable it.
!!! note
Wifi resume occurs asynchronously, this means that the resume request will only be processed when control of the processor is passed back to the SDK (after MyResumeFunction() has completed). The resume callback also executes asynchronously and will only execute after wifi has resumed normal operation.
Wifi resume occurs asynchronously, this means that the resume request will only be processed when control of the processor is passed back to the SDK (after MyResumeFunction() has completed). The resume callback also executes asynchronously and will only execute after wifi has resumed normal operation.
#### Syntax
`wifi.resume([resume_cb])`
#### Parameters
-`resume_cb` Callback to execute when WiFi wakes from suspension.
-`resume_cb` Callback to execute when WiFi wakes from suspension.
!!! note "Note:"
Any previously provided callbacks will be replaced!
...
...
@@ -209,12 +209,12 @@ Set the current country info.
-`end_ch` Ending channel, must not be less than starting channel (range:1-14). (Default:13)
-`policy` The policy parameter determines which country info configuration to use, country info given to station by AP or local configuration. (default:`wifi.COUNTRY_AUTO`)
-`wifi.COUNTRY_AUTO` Country policy is auto, NodeMCU will use the country info provided by AP that the station is connected to.
- while in stationAP mode, beacon/probe respose will reflect the country info of the AP that the station is connected to.
- while in stationAP mode, beacon/probe respose will reflect the country info of the AP that the station is connected to.
-`wifi.COUNTRY_MANUAL` Country policy is manual, NodeMCU will use locally configured country info.
@@ -323,7 +323,7 @@ The default value, 82, corresponds to maximum TX power. Lowering this setting co
`wifi.setmaxtxpower(max_tpw)`
#### Parameters
`max_tpw` maximum value of RF Tx Power, unit: 0.25 dBm, range [0, 82].
`max_tpw` maximum value of RF Tx Power, unit: 0.25 dBm, range [0, 82].
#### Returns
`nil`
...
...
@@ -385,13 +385,13 @@ none
[`wifi.startsmart()`](#wifistartsmart)
## wifi.suspend()
Suspend Wifi to reduce current consumption.
Suspend Wifi to reduce current consumption.
!!! attention
This is disabled by default. Modify `PMSLEEP_ENABLE` in `app/include/user_config.h` to enable it.
!!! note
Wifi suspension occurs asynchronously, this means that the suspend request will only be processed when control of the processor is passed back to the SDK (after MySuspendFunction() has completed). The suspend callback also executes asynchronously and will only execute after wifi has been successfully been suspended.
Wifi suspension occurs asynchronously, this means that the suspend request will only be processed when control of the processor is passed back to the SDK (after MySuspendFunction() has completed). The suspend callback also executes asynchronously and will only execute after wifi has been successfully been suspended.
#### Syntax
...
...
@@ -401,7 +401,7 @@ Suspend Wifi to reduce current consumption.
-`duration` Suspend duration in microseconds(μs). If a suspend duration of `0` is specified, suspension will be indefinite (Range: 0 or 50000 - 268435454 μs (0:4:28.000454))
-`suspend_cb` Callback to execute when WiFi is suspended. (Optional)
-`resume_cb` Callback to execute when WiFi wakes from suspension. (Optional)
-`preserve_mode` preserve current WiFi mode through node sleep. (Optional, Default: true)
-`preserve_mode` preserve current WiFi mode through node sleep. (Optional, Default: true)
- If true, Station and StationAP modes will automatically reconnect to previously configured Access Point when NodeMCU resumes.
- If false, discard WiFi mode and leave NodeMCU in [`wifi.NULL_MODE`](#wifigetmode). WiFi mode will be restored to original mode on restart.
...
...
@@ -494,7 +494,7 @@ wifi.sta.changeap(4)
## wifi.sta.clearconfig()
Clears the currently saved WiFi station configuration, erasing it from the flash. May be useful for certain factory-reset
Clears the currently saved WiFi station configuration, erasing it from the flash. May be useful for certain factory-reset
scenarios when a full [`node.restore()`](node.md#noderestore) is not desired, or to prepare for using
[End-User Setup](enduser-setup) so that the SoftAP is able to lock onto a single hardware radio channel.
...
...
@@ -536,11 +536,11 @@ Sets the WiFi station configuration.
- "DE:C1:A5:51:F1:ED"
- "AC-1D-1C-B1-0B-22"
- "DE AD BE EF 7A C0"
-`save` Save station configuration to flash.
-`save` Save station configuration to flash.
-`true` configuration **will** be retained through power cycle. (Default).
-`false` configuration **will not** be retained through power cycle.
- Event callbacks will only be available if `WIFI_SDK_EVENT_MONITOR_ENABLE` is uncommented in `user_config.h`
- Please note: To ensure all station events are handled at boot time, all relevant callbacks must be registered as early as possible in `init.lua` with either `wifi.sta.config()` or `wifi.eventmon.register()`.
- Please note: To ensure all station events are handled at boot time, all relevant callbacks must be registered as early as possible in `init.lua` with either `wifi.sta.config()` or `wifi.eventmon.register()`.
-`connected_cb`: Callback to execute when station is connected to an access point. (Optional)
- Items returned in table :
-`SSID`: SSID of access point. (format: string)
...
...
@@ -549,19 +549,19 @@ Sets the WiFi station configuration.
-`disconnected_cb`: Callback to execute when station is disconnected from an access point. (Optional)
- Items returned in table :
-`SSID`: SSID of access point. (format: string)
-`BSSID`: BSSID of access point. (format: string)
-`reason`: See [wifi.eventmon.reason](#wifieventmonreason) below. (format: number)
-`authmode_change_cb`: Callback to execute when the access point has changed authorization mode. (Optional)
-`BSSID`: BSSID of access point. (format: string)
-`reason`: See [wifi.eventmon.reason](#wifieventmonreason) below. (format: number)
-`authmode_change_cb`: Callback to execute when the access point has changed authorization mode. (Optional)
- Items returned in table :
-`old_auth_mode`: Old wifi authorization mode. (format: number)
-`old_auth_mode`: Old wifi authorization mode. (format: number)
-`new_auth_mode`: New wifi authorization mode. (format: number)
-`got_ip_cb`: Callback to execute when the station received an IP address from the access point. (Optional)
- Items returned in table :
-`IP`: The IP address assigned to the station. (format: string)
-`netmask`: Subnet mask. (format: string)
-`gateway`: The IP address of the access point the station is connected to. (format: string)
-`gateway`: The IP address of the access point the station is connected to. (format: string)
-`dhcp_timeout_cb`: Station DHCP request has timed out. (Optional)
- Blank table is returned.
- Blank table is returned.
#### Returns
-`true` Success
...
...
@@ -641,8 +641,8 @@ Disconnects from AP in station mode.
-`disconnected_cb`: Callback to execute when station is disconnected from an access point. (Optional)
- Items returned in table :
-`SSID`: SSID of access point. (format: string)
-`BSSID`: BSSID of access point. (format: string)
-`reason`: See [wifi.eventmon.reason](#wifieventmonreason) below. (format: number)
-`BSSID`: BSSID of access point. (format: string)
-`reason`: See [wifi.eventmon.reason](#wifieventmonreason) below. (format: number)
#### Returns
`nil`
...
...
@@ -789,7 +789,7 @@ Get information of APs cached by ESP8266 station.
-`qty` quantity of APs returned
-`1-5` index of AP. (the index corresponds to index used by [`wifi.sta.changeap()`](#wifistachangeap) and [`wifi.sta.getapindex()`](#wifistagetapindex))
-`ssid` ssid of Access Point
-`pwd` password for Access Point, `nil` if no password was configured
-`pwd` password for Access Point, `nil` if no password was configured
-`bssid` MAC address of Access Point
-`nil` will be returned if no MAC address was configured during station configuration.
@@ -861,10 +861,10 @@ If `return_table` is `true`:
-`config_table`
-`ssid` ssid of Access Point.
-`pwd` password to Access Point, `nil` if no password was configured
-`bssid_set` will return `true` if the station was configured specifically to connect to the AP with the matching `bssid`.
-`pwd` password to Access Point, `nil` if no password was configured
-`bssid_set` will return `true` if the station was configured specifically to connect to the AP with the matching `bssid`.
-`bssid` If a connection has been made to the configured AP this field will contain the AP's MAC address. Otherwise "ff:ff:ff:ff:ff:ff" will be returned.
If `return_table` is `false`:
...
...
@@ -911,7 +911,7 @@ If `return_table` is `true`:
-`config_table`
-`ssid` ssid of Access Point.
-`pwd` password to Access Point, `nil` if no password was configured
-`bssid_set` will return `true` if the station was configured specifically to connect to the AP with the matching `bssid`.
-`bssid_set` will return `true` if the station was configured specifically to connect to the AP with the matching `bssid`.
-`bssid` If a connection has been made to the configured AP this field will contain the AP's MAC address. Otherwise "ff:ff:ff:ff:ff:ff" will be returned.
If `return_table` is `false`:
...
...
@@ -1017,7 +1017,7 @@ none
#### Returns
- If station is connected to an access point, `rssi` is returned.
- If station is not connected to an access point, `nil` is returned.
- If station is not connected to an access point, `nil` is returned.
#### Example
```lua
...
...
@@ -1031,7 +1031,7 @@ Set Maximum number of Access Points to store in flash.
- This value is written to flash
!!! Attention
New setting will not take effect until restart.
New setting will not take effect until restart.
!!! Note
If 5 Access Points are stored and AP limit is set to 4, the AP at index 5 will remain until [`node.restore()`](node.md#noderestore) is called or AP limit is set to 5 and AP is overwritten.
...
...
@@ -1183,19 +1183,19 @@ Sets SSID and password in AP mode. Be sure to make the password at least 8 chara
-`true` configuration **will** be retained through power cycle. (Default)
-`false` configuration **will not** be retained through power cycle.
- Event callbacks will only be available if `WIFI_SDK_EVENT_MONITOR_ENABLE` is uncommented in `user_config.h`
- Please note: To ensure all SoftAP events are handled at boot time, all relevant callbacks must be registered as early as possible in `init.lua` with either `wifi.ap.config()` or `wifi.eventmon.register()`.
- Please note: To ensure all SoftAP events are handled at boot time, all relevant callbacks must be registered as early as possible in `init.lua` with either `wifi.ap.config()` or `wifi.eventmon.register()`.
-`staconnected_cb`: Callback executed when a new client has connected to the access point. (Optional)
- Items returned in table :
-`MAC`: MAC address of client that has connected.
-`AID`: SDK provides no details concerning this return value.
-`stadisconnected_cb`: Callback executed when a client has disconnected from the access point. (Optional)
-`MAC`: MAC address of client that has connected.
-`AID`: SDK provides no details concerning this return value.
-`stadisconnected_cb`: Callback executed when a client has disconnected from the access point. (Optional)
- Items returned in table :
-`MAC`: MAC address of client that has disconnected.
-`AID`: SDK provides no details concerning this return value.
-`MAC`: MAC address of client that has disconnected.
-`AID`: SDK provides no details concerning this return value.
-`probereq_cb`: Callback executed when a probe request was received. (Optional)
- Items returned in table :
-`MAC`: MAC address of the client that is probing the access point.
-`RSSI`: Received Signal Strength Indicator of client.
-`MAC`: MAC address of the client that is probing the access point.
-`RSSI`: Received Signal Strength Indicator of client.
@@ -167,7 +167,7 @@ A table with all the information elements in it.
print ("SSID", packet:ie_table()[0])
```
Note that this is possibly the worst way of getting the SSID.
Note that this is possibly the worst way of getting the SSID.
#### Alternative
...
...
@@ -188,7 +188,7 @@ information elements can be missing.
When a string is returned as the value of a field, it can (and often is) be a binary string with embedded nulls. All information elements are returned as strings
even if they are only one byte long and look like a number in the specification. This is purely to make the interface consistent. Note that even SSIDs can contain