@@ -65,6 +65,7 @@ Configuration
65
65
-------------
66
66
67
67
.. method :: ESPNow.init()
68
+ ESPNow.init([recv_bufsize]) (ESP8266 only)
68
69
69
70
Prepare the software and hardware for use of the ESPNow communication
70
71
protocol, including:
@@ -74,6 +75,9 @@ Configuration
74
75
- invoke esp_now_init() and
75
76
- register the send and recv callbacks.
76
77
78
+ **ESP8266 **: The recv buffer size may be set as an argument to `init() ` as
79
+ there is no `config() ` method on the ESP8266.
80
+
77
81
.. method :: ESPNow.deinit()
78
82
79
83
De-initialise the Espressif ESPNow software stack (esp_now_deinit()),
@@ -82,7 +86,7 @@ Configuration
82
86
**Note **: `deinit() ` will also deregister all peers which must be
83
87
re-registered after `init() `.
84
88
85
- .. method :: ESPNow.config()
89
+ .. method :: ESPNow.config() (ESP32 only)
86
90
ESPNow.config('param')
87
91
ESPNow.config(param=value, ...)
88
92
@@ -107,7 +111,7 @@ Configuration
107
111
- ``timeout ``: *(default=300,000) * Default read timeout (in milliseconds).
108
112
The timeout can also be provided as arg to `recv() ` and `irecv() `.
109
113
110
- .. method :: ESPNow.clear(True)
114
+ .. method :: ESPNow.clear(True) (ESP32 only)
111
115
112
116
Clear out any data in the recv buffer. Use this to clean
113
117
up after receiving a ``Buffer error `` (should not happen). All data in the
@@ -134,8 +138,8 @@ For example::
134
138
w0 = network.WLAN(network.STA_IF)
135
139
w0.active(True)
136
140
137
- .. method :: ESPNow.send(mac, msg, [sync=True])
138
- ESPNow.send(msg)
141
+ .. method :: ESPNow.send(mac, msg, [sync=True]) (ESP32 only)
142
+ ESPNow.send(msg) (ESP32 only)
139
143
140
144
Send the data contained in ``msg `` to the peer with given network ``mac ``
141
145
address. In the second form, ``mac=None `` and ``sync=True ``.
@@ -163,7 +167,7 @@ For example::
163
167
it has initialised it's ESP-Now system or is actively listening for ESP-Now
164
168
traffic (see the Espressif ESP-Now docs).
165
169
166
- .. method :: ESPNow.recv([timeout])
170
+ .. method :: ESPNow.recv([timeout]) (ESP32 only)
167
171
168
172
Wait for an incoming message and return a newly allocated tuple of
169
173
bytestrings: ``(mac, message) ``, where:
@@ -189,11 +193,11 @@ For example::
189
193
`irecv()<ESPNow.irecv()> `. You must make copies if you
190
194
wish to keep the values across calls to ``irecv() ``.
191
195
192
- .. method :: ESPNow.stats()
196
+ .. method :: ESPNow.stats() (ESP32 only)
193
197
194
198
Return a 5-tuple containing the number of packets sent/received/lost::
195
199
196
- (sent_packets, sent_responses, sent_failures, recv_packets, lost_rx_packets )
200
+ (sent_packets, sent_responses, sent_failures, recv_packets, dropped_recv_packets )
197
201
198
202
Incoming packets are *dropped * when the recv buffers are full. To reduce
199
203
packet loss, increase the ``rxbuf `` config parameters and ensure you are
@@ -205,6 +209,8 @@ For example::
205
209
Iteration over ESPNow
206
210
---------------------
207
211
212
+ **Note **: ESP32 only
213
+
208
214
It is also possible to read messages by iterating over the ESPNow singleton
209
215
object. This will yield ``(mac, message) `` tuples using the alloc-free
210
216
`irecv() ` method, eg::
@@ -222,7 +228,7 @@ The Esspresif ESP-Now software requires that other devices (peers) must be
222
228
*registered * before we can `send()<ESPNow.send()> ` them messages.
223
229
224
230
.. method :: ESPNow.add_peer(mac, [lmk], [channel], [ifidx], [encrypt])
225
- ESPNow.add_peer(mac, ' param' =value, ...)
231
+ ESPNow.add_peer(mac, param=value, ...) (ESP32 only )
226
232
227
233
Add/register the provided ``mac `` address (a 6-byte byte-string) as a peer
228
234
under the ESPNow protocol. The following "peer info" parameters may also be
@@ -239,30 +245,33 @@ The Esspresif ESP-Now software requires that other devices (peers) must be
239
245
be an integer from 0 to 14. If channel is set to 0 the current channel
240
246
of the wifi device will be used. (default=0)
241
247
242
- - ``ifidx ``: Index of the wifi interface which will be used to send data to
243
- this peer. Must be an integer set to ``network.STA_IF `` (=0) or
244
- ``network.AP_IF `` (=1). (default=0/``network.STA_IF ``).
248
+ - ``ifidx ``: *(ESP32 only) * Index of the wifi interface which will be used
249
+ to send data to this peer. Must be an integer set to
250
+ ``network.STA_IF `` (=0) or ``network.AP_IF `` (=1).
251
+ (default=0/``network.STA_IF ``).
252
+
253
+ - ``encrypt ``: *(ESP32 only) * If set to ``True `` data exchanged with this
254
+ peer will be encrypted with the PMK and LMK. (default=``False``)
245
255
246
- - ``encrypt ``: If set to ``True `` data exchanged with this peer will be
247
- encrypted with the PMK and LMK. (default=``False``)
256
+ **ESP8266 **: Keyword args may not be used on the ESP8266.
248
257
249
- .. method :: ESPNow.get_peer(mac)
258
+ .. method :: ESPNow.get_peer(mac) (ESP32 only)
250
259
251
260
Return a 5-tuple of the "peer info" associated with the ``mac `` address::
252
261
253
262
(mac, lmk, channel, ifidx, encrypt)
254
263
255
- .. method :: ESPNow.peer_count()
264
+ .. method :: ESPNow.peer_count() (ESP32 only)
256
265
257
266
Return the number of peers which have been registered.
258
267
259
- .. method :: ESPNow.get_peers()
268
+ .. method :: ESPNow.get_peers() (ESP32 only)
260
269
261
270
Return the "peer info" parameters for all the registered peers (as a tuple
262
271
of tuples).
263
272
264
- .. method :: ESPNow.mod_peer(mac, lmk, [channel], [ifidx], [encrypt])
265
- ESPNow.mod_peer(mac, 'param'=value, ...)
273
+ .. method :: ESPNow.mod_peer(mac, lmk, [channel], [ifidx], [encrypt]) (ESP32 only)
274
+ ESPNow.mod_peer(mac, 'param'=value, ...) (ESP32 only)
266
275
267
276
Modify the parameters of the peer associated with the provided ``mac ``
268
277
address. Parameters may be provided as positional or keyword arguments.
@@ -274,6 +283,8 @@ The Esspresif ESP-Now software requires that other devices (peers) must be
274
283
Stream IO interface
275
284
-------------------
276
285
286
+ **Note **: ESP32 only
287
+
277
288
**Note **: The ESPNow buffer packet format is not yet fully documented. It
278
289
will be supported by a python support module for reading and sending ESPNow
279
290
message packets through the ``stream `` interface.
@@ -315,6 +326,8 @@ may wait on received events.
315
326
Supporting ``uasyncio ``
316
327
-----------------------
317
328
329
+ **Note **: ESP32 only
330
+
318
331
`ESPNow ` uses the ``stream `` io interface to support the micropython
319
332
``uasyncio `` module for asynchronous IO. A ``StreamReader `` class may be
320
333
constructed from an ESPNow object and used to support async IO. Eg::
@@ -330,6 +343,8 @@ constructed from an ESPNow object and used to support async IO. Eg::
330
343
Constants
331
344
---------
332
345
346
+ **Note **: ESP32 only
347
+
333
348
.. data :: espnow.MAX_DATA_LEN (=250)
334
349
espnow.KEY_LEN (=16)
335
350
espnow.MAX_TOTAL_PEER_NUM (=20)
0 commit comments