ESP8266_RTOS_SDK v1.4.0

- Main Page
- Modules
- Data Structures
- Files

- File List

espnow.h
1 /*
2 * ESPRSSIF MIT License
3 *
4 * Copyright (c) 2015 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
5 *
6 * Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP8266 only, in which case,
7 * it is free of charge, to any person obtaining a copy of this software and associated
8 * documentation files (the "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the Software is furnished
11 * to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all copies or
14 * substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 *
23 */
24
25 #ifndef __ESPNOW_H__
26 #define __ESPNOW_H__
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
56 enum esp_now_role {
57 ESP_NOW_ROLE_IDLE = 0,
58 ESP_NOW_ROLE_CONTROLLER,
59 ESP_NOW_ROLE_SLAVE,
60 ESP_NOW_ROLE_MAX,
61 };
62
75 typedef void (*esp_now_recv_cb_t)(uint8 *mac_addr, uint8 *data, uint8 len);
76
88 typedef void (*esp_now_send_cb_t)(uint8 *mac_addr, uint8 status);
89
98 sint32 esp_now_init(void);
99
108 sint32 esp_now_deinit(void);
109
118 sint32 esp_now_register_send_cb(esp_now_send_cb_t cb);
119
128 sint32 esp_now_unregister_send_cb(void);
129
138 sint32 esp_now_register_recv_cb(esp_now_recv_cb_t cb);
139
148 sint32 esp_now_unregister_recv_cb(void);
149
162 sint32 esp_now_send(uint8 *da, uint8 *data, uint8 len);
163
176 sint32 esp_now_add_peer(uint8 *mac_addr, uint8 role, uint8 channel, uint8 *key, uint8 key_len);
177
186 sint32 esp_now_del_peer(uint8 *mac_addr);
187
196 sint32 esp_now_set_self_role(uint8 role);
197
206 sint32 esp_now_get_self_role(void);
207
218 sint32 esp_now_set_peer_role(uint8 *mac_addr, uint8 role);
219
229 sint32 esp_now_get_peer_role(uint8 *mac_addr);
230
244 sint32 esp_now_set_peer_channel(uint8 *mac_addr, uint8 channel);
245
256 sint32 esp_now_get_peer_channel(uint8 *mac_addr);
257
271 sint32 esp_now_set_peer_key(uint8 *mac_addr, uint8 *key, uint8 key_len);
272
286 sint32 esp_now_get_peer_key(uint8 *mac_addr, uint8 *key, uint8 *key_len);
287
304 uint8 *esp_now_fetch_peer(bool restart);
305
315 sint32 esp_now_is_peer_exist(uint8 *mac_addr);
316
327 sint32 esp_now_get_cnt_info(uint8 *all_cnt, uint8 *encrypt_cnt);
328
341 sint32 esp_now_set_kok(uint8 *key, uint8 len);
342
347 #ifdef __cplusplus
348 }
349 #endif
350
351 #endif
esp_now_set_peer_role
sint32 esp_now_set_peer_role(uint8 *mac_addr, uint8 role)
Set ESP-NOW role for a target device. If it is set multiple times, new role will cover the old one...
esp_now_del_peer
sint32 esp_now_del_peer(uint8 *mac_addr)
Delete an ESP-NOW peer, delete MAC address of the device from ESP-NOW MAC list.
esp_now_get_peer_role
sint32 esp_now_get_peer_role(uint8 *mac_addr)
Get ESP-NOW role of a target device.
esp_now_send_cb_t
void(* esp_now_send_cb_t)(uint8 *mac_addr, uint8 status)
ESP-NOW send callback.
Definition: espnow.h:88
esp_now_get_cnt_info
sint32 esp_now_get_cnt_info(uint8 *all_cnt, uint8 *encrypt_cnt)
Get the total number of ESP-NOW devices which are associated, and the number count of encrypted devic...
esp_now_register_send_cb
sint32 esp_now_register_send_cb(esp_now_send_cb_t cb)
Register ESP-NOW send callback.
esp_now_register_recv_cb
sint32 esp_now_register_recv_cb(esp_now_recv_cb_t cb)
Register ESP-NOW receive callback.
esp_now_set_peer_channel
sint32 esp_now_set_peer_channel(uint8 *mac_addr, uint8 channel)
Record channel information of a ESP-NOW device.
esp_now_set_self_role
sint32 esp_now_set_self_role(uint8 role)
Set ESP-NOW role of device itself.
esp_now_unregister_send_cb
sint32 esp_now_unregister_send_cb(void)
Unregister ESP-NOW send callback.
esp_now_init
sint32 esp_now_init(void)
ESP-NOW initialization.
esp_now_fetch_peer
uint8 * esp_now_fetch_peer(bool restart)
Get MAC address of ESP-NOW device.
esp_now_set_peer_key
sint32 esp_now_set_peer_key(uint8 *mac_addr, uint8 *key, uint8 key_len)
Set ESP-NOW key for a target device.
esp_now_is_peer_exist
sint32 esp_now_is_peer_exist(uint8 *mac_addr)
Check if target device exists or not.
esp_now_add_peer
sint32 esp_now_add_peer(uint8 *mac_addr, uint8 role, uint8 channel, uint8 *key, uint8 key_len)
Add an ESP-NOW peer, store MAC address of target device into ESP-NOW MAC list.
esp_now_deinit
sint32 esp_now_deinit(void)
Deinitialize ESP-NOW.
esp_now_get_peer_key
sint32 esp_now_get_peer_key(uint8 *mac_addr, uint8 *key, uint8 *key_len)
Get ESP-NOW key of a target device.
esp_now_get_self_role
sint32 esp_now_get_self_role(void)
Get ESP-NOW role of device itself.
esp_now_unregister_recv_cb
sint32 esp_now_unregister_recv_cb(void)
Unregister ESP-NOW receive callback.
esp_now_recv_cb_t
void(* esp_now_recv_cb_t)(uint8 *mac_addr, uint8 *data, uint8 len)
ESP-NOW send callback.
Definition: espnow.h:75
esp_now_send
sint32 esp_now_send(uint8 *da, uint8 *data, uint8 len)
Send ESP-NOW packet.
esp_now_get_peer_channel
sint32 esp_now_get_peer_channel(uint8 *mac_addr)
Get channel information of a ESP-NOW device.
esp_now_set_kok
sint32 esp_now_set_kok(uint8 *key, uint8 len)
Set the encrypt key of communication key.