ESP-NOW User Guide Version 1.0 Copyright 2016

Similar documents
Simple-Pair User Guide

Jump Test of ESP8266 s Secondary Bootloader (V1.6+)

ESP32 BT&BLE Dual-mode Bluetooth. Version 1.0 Copyright 2018

Smart Plug User Guide

ESP8266 Application Note Firmware Download Protocol

ESP8266 AT Command Examples

ESP8266 FOTA Guide Version 1.7 Copyright 2016

Manufacturing Instruction

ESP8266 AT Command Examples

ESP8266 SSL User Manual

ECO and Workarounds for Bugs in ESP32

Espressif IOT Demo. Smart Light/Plug/Sensor. Version 1.0.1

Geolocating with ESP8266

ESP8266 AT Command Examples

DISTRIBUTED BY TEXIM EUROPE. ESP32-DevKitC Getting Started Guide

ECO and Workarounds for Bugs in ESP32

ESP8266 Quick Start Guide

ESP8266 Quick Start Guide

ESP8266 Flash RW Operation

Gen-Z Identifiers September Copyright 2016 by Gen-Z. All rights reserved.

Enhanced Serial Peripheral Interface (espi) ECN

Ai-Thinker. ESP-12S Datasheet. Version V0. Copyright 2018 ESP-12S WIFI MODULE V0. Shenzhen Ai-Thinker Technology Co., Ltd All Rights Reserved

ESP8266 Non-OS SDK IoT_Demo Guide

Ai-Thinker. ESP-01F Datasheet. Version V1 Copyright Copyright 2018 Shenzhen Ai-Thinker Technology Co., Ltd All Rights Reserved

ESP-01 WiFi Module Version1.0

STSW-BNRG-Mesh. Mesh over Bluetooth low energy. Features. Description. Applications

ESP-WROVER-KIT Getting Started Guide

Bluetooth PC Card Transport Layer

PCI Express Link/Transaction Test Methodology

ESP32-SOLO-1 OEM Installation Manual

IEEE1588 Frequently Asked Questions (FAQs)

STSW-BNRGUI. BlueNRG GUI SW package. Data brief. Features. Description

KW41Z IEEE and BLE Coexistence Performance

Enhanced Serial Peripheral Interface (espi)

SAMSUNG ELECTRONICS RESERVES THE RIGHT TO CHANGE PRODUCTS, INFORMATION AND SPECIFICATIONS WITHOUT NOTICE. Products and specifications discussed

Intel Platform Innovation Framework for EFI SMBus Host Controller Protocol Specification. Version 0.9 April 1, 2004

Macrotron Systems, Inc. Flash Media Products. Part Number Family: 2.5 PATA (IDE) SSD (High Performance Series) PA25SMXXXXXMXXMX

AN4696 Application note

LMX9838 Cable Replacement

Embedded Simply Blue Application Note

Messaging Overview. Introduction. Gen-Z Messaging

Document Revision 1.0 September 16, 1998 Intel Hewlett-Packard NEC Dell

Native route discovery algorithm

STSW-BLUENRG1-DK. BlueNRG-1, BlueNRG-2 DK SW package

Intel Server Board S2600CW2S

[MS-WFDAA]: Intellectual Property Rights Notice for Open Specifications Documentation

UM2361. Getting started with the ST BlueNRG-Mesh ios application. User manual. Introduction

USB2 Debug Device A Functional Device Specification

Intel Server Board S2600STB

STM32-MP3NL/DEC. STM32 audio engine MP3 decoder library. Description. Features

TCG Physical Security Interoperability Alliance IP Video Use Case 002 (PSI-UC-IPV002) Specification Version 1.0 Revision 0.2

STLC2500D. Bluetooth V2.1 "Lisbon" + EDR. Features. Description

DR CONTROL. Contents. Trademarks

Intel Cluster Ready Allowed Hardware Variances

INTEL PERCEPTUAL COMPUTING SDK. How To Use the Privacy Notification Tool

UM2330 User manual. ST8500 boot. Introduction

CHANGING THE MODES OF MOD-WIFI-ESP8266-DEV

TAS1020 Application Notes

The BlueNRG-1, BlueNRG-2 BLE OTA (over-the-air) firmware upgrade

[MS-NCT-Diff]: Network Cost Transfer Protocol. Intellectual Property Rights Notice for Open Specifications Documentation

AN4113 Application note

Intel Desktop Board DZ68DB

UM2379. The BlueNRG-1, BlueNRG-2 radio driver. User manual. Introduction

Interoperability Specification for ICCs and Personal Computer Systems

ESP8266 AT. Version 1.3

ComAPI+ API Documentation

How to configure the BlueNRG-1 and BlueNRG-2 devices in network coprocessor mode. Main components Bluetooth Low Energy wireless system-on-chip

SafeNet Authentication Client

UM0401 User manual. User manual for eight bit port expander STMPE801 demonstration board. Introduction

Technical Note: NVMe Simple Management Interface

Intel Software Guard Extensions (SGX) SW Development Guidance for Potential Bounds Check Bypass (CVE ) Side Channel Exploits.

Changing your Driver Options with Radeon Pro Settings. Quick Start User Guide v2.1

[MS-NCT-Diff]: Network Cost Transfer Protocol. Intellectual Property Rights Notice for Open Specifications Documentation

APPLICATION NOTE. Atmel AVR2131: Lightweight Mesh Getting Started Guide. Atmel MCU Wireless. Features. Description

Intel Cache Acceleration Software for Windows* Workstation

Intel Cloud Builder Guide: Cloud Design and Deployment on Intel Platforms

DCMI Data Center Manageability Interface Specification v1.0, Revision 1.0. Addenda, Errata, and Clarifications

AN4869 Application note

VP-UML Installation Guide

Network+ Guide to Networks, 6 th Edition. Chapter 2 Solutions

FOR TCG ACPI Specification

AMD Radeon ProRender plug-in for Unreal Engine. Installation Guide

SonicWall Mobile Connect for Chrome OS

TCG Compliance TNC IF-MAP Metadata for Network Security Compliance Test Plan

SEP Technology White Paper

Understanding Windows To Go

Intel Server Board S2400SC

Intel Server Board S1200V3RPO Intel Server System R1208RPOSHORSPP

ST21NFCB. Near field communication controller. Features. RF communications. Hardware features. Communication interfaces. Electrical characteristics

APPLICATION NOTE. Scope. Reference Documents. Software Ethernet Bridge on SAMA5D3/D4. Atmel SMART SAMA5D3/D4 Series

Evolving Small Cells. Udayan Mukherjee Senior Principal Engineer and Director (Wireless Infrastructure)

SafeNet MobilePKI for BlackBerry V1.2. Administration Guide

Changing your Driver Options with Radeon Pro Settings. Quick Start User Guide v3.0

This user guide describes how to run the Atmel ATWINC3400 Bluetooth Low Energy (BLE) Provisioning demo from out-of-box conditions.

Intel Server Board S1200V3RPO Intel Server System R1208RPOSHORSPP

Metalogix Essentials for Office Creating a Backup

Intel Stereo 3D SDK Developer s Guide. Alpha Release

LED Manager for Intel NUC

SafeNet Authentication Client

RN0046 Release note. 1 Introduction. SimpleMAC library for STM32W108xx kits. About this release note

Transcription:

ESP-NOW User Guide Version 1.0 Copyright 2016

About This Guide This document introduces ESP-NOW technology developed by Espressif. The document focuses on ESP-NOW features, how to use it and the demo code. The structure is as below: Chapter Title Subject Chapter 1 ESP-NOW Introduction Introduction on ESP-NOW technology and features. Chapter 2 ESP-NOW Usage Guide Description of the device information; guidance on how to use ESP-NOW. Chapter 3 Sample Code Provision of the sample code of ESP-NOW. Release Notes Date Version Release notes V1.0 First release.

Table of Contents 1. ESP-NOW Introduction... 1 1.1. Overview... 1 1.2. Features... 1 2. ESP-NOW Usage Guide... 2 2.1. Information Description... 2 2.2. Usage Process... 3 3. Sample Code... 5

! 1. ESP-NOW Introduction 1. ESP-NOW Introduction 1.1. Overview ESP-NOW is a fast, connectionless communication technology featuring short packet transmission. ESP-NOW is ideal for smart lights, remote control devices, sensors and other applications. ESP-NOW applies IEEE802.11 Action Vendor frame technology, along with the IE function developed by Espressif and CCMP encryption technology, realizing a secure, connectionless communication solution. 1.2. Features ESP-NOW supports the following features: Encrypted and unencrypted unicast communication. Mixed encrypted and unencrypted peer devices. Up to 250 byte payload can be carried. Send callback function can be set to inform the application layer of transmission success or failure. ESP-NOW features also have the following limitations: Broadcast is not supported. Limited encrypted peers. 10 encrypted peers at most are supported in Station mode, 6 at most in SoftAP or SoftAP + Station mode. Multiple unencrypted peers are supported, however, together with encrypted peers, the sum should be less than 20. Payload is limited to 250 bytes. Espressif! 1/7

! 2. ESP-NOW Usage Guide 2. ESP-NOW Usage Guide 2.1. Information Description A linked list of the local device and the peer will be maintained in a low level layer of ESP- NOW. This information is used to send and receive data. ESP-NOW maintains the essential information such as MAC address and key in the lower layer for the peer. Besides, ESP- NOW also stores the frequently used data for the application layer to avoid the overhead of secondary maintenance of the linked list. The information involved includes: In the local device: - PMK - Role In the peer (including frequently used information and other user-defined information): - Key - MAC Address - Role - Channel For detailed description of the information, please refer to Table 2-1. Table 2-1. Information Description Device Informa tion Value / length Description Note PMK Length: 16 bytes Primary Master Key, i.e., KOK in API, used to encrypt the Key of the peer. The system will maintain a default PMK, therefore, no configuration is required. If needed, please make sure it is the same as that of the local device. The local device's Role will define the transmitting interface (SoftAP interface or Station interface) of ESP-NOW. Local device Role IDLE CONTROLLER SLAVE COMBO The device's role. IDLE: undefined role CONTROLLER: controller SLAVE: slave COMBO: double role as controller and slave IDLE: data transmission is not allowed. CONTROLLER: priority is given to Sation interface SLAVE: priority is given to SoftAP interface COMBO: priority is given to SoftAP interface Station interface for Station only mode and SoftAP interface for SoftAP only mode. Espressif! 2/7

2. ESP-NOW Usage Guide! Device Informa tion Value / length Description Note Key Length: 16 bytes Used to encrypt the payload Key during communication with the specified peer. Mac Address Length: 6 bytes MAC address of the peer. MAC address must be the same as the sending address. For example, if the packet is sent from the Station interface, the MAC address should be the same as the Station address. The device's role. Peer Role IDLE CONTROLLER SLAVE COMBO IDLE: undefined role CONTROLLER: controller SLAVE: slave COMBO: double role as controller and slave The peer's Role does not affect any function, but only stores the Role information for the application layer. Channel Value: 0 ~ 255 The channel in which the local device and the peer communicate. Channel does not affect any function, but only stores the Channel information for the application layer. The value is defined by the application layer. For example, 0 can mean that the Channel is not defined; 1 ~ 14 valid Channel; and others specified functions. 2.2. Usage Process 1. Set sending callback function Sending callback function can be used to tell transmission success or failure, e.g., if the information in the MAC sublayer is conveyed successfully. Please note the following points carefully when using sending callback function: For unicast communication: If the application layer does not receive the packet but the callback function returns success, the reasons may be: - attacks from rogue device - encrypted Key setting mistake - packet loss in the application layer Note: Handshake is must for guaranteed transmission success rate. If the application layer has received the packet but the callback function returns failure, the reasons may be: Espressif! 3/7

2. ESP-NOW Usage Guide! - The channel is busy and ACK is not received. Note: The application layer may retransmit the packet and the receiving end needs to check the retransmitted packet. For multicast communication (broadcast communication also included): If the callback function returns success, it means the packet has been sent successfully. If the callback function returns failure, it means the packet has not been sent successfully. 2. Set receiving callback function Receiving callback function can be used to inform the application layer as the packet sent by the peer is received. The receiving callback function will return the MAC address of the peer and the payload of the packet. 3. If the Key needs to be encrypted, the API that set PMK (KOK) can be called for configuration. If PMK is not configured, then the default PMK will be used. 4. Select the communication interface for the devices. Usually, Station interface is set for CONTROLLER, SoftAP interface for SLAVE AND COMBO. Note: It is not recommended to send packets to a device in Station only mode, for the device may be in sleep. 5. Select the same Key for the devices. Call the function to add peers. Please refer to Table 2-1 for details. 6. Call the sending function to return payload. If the sending function returns the specified MAC address, then it will be sent to the specified device. If the sending function returns NULL, then it will be sent to all the peers, which may result in transmission failure or delay due to network congestion. Espressif! 4/7

! 3. Sample Code 3. Sample Code Note: For more information on ESP-NOW APIs, please refer to ESP8266 Non-OS SDK API Guide. void ICACHE_FLASH_ATTR simple_cb(u8 *macaddr, u8 *data, u8 len) { int i; u8 ack_buf[16]; u8 recv_buf[17]; os_printf("now from["); for (i = 0; i < 6; i++) os_printf("%02x, ", macaddr[i]); os_printf(" len: %d]:", len); os_bzero(recv_buf, 17); os_memcpy(recv_buf, data, len<17?len:16); if (os_strncmp(data, "ACK", 3) == 0) return; } os_sprintf(ack_buf, "ACK[%08x]", ack_count++); esp_now_send(macaddr, ack_buf, os_strlen(ack_buf)); void user_init(void) { u8 key[16]= {0x33, 0x44, 0x33, 0x44, 0x33, 0x44, 0x33, 0x44, 0x33, 0x44, 0x33, 0x44, 0x33, 0x44, 0x33, 0x44}; u8 da1[6] = {0x18, 0xfe, 0x34, 0x97, 0xd5, 0xb1}; u8 da2[6] = {0x1a, 0xfe, 0x34, 0x97, 0xd5, 0xb1}; if (esp_now_init()==0) { Espressif! 5/7

3. Sample Code! os_printf("esp_now init ok\n"); esp_now_register_recv_cb(simple_cb); esp_now_set_self_role(1); esp_now_add_peer(da1, 1, key, 16); esp_now_add_peer(da2, 2, key, 16) } else { } os_printf("esp_now init failed\n"); } void ICACHE_FLASH_ATTR demo_send(u8 *mac_addr, u8 *data, u8 len) { esp_now_send(null, data, len);/* the demo will send to two devices which added by esp_now_add_peer() */ //esp_now_send(mac_addr, data, len); /* send to the specified mac_addr */ } Espressif! 6/7

Espressif IOT Team www.espressif.com Disclaimer and Copyright Notice Information in this document, including URL references, is subject to change without notice. THIS DOCUMENT IS PROVIDED AS IS WITH NO WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY, NON-INFRINGEMENT, FITNESS FOR ANY PARTICULAR PURPOSE, OR ANY WARRANTY OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. All liability, including liability for infringement of any proprietary rights, relating to use of information in this document is disclaimed. No licenses express or implied, by estoppel or otherwise, to any intellectual property rights are granted herein. The Wi-Fi Alliance Member logo is a trademark of the Wi-Fi Alliance. The Bluetooth logo is a registered trademark of Bluetooth SIG. All trade names, trademarks and registered trademarks mentioned in this document are property of their respective owners, and are hereby acknowledged. Copyright 2016 Espressif Inc. All rights reserved.