Commit d77666c0 authored by sergio's avatar sergio Committed by Terry Ellison
Browse files

trailing spaces cleanup (#2659)

parent d7583040
......@@ -88,7 +88,7 @@ dofile("hello.lc")
Enters deep sleep mode, wakes up when timed out.
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.
#### Parameters
none
#### Returns
`max_duration`
......@@ -410,10 +410,10 @@ node.setcpufreq(node.CPU80MHZ)
## node.sleep()
Put NodeMCU in light sleep mode to reduce current consumption.
Put NodeMCU in light sleep mode to reduce current consumption.
* NodeMCU can not enter light sleep mode if wifi is suspended.
* All active timers will be suspended and then resumed when NodeMCU wakes from sleep.
* All active timers will be suspended and then resumed when NodeMCU wakes from sleep.
!!! attention
This is disabled by default. Modify `PMSLEEP_ENABLE` in `app/include/user_config.h` to enable it.
......@@ -423,10 +423,10 @@ Put NodeMCU in light sleep mode to reduce current consumption.
`node.sleep({wake_pin[, int_type, resume_cb, preserve_mode]})`
#### Parameters
<!--- 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`
#### Example
```lua
for i = node.task.LOW_PRIORITY, node.task.HIGH_PRIORITY do
for i = node.task.LOW_PRIORITY, node.task.HIGH_PRIORITY do
node.task.post(i,function(p2)
print("priority is "..p2)
end)
end
```
end)
end
```
prints
```
priority is 2
......
......@@ -170,7 +170,7 @@ else
present = ow.reset(pin)
ow.select(pin, addr)
ow.write(pin,0xBE,1)
print("P="..present)
print("P="..present)
data = nil
data = string.char(ow.read(pin))
for i = 1, 8 do
......@@ -184,7 +184,7 @@ else
t1 = t / 10000
t2 = t % 10000
print("Temperature="..t1.."."..t2.."Centigrade")
end
end
tmr.wdclr()
until false
else
......@@ -247,7 +247,7 @@ Writes a byte. If `power` is 1 then the wire is held high at the end for parasit
#### Parameters
- `pin` 1~12, I/O index
- `v` byte to be written to slave device
- `v` byte to be written to slave device
- `power` 1 for wire being held high for parasitically powered devices
#### Returns
......
......@@ -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
being spent.
being spent.
......@@ -4,7 +4,7 @@
| 2016-03-01 | [Philip Gladstone](https://github.com/pjsg) | [Philip Gladstone](https://github.com/pjsg) | [rotary.c](../../app/modules/rotary.c)|
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
- Adafruit: [rotary encoder](https://www.adafruit.com/products/377)
- 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
......
......@@ -142,7 +142,7 @@ Note that if the timestamp delta is too large compared to the previous sample st
####Example
```lua
-- Obtain a sample value from somewhere
local sample = ...
local sample = ...
-- Store sample with no scaling, under the name "foo"
rtcfifo.put(rtctime.get(), sample, 0, "foo")
```
......
......@@ -5,7 +5,7 @@
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.
......
......@@ -9,7 +9,7 @@ Please note that nested tables can require a lot of memory to encode. To catch o
This code using the streaming json library [jsonsl](https://github.com/mnunberg/jsonsl) to do the parsing of the string.
This module can be used in two ways. The simpler way is to use it as a direct drop-in for cjson (you can just do `_G.cjson = sjson`).
This module can be used in two ways. The simpler way is to use it as a direct drop-in for cjson (you can just do `_G.cjson = sjson`).
The more advanced approach is to use the streaming interface. This allows encoding and decoding of significantly larger objects.
The handling of json null is as follows:
......@@ -59,7 +59,7 @@ The following example prints out (in 64 byte chunks) a JSON encoded string conta
can be bigger than the total amount of memory on the NodeMCU.
```lua
function files()
function files()
result = {}
for k,v in pairs(file.list()) do
result[k] = function() return file.open(k):read(4096) end
......@@ -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
same object each time.
####Syntax
......@@ -199,7 +199,7 @@ altogether if desired.
```
local decoder = sjson.decoder({metatable=
{__newindex=function(t,k,v) print("Setting '" .. k .. "' = '" .. tostring(v) .."'")
{__newindex=function(t,k,v) print("Setting '" .. k .. "' = '" .. tostring(v) .."'")
rawset(t,k,v) end}})
decoder:write('[1, 2, {"foo":"bar"}]')
......
......@@ -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.
#### Syntax
`sntp.sync([server_ip], [callback], [errcallback], [autorepeat])`
`sntp.sync({ server1, server2, .. }, [callback], [errcallback], [autorepeat])`
#### Parameters
- `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.
......
......@@ -3,7 +3,7 @@
| :----- | :-------------------- | :---------- | :------ |
| 2016-09-27 | [vsky279](https://github.com/vsky279) | [vsky279](https://github.com/vsky279) | [somfy.c](../../app/modules/somfy.c)|
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.
#### Returns
#### Returns
nil
#### Example
......
......@@ -108,7 +108,7 @@ Calling `spi.setup()` will route the HSPI signals to the related pins, overridin
- `spi.MASTER`
- `spi.SLAVE` - **not supported currently**
- `cpol` clock polarity selection
- `spi.CPOL_LOW`
- `spi.CPOL_LOW`
- `spi.CPOL_HIGH`
- `cpha` clock phase selection
- `spi.CPHA_LOW`
......
......@@ -3,18 +3,18 @@
| :----- | :-------------------- | :---------- | :------ |
| 2016-06-26 |[Philip Gladstone](https://github.com/pjsg) | [Philip Gladstone](https://github.com/pjsg) | [switec.c](../../app/modules/switec.c)|
This module controls a [Switec X.27](http://www.jukenswisstech.com/?page_id=103) (or compatible) instrument stepper motor. These are the
This module controls a [Switec X.27](http://www.jukenswisstech.com/?page_id=103) (or compatible) instrument stepper motor. These are the
stepper motors that are used in modern automotive instrument clusters. They are incredibly cheap
and can be found at your favorite auction site or Chinese shopping site. There are varieties
which are dual axis -- i.e. have two stepper motors driving two concentric shafts so you
which are dual axis -- i.e. have two stepper motors driving two concentric shafts so you
can mount two needles from the same axis.
These motors run off 5V (some may work off 3.3V). They draw under 20mA and are designed to be
driven directly from MCU pins. Since the nodemcu runs at 3.3V, a level translator is required.
An octal translator like the [74LVC4245A](https://www.ti.com/lit/ds/symlink/sn74lvc4245a.pdf) can perform this translation. It also includes all the
protection diodes required.
protection diodes required.
These motors can be driven off three pins, with `pin2` and `pin3` being the same GPIO pin.
These motors can be driven off three pins, with `pin2` and `pin3` being the same GPIO pin.
If the motor is directly connected to the MCU, then the current load is doubled and may exceed
the maximum ratings. If, however, a driver chip is being used, then the load on the MCU is negligible
and the same MCU pin can be connected to two driver pins. In order to do this, just specify
......@@ -23,7 +23,7 @@ the same pin for `pin2` and `pin3`.
These motors do not have absolute positioning, but come with stops at both ends of the range.
The startup procedure is to drive the motor anti-clockwise until it is guaranteed that the needle
is on the step. Then this point can be set as zero. It is important not to let the motor
run into the endstops during normal operation as this will make the pointing inaccurate.
run into the endstops during normal operation as this will make the pointing inaccurate.
This module does not enforce any range limiting.
!!! important
......@@ -32,7 +32,7 @@ This module does not enforce any range limiting.
## switec.setup()
Initialize the nodemcu to talk to a switec X.27 or compatible instrument stepper motor. The default
slew rate is set so that it should work for most motors. Some motors can run at 600 degrees per second.
slew rate is set so that it should work for most motors. Some motors can run at 600 degrees per second.
#### Syntax
`switec.setup(channel, pin1, pin2, pin3, pin4 [, maxDegPerSec])`
......@@ -50,7 +50,7 @@ Nothing. If the arguments are in error, or the operation cannot be completed, th
##### Note
Once a channel is setup, it cannot be re-setup until the needle has stopped moving.
Once a channel is setup, it cannot be re-setup until the needle has stopped moving.
#### Example
......@@ -62,7 +62,7 @@ switec.setup(0, 5, 6, 7, 8)
Starts the needle moving to the specified position. If the needle is already moving, then the current
motion is cancelled, and the needle will move to the new position. It is possible to get a callback
when the needle stops moving. This is not normally required as multiple `moveto` operations can
be issued in quick succession. During the initial calibration, it is important. Note that the
be issued in quick succession. During the initial calibration, it is important. Note that the
callback is not guaranteed to be called -- it is possible that the needle never stops at the
target location before another `moveto` operation is triggered.
......@@ -125,12 +125,12 @@ The needle must not be moving, otherwise an error is thrown.
## Calibration
In order to set the zero point correctly, the needle should be driven anti-clockwise until
it runs into the end stop. Then the zero point can be set. The value of -1000 is used as that is
larger than the range of the motor -- i.e. it drives anti-clockwise through the entire range and
larger than the range of the motor -- i.e. it drives anti-clockwise through the entire range and
onto the end stop.
switec.setup(0, 5,6,7,8)
calibration = true
switec.moveto(0, -1000, function()
switec.moveto(0, -1000, function()
switec.reset(0)
calibration = false
end)
......
......@@ -43,7 +43,7 @@ end)
#### Parameters
A function called when the sensor has finished initialising.
#### Returns
#### Returns
0
## tcs34725.disable()
......@@ -53,7 +53,7 @@ Disables the sensor. Enables a low-power sleep mode.
#### Syntax
`tcs34725.disable()`
#### Returns
#### Returns
0
## tcs34725.raw()
......@@ -63,7 +63,7 @@ Reads the clear, red, green and blue values from the sensor.
#### Syntax
`clear,red,green,blue=tcs34725.raw()`
#### Returns
#### Returns
clear, red, green, blue in uint16_t.
## tcs34725.setGain()
......@@ -81,7 +81,7 @@ Sets the gain of the sensor. Must be called after the sensor is enabled.
|0x02|TCS34725_GAIN_16X|
|0x03|TCS34725_GAIN_60X|
#### Returns
#### Returns
0
## tcs34725.setIntegrationTime()
......@@ -99,6 +99,6 @@ Sets the integration time of the sensor. Must be called after the sensor is enab
|0xD5|TCS34725_INTEGRATIONTIME_101MS|
|0xC0|TCS34725_INTEGRATIONTIME_154MS|
|0x00|TCS34725_INTEGRATIONTIME_700MS|
#### Returns
#### Returns
0
......@@ -232,7 +232,7 @@ Controls the vertificate verification process when the Nodemcu makes a secure co
- `pemdata` A string containing the CA certificate to use for verification.
#### Returns
`true` if it worked.
`true` if it worked.
Can throw a number of errors if invalid data is supplied.
......@@ -278,10 +278,10 @@ http.get("https://letsencrypt.org/", nil, function (code, resp) print(code, resp
#### Notes
The certificate needed for verification is stored in the flash chip. The `tls.cert.verify` call with `true`
enables verification against the value stored in the flash.
enables verification against the value stored in the flash.
The certificate can be loaded into the flash chip in two ways -- one at firmware build time, and the other at initial boot
of the firmware. In order to load the certificate at build time, just place a file containing the CA certificate (in PEM format)
of the firmware. In order to load the certificate at build time, just place a file containing the CA certificate (in PEM format)
at `server-ca.crt` in the root of the nodemcu-firmware build tree. The build scripts will incorporate this into the resulting
firmware image.
......
......@@ -27,7 +27,7 @@ status = tsl2561.init(5, 6, tsl2561.ADDRESS_FLOAT, tsl2561.PACKAGE_T_FN_CL)
if status == tsl2561.TSL2561_OK then
lux = tsl2561.getlux()
print("Illuminance: "..lux.." lx")
print("Illuminance: "..lux.." lx")
end
```
......@@ -58,7 +58,7 @@ if status == tsl2561.TSL2561_OK then
ch0, ch1 = tsl2561.getrawchannels()
print("Raw values: "..ch0, ch1)
lux = tsl2561.getlux()
print("Illuminance: "..lux.." lx")
print("Illuminance: "..lux.." lx")
end
```
......@@ -93,7 +93,7 @@ Initializes the device on pins sdapin & sclpin. Optionally also configures the d
status = tsl2561.init(5, 6, tsl2561.ADDRESS_FLOAT, tsl2561.PACKAGE_T_FN_CL)
if status == tsl2561.TSL2561_OK then
lux = tsl2561.getlux()
print("Illuminance: "..lux.." lx")
print("Illuminance: "..lux.." lx")
end
```
......@@ -129,6 +129,6 @@ if status == tsl2561.TSL2561_OK then
end
if status == tsl2561.TSL2561_OK then
lux = tsl2561.getlux()
print("Illuminance: "..lux.." lx")
print("Illuminance: "..lux.." lx")
end
```
......@@ -15,26 +15,26 @@ U8g2 is a graphics library developed at [olikraus/u8g2](https://github.com/olikr
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list
* Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The NodeMCU firmware supports the following displays in I²C and SPI mode:
......
......@@ -10,7 +10,7 @@ after platform boot. This will cause a switch to the correct baud rate once a fe
!!! important
Although there are two UARTs(0 and 1) available to NodeMCU, **UART 1 is not capable of receiving data and is therefore transmit only**.
## uart.alt()
Change UART pin assignment.
......@@ -32,8 +32,8 @@ Sets the callback function to handle UART events.
Currently only the "data" event is supported.
!!! note
Due to limitations of the ESP8266, only UART 0 is capable of receiving data.
!!! note
Due to limitations of the ESP8266, only UART 0 is capable of receiving data.
#### Syntax
`uart.on(method, [number/end_char], [function], [run_input])`
......@@ -102,7 +102,7 @@ uart.setup(0, 9600, 8, uart.PARITY_NONE, uart.STOPBITS_1, 1)
## uart.getconfig()
Returns the current configuration parameters of the UART.
Returns the current configuration parameters of the UART.
#### Syntax
`uart.getconfig(id)`
......
......@@ -11,29 +11,29 @@ Ucglib is a graphics library developed at [olikraus/ucglib](https://github.com/o
Copyright (c) 2014, olikraus@gmail.com
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list
* Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The NodeMCU firmware supports a subset of these:
......
......@@ -9,7 +9,7 @@ The implementation supports fragmented messages, automatically responds to ping
**SSL/TLS support**
Take note of constraints documented in the [net module](net.md).
Take note of constraints documented in the [net module](net.md).
## websocket.createClient()
......
......@@ -71,12 +71,12 @@ Get the current country info.
#### Returns
- `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.
#### Returns
`true` If configuration was sucessful.
#### Example
```lua
......@@ -225,7 +225,7 @@ do
country_info.end_ch=13
country_info.policy=wifi.COUNTRY_AUTO;
wifi.setcountry(country_info)
end
end
--compact version
wifi.setcountry({country="US", start_ch=1, end_ch=13, policy=wifi.COUNTRY_AUTO})
......@@ -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.
......@@ -814,7 +814,7 @@ do
local x=wifi.sta.getapinfo()
local y=wifi.sta.getapindex()
print("\n Number of APs stored in flash:", x.qty)
print(string.format(" %-6s %-32s %-64s %-18s", "index:", "SSID:", "Password:", "BSSID:"))
print(string.format(" %-6s %-32s %-64s %-18s", "index:", "SSID:", "Password:", "BSSID:"))
for i=1, (x.qty), 1 do
print(string.format(" %s%-6d %-32s %-64s %-18s",(i==y and ">" or " "), i, x[i].ssid, x[i].pwd and x[i].pwd or type(nil), x[i].bssid and x[i].bssid or type(nil)))
end
......@@ -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.
#### Returns
- `true` Success
......@@ -1243,7 +1243,7 @@ end)
```
#### See also
[`wifi.eventmon.register()`](#wifieventmonregister)
[`wifi.eventmon.register()`](#wifieventmonregister)
[`wifi.eventmon.reason()`](#wifieventmonreason)
## wifi.ap.getbroadcast()
......@@ -1551,54 +1551,54 @@ Register/unregister callbacks for WiFi event monitor.
wifi.eventmon.register(Event[, function(T)])
#### Parameters
Event: WiFi event you would like to set a callback for.
- Valid WiFi events:
- wifi.eventmon.STA_CONNECTED
- wifi.eventmon.STA_DISCONNECTED
- wifi.eventmon.STA_AUTHMODE_CHANGE
- wifi.eventmon.STA_GOT_IP
- wifi.eventmon.STA_DHCP_TIMEOUT
- wifi.eventmon.AP_STACONNECTED
- wifi.eventmon.AP_STADISCONNECTED
- wifi.eventmon.AP_PROBEREQRECVED
Event: WiFi event you would like to set a callback for.
- Valid WiFi events:
- wifi.eventmon.STA_CONNECTED
- wifi.eventmon.STA_DISCONNECTED
- wifi.eventmon.STA_AUTHMODE_CHANGE
- wifi.eventmon.STA_GOT_IP
- wifi.eventmon.STA_DHCP_TIMEOUT
- wifi.eventmon.AP_STACONNECTED
- wifi.eventmon.AP_STADISCONNECTED
- wifi.eventmon.AP_PROBEREQRECVED
#### Returns
Function:
Function:
`nil`
Callback:
T: Table returned by event.
- `wifi.eventmon.STA_CONNECTED` Station is connected to access point.
- `SSID`: SSID of access point.
- `BSSID`: BSSID of access point.
- `channel`: The channel the access point is on.
- `wifi.eventmon.STA_DISCONNECTED`: Station was disconnected from access point.
- `SSID`: SSID of access point.
- `BSSID`: BSSID of access point.
- `reason`: See [wifi.eventmon.reason](#wifieventmonreason) below.
- `wifi.eventmon.STA_AUTHMODE_CHANGE`: Access point has changed authorization mode.
- `old_auth_mode`: Old wifi authorization mode.
- `new_auth_mode`: New wifi authorization mode.
- `wifi.eventmon.STA_GOT_IP`: Station got an IP address.
- `IP`: The IP address assigned to the station.
- `netmask`: Subnet mask.
- `gateway`: The IP address of the access point the station is connected to.
- `wifi.eventmon.STA_DHCP_TIMEOUT`: Station DHCP request has timed out.
- Blank table is returned.
- `wifi.eventmon.AP_STACONNECTED`: A new client has connected to the access point.
- `MAC`: MAC address of client that has connected.
- `AID`: SDK provides no details concerning this return value.
- `wifi.eventmon.AP_STADISCONNECTED`: A client has disconnected from the access point.
- `MAC`: MAC address of client that has disconnected.
- `AID`: SDK provides no details concerning this return value.
- `wifi.eventmon.AP_PROBEREQRECVED`: A probe request was received.
- `MAC`: MAC address of the client that is probing the access point.
- `RSSI`: Received Signal Strength Indicator of client.
- `wifi.eventmon.WIFI_MODE_CHANGE`: WiFi mode has changed.
- `old_auth_mode`: Old WiFi mode.
- `new_auth_mode`: New WiFi mode.
Callback:
T: Table returned by event.
- `wifi.eventmon.STA_CONNECTED` Station is connected to access point.
- `SSID`: SSID of access point.
- `BSSID`: BSSID of access point.
- `channel`: The channel the access point is on.
- `wifi.eventmon.STA_DISCONNECTED`: Station was disconnected from access point.
- `SSID`: SSID of access point.
- `BSSID`: BSSID of access point.
- `reason`: See [wifi.eventmon.reason](#wifieventmonreason) below.
- `wifi.eventmon.STA_AUTHMODE_CHANGE`: Access point has changed authorization mode.
- `old_auth_mode`: Old wifi authorization mode.
- `new_auth_mode`: New wifi authorization mode.
- `wifi.eventmon.STA_GOT_IP`: Station got an IP address.
- `IP`: The IP address assigned to the station.
- `netmask`: Subnet mask.
- `gateway`: The IP address of the access point the station is connected to.
- `wifi.eventmon.STA_DHCP_TIMEOUT`: Station DHCP request has timed out.
- Blank table is returned.
- `wifi.eventmon.AP_STACONNECTED`: A new client has connected to the access point.
- `MAC`: MAC address of client that has connected.
- `AID`: SDK provides no details concerning this return value.
- `wifi.eventmon.AP_STADISCONNECTED`: A client has disconnected from the access point.
- `MAC`: MAC address of client that has disconnected.
- `AID`: SDK provides no details concerning this return value.
- `wifi.eventmon.AP_PROBEREQRECVED`: A probe request was received.
- `MAC`: MAC address of the client that is probing the access point.
- `RSSI`: Received Signal Strength Indicator of client.
- `wifi.eventmon.WIFI_MODE_CHANGE`: WiFi mode has changed.
- `old_auth_mode`: Old WiFi mode.
- `new_auth_mode`: New WiFi mode.
#### Example
......@@ -1655,18 +1655,18 @@ Unregister callbacks for WiFi event monitor.
wifi.eventmon.unregister(Event)
#### Parameters
Event: WiFi event you would like to set a callback for.
Event: WiFi event you would like to set a callback for.
- Valid WiFi events:
- wifi.eventmon.STA_CONNECTED
- wifi.eventmon.STA_DISCONNECTED
- wifi.eventmon.STA_AUTHMODE_CHANGE
- wifi.eventmon.STA_GOT_IP
- wifi.eventmon.STA_DHCP_TIMEOUT
- wifi.eventmon.AP_STACONNECTED
- wifi.eventmon.AP_STADISCONNECTED
- wifi.eventmon.AP_PROBEREQRECVED
- wifi.eventmon.WIFI_MODE_CHANGED
- wifi.eventmon.STA_CONNECTED
- wifi.eventmon.STA_DISCONNECTED
- wifi.eventmon.STA_AUTHMODE_CHANGE
- wifi.eventmon.STA_GOT_IP
- wifi.eventmon.STA_DHCP_TIMEOUT
- wifi.eventmon.AP_STACONNECTED
- wifi.eventmon.AP_STADISCONNECTED
- wifi.eventmon.AP_PROBEREQRECVED
- wifi.eventmon.WIFI_MODE_CHANGED
#### Returns
`nil`
......@@ -1686,7 +1686,7 @@ Table containing disconnect reasons.
| Disconnect reason | value |
|:--------------------|:-------:|
|wifi.eventmon.reason.UNSPECIFIED | 1 |
|wifi.eventmon.reason.AUTH_EXPIRE | 2 |
|wifi.eventmon.reason.AUTH_EXPIRE | 2 |
|wifi.eventmon.reason.AUTH_LEAVE | 3 |
|wifi.eventmon.reason.ASSOC_EXPIRE | 4 |
|wifi.eventmon.reason.ASSOC_TOOMANY | 5 |
......
......@@ -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
embedded nulls.
embedded nulls.
| Attribute name | Type |
|:--------------------|:-------:|
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment