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

trailing spaces cleanup (#2659)

parent d7583040
......@@ -7,7 +7,7 @@ This Lua module provides access to [HDC1000](https://www.ti.com/lit/ds/symlink/h
!!! note
This module requires `i2c` C module built into firmware.
### Require
```lua
HDC1000 = require("HDC1000")
......@@ -54,7 +54,7 @@ Function to configure various options of HDC1000 sensor.
`nil`
## HDC1000.getTemp()
Reads the temperature from HDC1000 sensor.
Reads the temperature from HDC1000 sensor.
#### Syntax
`HDC1000.getTemp()`
......@@ -66,7 +66,7 @@ None
Temperature in Celsius degrees.
## HDC1000.getHumi()
Reads the humidity value from HDC1000 sensor.
Reads the humidity value from HDC1000 sensor.
#### Syntax
`HDC1000.getHumi()`
......
......@@ -20,7 +20,7 @@ package.loaded["httpserver"] = nil
Function to start HTTP server.
#### Syntax
`httpserver.createServer(port, handler(req, res))`
`httpserver.createServer(port, handler(req, res))`
#### Parameters
- `port`: Port number for HTTP server. Most HTTP servers listen at port 80.
......@@ -40,8 +40,8 @@ Callback function has 2 arguments: `req` (request) and `res` (response). The fir
- `self`: `req` object
- `name`: Header name
- `value`: Header value
- `value`: Header value
- `ondata`: value to setup handler function HTTP data. Handler function has 2 parameters:
- `self`: `req` object
- `chunk`: Request data
......
......@@ -7,7 +7,7 @@ This Lua module provides access to [LM92](http://www.ti.com/lit/ds/symlink/lm92.
!!! note
This module requires `i2c` C module built into firmware.
### Require
```lua
lm92 = require("lm92")
......@@ -183,7 +183,7 @@ scl = 4 -- GPIO 2
addr = 0x48
i2c.setup(0, sda, scl, i2c.SLOW) -- call i2c.setup() only once
lm92.setup(addr)
t = lm92.getTemperature()
print("Got temperature: "..t.." C")
......
......@@ -7,7 +7,7 @@ This Lua module provides access to [MCP23008](http://ww1.microchip.com/downloads
!!! note
This module requires `i2c` C module built into firmware.
### Require
```lua
mcp32008 = require("mcp32008")
......@@ -20,7 +20,7 @@ package.loaded["mcp32008"] = nil
```
## mcp32008.begin()
Sets the MCP23008 device address's last three bits.
Sets the MCP23008 device address's last three bits.
!!! note
The address is defined as binary `0100[A2][A1][A0]` where `A2`, `A1`, and `A0` are defined by the connection of the pins, e.g. if the pins are connected all to GND then the parameter address will need to be `0x0`.
......
......@@ -36,7 +36,7 @@ a = 31
b = 0
g = 0
r = 255
leds_abgr = string.char(a, b, g, r, a, b, g, r)
leds_abgr = string.char(a, b, g, r, a, b, g, r)
apa102.write(2, 3, leds_abgr) -- turn two APA102s to red, connected to data_pin 2 and clock_pin 3
```
......
......@@ -4,9 +4,9 @@
| 2017-11-13 | [Philip Gladstone](https://github.com/pjsg) | [Philip Gladstone](https://github.com/pjsg) | [bloom.c](../../app/modules/bloom.c)|
This module implements a [Bloom filter](https://en.wikipedia.org/wiki/Bloom_filter). This is a probabilistic data structure that is used to test for set membership. There are two operations -- `add` and `check` that allow
This module implements a [Bloom filter](https://en.wikipedia.org/wiki/Bloom_filter). This is a probabilistic data structure that is used to test for set membership. There are two operations -- `add` and `check` that allow
arbitrary strings to be added to the set or tested for set membership. Since this is a probabilistic data structure, the answer returned can be incorrect. However,
if the string *is* a member of the set, then the `check` operation will always return `true`.
if the string *is* a member of the set, then the `check` operation will always return `true`.
## bloom.create()
Create a filter object.
......@@ -93,7 +93,7 @@ Get some status information on the filter.
#### Returns
- `bits` The number of bits in the filter.
- `fns` The number of hash functions in use.
- `occupancy` The number of bits set in the filter.
- `occupancy` The number of bits set in the filter.
- `fprate` The approximate chance that the next `check` will return `true` when it should return `false`. This is represented as the inverse of the probability -- i.e. as the n in 1-in-n chance. This value is limited to 1,000,000.
#### Example
......
......@@ -8,7 +8,7 @@ This module provides a simple interface to [BME280/BMP280 temperature/air presss
!!! caution
Note that you must call [`setup()`](#bme280setup) before you can start reading values! Furthermore, there has to be a variable delay between some tens to hundreds of milliseconds between `setup()` and reading measurements. Instead of using a fixed delay you might also poll the sensor until data is delivered e.g. `humi()` not returning `nil` anymore.
## bme280.altitude()
......@@ -21,7 +21,7 @@ For given air pressure and sea level air pressure returns the altitude in meters
- `P` measured pressure
- `QNH` current sea level pressure
#### Returns
#### Returns
altitude in meters of measurement point
## bme280.baro()
......@@ -35,7 +35,7 @@ Current temperature is needed to calculate the air pressure so temperature readi
#### Parameters
none
#### Returns
#### Returns
- `P` air pressure in hectopascals multiplied by 1000
- `T` temperature in celsius as an integer multiplied with 100
......@@ -50,7 +50,7 @@ For given temperature and relative humidity returns the dew point in celsius as
- `H` relative humidity in percent multiplied by 1000.
- `T` temperate in celsius multiplied by 100.
#### Returns
#### Returns
dew point in celsisus
## bme280.humi()
......@@ -64,7 +64,7 @@ Current temperature is needed to calculate the relative humidity so temperature
#### Parameters
none
#### Returns
#### Returns
- `H` last relative humidity reading in % times 1000
- `T` temperature in celsius as an integer multiplied with 100
......@@ -79,13 +79,13 @@ For given altitude converts the air pressure to sea level air pressure.
- `P` measured pressure
- `altitude` altitude in meters of measurement point
#### Returns
#### Returns
sea level pressure
## bme280.read()
Reads the sensor and returns the temperature, the air pressure, the air relative humidity and
Reads the sensor and returns the temperature, the air pressure, the air relative humidity and
#### Syntax
`bme280.read([altitude])`
......@@ -93,7 +93,7 @@ Reads the sensor and returns the temperature, the air pressure, the air relative
#### Parameters
- (optional) `altitude`- altitude in meters of measurement point. If provided also the air pressure converted to sea level air pressure is returned.
#### Returns
#### Returns
- `T` temperature in celsius as an integer multiplied with 100
- `P` air pressure in hectopascals multiplied by 1000
- `H` relative humidity in percent multiplied by 1000
......@@ -111,7 +111,7 @@ Starts readout (turns the sensor into forced mode). After the readout the sensor
- `delay` sets sensor to forced mode and calls the `callback` (if provided) after given number of milliseconds. For 0 the default delay is set to 113ms (sufficient time to perform reading for oversampling settings 16x). For different oversampling setting please refer to [BME280 Final Datasheet - Appendix B: Measurement time and current calculation](https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BME280-DS002.pdf#page=51).
- `callback` if provided it will be invoked after given `delay`. The sensor reading should be finalized by then so.
#### Returns
#### Returns
`nil`
## bme280.setup()
......@@ -151,11 +151,11 @@ Using forced mode is recommended for applications which require low sampling rat
|`inactive_duration`|t standby (ms)|
|-----|-----------------|
|0|0.5|
|1|62.5|
|1|62.5|
|2|125|
|3|250|
|4|500|
|5|1000|
|5|1000|
|6|10|
|**7**|**20**|
......@@ -249,7 +249,7 @@ Reads the sensor and returns the temperature in celsius as an integer multiplied
#### Syntax
`bme280.temp()`
#### Parameters
#### Parameters
none
#### Returns
......
......@@ -9,7 +9,7 @@ In order to measure the air quality the sensor needs to be heated first. In the
This module is able to measure the gas resistance (see Bosch's datasheet). The gas resistance is not the IAQ (Indoor Air Quality) Index. But apparently it can be used as some proxy. The value still should somehow reflect the air quality. It seems that the higher value the air quality is better.
The algorithm for IAQ calculation from the gas restistances (probably measured at different temperatures) is not publicly available. Bosch says that at this point of time the calculations for the Indoor Air Quality index are offered only as a pre-compiled library (see discussion here: [BoschSensortec/BME680_driver#6](https://github.com/BoschSensortec/BME680_driver/issues/6)). It is available as the [BSEC Library](https://www.bosch-sensortec.com/bst/products/all_products/bsec).
The algorithm for IAQ calculation from the gas restistances (probably measured at different temperatures) is not publicly available. Bosch says that at this point of time the calculations for the Indoor Air Quality index are offered only as a pre-compiled library (see discussion here: [BoschSensortec/BME680_driver#6](https://github.com/BoschSensortec/BME680_driver/issues/6)). It is available as the [BSEC Library](https://www.bosch-sensortec.com/bst/products/all_products/bsec).
The algorithm is implemented in the library `bsec/algo/bin/ESP8266/libalgobsec.a`. Unfortunately I did not even manage to run the Bosch BSEC example on ESP8266 using this library.
## bme680.altitude()
......@@ -23,7 +23,7 @@ For given air pressure and sea level air pressure returns the altitude in meters
- `P` measured pressure
- `QNH` current sea level pressure
#### Returns
#### Returns
altitude in meters of measurement point
## bme680.dewpoint()
......@@ -37,7 +37,7 @@ For given temperature and relative humidity returns the dew point in Celsius as
- `H` relative humidity in percent multiplied by 1000.
- `T` temperate in Celsius multiplied by 100.
#### Returns
#### Returns
dew point in Celsius
## bme680.qfe2qnh()
......@@ -51,13 +51,13 @@ For given altitude converts the air pressure to sea level air pressure.
- `P` measured pressure
- `altitude` altitude in meters of measurement point
#### Returns
#### Returns
sea level pressure
## bme680.read()
Reads the sensor and returns the temperature, the air pressure, the air relative humidity and
Reads the sensor and returns the temperature, the air pressure, the air relative humidity and
#### Syntax
`bme680.read([altitude])`
......@@ -65,7 +65,7 @@ Reads the sensor and returns the temperature, the air pressure, the air relative
#### Parameters
- (optional) `altitude`- altitude in meters of measurement point. If provided also the air pressure converted to sea level air pressure is returned.
#### Returns
#### Returns
- `T` temperature in Celsius as an integer multiplied with 100
- `P` air pressure in hectopascals multiplied by 100
- `H` relative humidity in percent multiplied by 1000
......@@ -86,7 +86,7 @@ Starts readout (turns the sensor into forced mode). After the readout the sensor
- `delay` sets sensor to forced mode and calls the `callback` (if provided) after given number of milliseconds. For 0 the default delay is calculated by the [formula provided by Bosch](https://github.com/BoschSensortec/BME680_driver/blob/2a51b9c0c1899f28e561e6701caa22cb23201cfc/bme680.c#L586). Apparently for certain combinations of oversamplings setup the the delay returned by the formula is not sufficient and the readout is not ready (make sure you are not reading the previous measurement). For default parameters (2x, 16x, 1x) the calculated delay is 121 ms while in reality 150 ms are needed to get the result.
- `callback` if provided it will be invoked after given `delay`. The sensor reading should be finalized by then so.
#### Returns
#### Returns
`nil`
## bme680.setup()
......@@ -101,8 +101,8 @@ Initializes module. Initialization is mandatory before read values.
- (optional) `temp_oss` - Controls oversampling of temperature data. Default oversampling is 2x.
- (optional) `press_oss` - Controls oversampling of pressure data. Default oversampling is 16x.
- (optional) `humi_oss` - Controls oversampling of humidity data. Default oversampling is 1x
- (optional) `heater_temp` -
- (optional) `heater_duration` -
- (optional) `heater_temp` -
- (optional) `heater_duration` -
- (optional) `IIR_filter` - Controls the time constant of the IIR filter. Default filter coefficient is 31.
- (optional) `cold_start` - If 0 then the bme680 chip is not initialised. Useful in a battery operated setup when the ESP deep sleeps and on wakeup needs to initialise the driver (the module) but not the chip itself. The chip was kept powered (sleeping too) and is holding the latest reading that should be fetched quickly before another reading starts (`bme680.startreadout()`). By default the chip is initialised.
......
......@@ -197,7 +197,7 @@ cs:var("all", coap.JSON) -- sets content type to json
## coap.server:func()
Registers a Lua function as an endpoint in the server. The function then can be called by a client via POST method. represented as an [URI](http://tools.ietf.org/html/rfc7252#section-6) to the client. The endpoint path for function is '/v1/f/'.
Registers a Lua function as an endpoint in the server. The function then can be called by a client via POST method. represented as an [URI](http://tools.ietf.org/html/rfc7252#section-6) to the client. The endpoint path for function is '/v1/f/'.
When the client issues a POST request to this URI, the payload will be passed to the function as parameter. The function's return value will be the payload in the message to the client.
......
......@@ -3,7 +3,7 @@
| :----- | :-------------------- | :---------- | :------ |
| 2017-12-30 | [Konrad Huebner](https://github.com/skycoders) | [Konrad Huebner](https://github.com/skycoders) | [color_utils.c](../../app/modules/color_utils.c)|
This module provides basic color transformations useful for color LEDs.
This module provides basic color transformations useful for color LEDs.
## color_utils.hsv2grb()
Convert HSV color to GRB color.
......
......@@ -7,7 +7,7 @@
!!! important
This module needs RTC time to operate correctly. Do not forget to include the [`rtctime`](rtctime.md) module **and** initialize it properly.
!!! important
The cron expression has to be in GMT/UTC!
......
......@@ -32,7 +32,7 @@ thrown if the string is not a valid base64 encoding.
`binary_string = encoder.toBase64(b64)`
#### Parameters
`b64` Base64 encoded input string
`b64` Base64 encoded input string
#### Return
The decoded Lua (binary) string.
......@@ -64,7 +64,7 @@ print(encoder.toHex(crypto.hash("sha1","abc")))
## encoder.fromHex()
Returns the Lua binary string decode of a ASCII hex string. Each byte in the output string is
represented as two hex characters in the input. An error is thrown if the string is not a
represented as two hex characters in the input. An error is thrown if the string is not a
valid base64 encoding.
#### Syntax
......
......@@ -7,17 +7,17 @@ This module provides a simple way of configuring ESP8266 chips without using a s
![enduser setup config dialog](../img/enduser-setup.jpg "enduser setup config dialog")
After running [`enduser_setup.start()`](#enduser_setupstart), a wireless network named "SetupGadget_XXXXXX" will start (this prefix can be overridden in `user_config.h` by defining
After running [`enduser_setup.start()`](#enduser_setupstart), a wireless network named "SetupGadget_XXXXXX" will start (this prefix can be overridden in `user_config.h` by defining
`ENDUSER_SETUP_AP_SSID`). Connect to that SSID and then navigate to the root
of any website (e.g., `http://example.com/` will work, but do not use `.local` domains because it will fail on iOS). A web page similar to the picture above will load, allowing the
of any website (e.g., `http://example.com/` will work, but do not use `.local` domains because it will fail on iOS). A web page similar to the picture above will load, allowing the
end user to provide their Wi-Fi information.
After an IP address has been successfully obtained, then this module will stop as if [`enduser_setup.stop()`](#enduser_setupstop) had been called. There is a 10-second delay before
teardown to allow connected clients to obtain a last status message while the SoftAP is still active.
Alternative HTML can be served by placing a file called `enduser_setup.html` on the filesystem. Everything needed by the web page must be included in this one file. This file will be kept
in RAM, so keep it as small as possible. The file can be gzip'd ahead of time to reduce the size (i.e., using `gzip -n` or `zopfli`), and when served, the End User Setup module will add
the appropriate `Content-Encoding` header to the response.
Alternative HTML can be served by placing a file called `enduser_setup.html` on the filesystem. Everything needed by the web page must be included in this one file. This file will be kept
in RAM, so keep it as small as possible. The file can be gzip'd ahead of time to reduce the size (i.e., using `gzip -n` or `zopfli`), and when served, the End User Setup module will add
the appropriate `Content-Encoding` header to the response.
*Note: If gzipped, the file can also be named `enduser_setup.html.gz` for semantic purposes. Gzip encoding is determined by the file's contents, not the filename.*
......@@ -67,7 +67,7 @@ enduser_setup.start(
## enduser_setup.start()
Starts the captive portal.
Starts the captive portal.
*Note: Calling start() while EUS is already running is an error, and will result in stop() to be invoked to shut down EUS.*
......
......@@ -14,10 +14,10 @@ target remote /dev/ttyUSB0
At this point, you can just poke around and see what happened, but you cannot continue execution.
In order to do interactive debugging, add a call to `gdbstub.brk()` in your Lua code. This will trigger a break instruction and will trap into gdb as above. However, continuation is supported from a break instruction and so you can single step, set breakpoints, etc. Note that the lx106 processor as configured by Espressif only supports a single hardware breakpoint. This means that you can only put a single breakpoint in flash code. You can single step as much as you like.
In order to do interactive debugging, add a call to `gdbstub.brk()` in your Lua code. This will trigger a break instruction and will trap into gdb as above. However, continuation is supported from a break instruction and so you can single step, set breakpoints, etc. Note that the lx106 processor as configured by Espressif only supports a single hardware breakpoint. This means that you can only put a single breakpoint in flash code. You can single step as much as you like.
## gdbstub.open()
Runs gdbstub initialization routine. It has to be run only once in code.
Runs gdbstub initialization routine. It has to be run only once in code.
#### Syntax
`gdbstub.open()`
......@@ -29,7 +29,7 @@ Enters gdb by executing a `break 0,0` instruction.
`gdbstub.brk()`
## gdbstub.gdboutput()
Controls whether system output is encapsulated in gdb remote debugging protocol. This turns out not to be as useful as you would hope - mostly because you can't send input to the NodeMCU board. Also because you really only should make this call *after* you get gdb running and connected to the NodeMCU. The example below first does the break and then switches to redirect the output. This works (but you are unable to send any more console input).
Controls whether system output is encapsulated in gdb remote debugging protocol. This turns out not to be as useful as you would hope - mostly because you can't send input to the NodeMCU board. Also because you really only should make this call *after* you get gdb running and connected to the NodeMCU. The example below first does the break and then switches to redirect the output. This works (but you are unable to send any more console input).
#### Syntax
`gdbstub.gdboutput(enable)`
......
......@@ -125,7 +125,7 @@ This function is not available if GPIO_INTERRUPT_ENABLE was undefined at compile
- `type` "up", "down", "both", "low", "high", which represent *rising edge*, *falling edge*, *both
edges*, *low level*, and *high level* trigger modes respectivey. If the type is "none" or omitted
then the callback function is removed and the interrupt is disabled.
- `callback_function(level, when, eventcount)` callback function when trigger occurs. The level of the specified pin
- `callback_function(level, when, eventcount)` callback function when trigger occurs. The level of the specified pin
at the interrupt passed as the first parameter to the callback. The timestamp of the event is passed
as the second parameter. This is in microseconds and has the same base as for `tmr.now()`. This timestamp
is grabbed at interrupt level and is more consistent than getting the time in the callback function.
......@@ -191,7 +191,7 @@ timing control.
The basic idea is to build a `gpio.pulse` object and then control it with methods on that object. Only one `gpio.pulse`
object can be active at a time. The object is built from an array of tables where each inner table represents
an action to take and the time to delay before moving to the next action.
an action to take and the time to delay before moving to the next action.
One of the uses for this is to generate bipolar impulse for driving clock movements where you want (say) a pulse on Pin 1 on the even
second, and a pulse on Pin 2 on the odd second. `:getstate` and `:adjust` can be used to keep the pulse synchronized to the
......@@ -236,7 +236,7 @@ an unisgned 32 bit integer). If this isn't enough repeats, then loops can be nes
```
The loop/count in step 2 will cause 1,000,000,000 pulses to be output (at 1kHz). This is around 11 days. At this point, it will continue onto step 3 which triggers the
11 days of 1kHz. THis process will repeat for 1,000,000,000 times (which is roughly 30 Million years).
11 days of 1kHz. THis process will repeat for 1,000,000,000 times (which is roughly 30 Million years).
The looping model is that associated with each loop there is a hidden variable which starts at the `count` value and decrements on each iteration until it gets to zero
when it then proceeds to the next step. If control reaches that loop again, then the hidden variable is reset to the value of `count` again.
......@@ -252,8 +252,8 @@ This builds the `gpio.pulse` object from the supplied argument (a table as descr
#### Parameter
`table` this is view as an array of instructions. Each instruction is represented by a table as follows:
- All numeric keys are considered to be pin numbers. The values of each are the value to be set onto the respective GPIO line.
For example `{ [1] = gpio.HIGH }` would set pin 1 to be high.
- All numeric keys are considered to be pin numbers. The values of each are the value to be set onto the respective GPIO line.
For example `{ [1] = gpio.HIGH }` would set pin 1 to be high.
Note this that is the NodeMCU pin number and *not* the ESP8266 GPIO number. Multiple pins can be
set at the same time. Note that any valid GPIO pin can be used, including pin 0.
- `delay` specifies the number of microseconds after setting the pin values to wait until moving to the next state. The actual delay may be longer than this value depending on whether interrupts are enabled at the end time. The maximum value is 64,000,000 -- i.e. a bit more than a minute.
......
......@@ -7,7 +7,7 @@ Basic HTTP *client* module that provides an interface to do GET/POST/PUT/DELETE
!!! attention
It is **not** possible to execute concurrent HTTP requests using this module.
It is **not** possible to execute concurrent HTTP requests using this module.
Each request method takes a callback which is invoked when the response has been received from the server. The first argument is the status code, which is either a regular HTTP status code, or -1 to denote a DNS, connection or out-of-memory failure, or a timeout (currently at 60 seconds).
......@@ -20,7 +20,7 @@ to make it easy to access. If there are multiple headers of the same name, then
**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).
## http.delete()
......@@ -157,7 +157,7 @@ Execute a custom HTTP request for any HTTP method. Note that concurrent requests
#### Example
```lua
http.request("http://httpbin.org", "HEAD", "", "",
http.request("http://httpbin.org", "HEAD", "", "",
function(code, data)
if (code < 0) then
print("HTTP request failed")
......
......@@ -10,7 +10,7 @@ This module provides access to the [MCP4725 12-bit Digital to Analog Converter](
VDD is the power supply pin for the device. The voltage at the VDD pin is used as the supply input as well as the DAC reference input. The power supply at the VDD pin should be clean as possible for good DAC performance.
!!!note:
The MCP4725 device address contains four fixed bits ( 1100 = device code) and three address bits (A2, A1, A0). The A2 and A1 bits are hard-wired during manufacturing, and A0 bit is determined by the logic state of A0 pin. The A0 pin can be connected to VDD or VSS , or actively driven by digital logic levels. The address pin(A0) can be actively driven by a GPIO to act as a chip select, allowing more than 2 devices to be used on the same bus.
The MCP4725 device address contains four fixed bits ( 1100 = device code) and three address bits (A2, A1, A0). The A2 and A1 bits are hard-wired during manufacturing, and A0 bit is determined by the logic state of A0 pin. The A0 pin can be connected to VDD or VSS , or actively driven by digital logic levels. The address pin(A0) can be actively driven by a GPIO to act as a chip select, allowing more than 2 devices to be used on the same bus.
## mcp4725.read()
Gets contents of the dac register and EEPROM.
......@@ -25,7 +25,7 @@ Gets contents of the dac register and EEPROM.
- `A2` Address bit 2. This bit is hard-wired during manufacture. (valid states: 0 or 1) (default: 0)
#### Returns
* `cur_pwrdn` Current power down configuration value.
* `cur_pwrdn` Current power down configuration value.
* `cur_val` Current value stored in dac register.
* `eeprom_pwrdn` Power down configuration stored in EEPROM.
* `eeprom_val` DAC value stored in EEPROM.
......@@ -98,7 +98,7 @@ Write configuration to dac register or dac register and eeprom.
- `mcp4725.PWRDN_500K` MCP4725 output disabled, output pulled to ground via 500K restistor.
- `save` Save pwrdn and dac values to EEPROM. (Values are loaded on power-up or during reset.)
- `true` Save configuration to EEPROM.
- `false` Do not save configuration to EEPROM. (Default)
- `false` Do not save configuration to EEPROM. (Default)
#### Returns
nil
......@@ -136,7 +136,7 @@ do
i2c.setup(ID, SDA, SCL, i2c.SLOW)
gpio.mode(mcp4725_chip_sel, gpio.OUTPUT, gpio.PULLUP)
gpio.write(mcp4725_chip_sel, 1)
mcp4725.read({A0=1, value})
gpio.write(mcp4725_chip_sel, 0)
......
......@@ -3,7 +3,7 @@
| :----- | :-------------------- | :---------- | :------ |
| 2016-02-24 | [Philip Gladstone](https://github.com/pjsg) | [Philip Gladstone](https://github.com/pjsg) | [mdns.c](../../app/modules/mdns.c)|
[Multicast DNS](https://en.wikipedia.org/wiki/Multicast_DNS) is used as part of Bonjour / Zeroconf. This allows systems to identify themselves and the services that they provide on a local area network. Clients are then able to discover these systems and connect to them.
[Multicast DNS](https://en.wikipedia.org/wiki/Multicast_DNS) is used as part of Bonjour / Zeroconf. This allows systems to identify themselves and the services that they provide on a local area network. Clients are then able to discover these systems and connect to them.
!!! note
......@@ -19,8 +19,8 @@ Register a hostname and start the mDNS service. If the service is already runnin
- `hostname` The hostname for this device. Alphanumeric characters are best.
- `attributes` A optional table of options. The keys must all be strings.
The `attributes` contains two sorts of attributes — those with specific names, and those that are service specific. [RFC 6763](https://tools.ietf.org/html/rfc6763#page-13)
defines how extra, service specific, attributes are encoded into the DNS. One example is that if the device supports printing, then the queue name can
The `attributes` contains two sorts of attributes — those with specific names, and those that are service specific. [RFC 6763](https://tools.ietf.org/html/rfc6763#page-13)
defines how extra, service specific, attributes are encoded into the DNS. One example is that if the device supports printing, then the queue name can
be specified as an additional attribute. This module supports up to 10 such attributes.
The specific names are:
......
......@@ -60,7 +60,7 @@ m = mqtt.Client("clientid", 120)
m = mqtt.Client("clientid", 120, "user", "password")
-- setup Last Will and Testament (optional)
-- Broker will publish a message with qos = 0, retain = 0, data = "offline"
-- Broker will publish a message with qos = 0, retain = 0, data = "offline"
-- to topic "/lwt" if client don't send keepalive packet
m:lwt("/lwt", "offline", 0, 0)
......@@ -68,8 +68,8 @@ m:on("connect", function(client) print ("connected") end)
m:on("offline", function(client) print ("offline") end)
-- on publish message receive event
m:on("message", function(client, topic, data)
print(topic .. ":" )
m:on("message", function(client, topic, data)
print(topic .. ":" )
if data ~= nil then
print(data)
end
......@@ -145,7 +145,7 @@ is lost for any reason.
In order to acheive a consistent connection, handle errors in the error callback. For example:
```
function handle_mqtt_error(client, reason)
function handle_mqtt_error(client, reason)
tmr.create():alarm(10 * 1000, tmr.ALARM_SINGLE, do_mqtt_connect)
end
......@@ -232,7 +232,7 @@ Publishes a message.
- `qos` QoS level
- `retain` retain flag
- `function(client)` optional callback fired when PUBACK received. NOTE: When calling publish() more than once, the last callback function defined will be called for ALL publish commands.
#### Returns
`true` on success, `false` otherwise
......
......@@ -320,16 +320,16 @@ srv = net.createConnection(net.TCP, 0)
srv:on("receive", function(sck, c) print(c) end)
-- Wait for connection before sending.
srv:on("connection", function(sck, c)
-- 'Connection: close' rather than 'Connection: keep-alive' to have server
-- initiate a close of the connection after final response (frees memory
-- earlier here), https://tools.ietf.org/html/rfc7230#section-6.6
-- 'Connection: close' rather than 'Connection: keep-alive' to have server
-- initiate a close of the connection after final response (frees memory
-- earlier here), https://tools.ietf.org/html/rfc7230#section-6.6
sck:send("GET /get HTTP/1.1\r\nHost: httpbin.org\r\nConnection: close\r\nAccept: */*\r\n\r\n")
end)
srv:connect(80,"httpbin.org")
```
!!! note
The `receive` event is fired for every network frame! Hence, if the data sent to the device exceeds 1460 bytes (derived from [Ethernet frame size](https://en.wikipedia.org/wiki/Ethernet_frame)) it will fire more than once. There may be other situations where incoming data is split across multiple frames (e.g. HTTP POST with `multipart/form-data`). You need to manually buffer the data and find means to determine if all data was received.
```lua
local buffer = nil
......@@ -342,7 +342,7 @@ srv:on("receive", function(sck, c)
end)
-- throttling could be implemented using socket:hold()
-- example: https://github.com/nodemcu/nodemcu-firmware/blob/master/lua_examples/pcm/play_network.lua#L83
```
```
#### See also
- [`net.createServer()`](#netcreateserver)
......@@ -405,11 +405,11 @@ end)
If you do not or can not keep all the data you send back in memory at one time (remember that `response` is an aggregation) you may use explicit callbacks instead of building up a table like so:
```lua
sck:send(header, function()
sck:send(header, function()
local data1 = "some large chunk of dynamically loaded data"
sck:send(data1, function()
local data2 = "even more dynamically loaded data"
sck:send(data2, function(sk)
sck:send(data2, function(sk)
sk:close()
end)
end)
......@@ -601,7 +601,7 @@ Sets the IP of the DNS server used to resolve hostnames. Default: resolver1.open
#### Parameters
- `dns_ip_addr` IP address of a DNS server
- `dns_index` which DNS server to set (range 0~1). Hence, it supports max. 2 servers.
- `dns_index` which DNS server to set (range 0~1). Hence, it supports max. 2 servers.
#### Returns
`nil`
......
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