Yilin Sun
7e1f11ab84
Signed-off-by: Yilin Sun <imi415@imi.moe> |
||
---|---|---|
include | ||
lib | ||
proto | ||
src | ||
.gitmodules | ||
CMakeLists.txt | ||
README.md |
README.md
ESP Nano Hosted
Introduction
This project is trying to interface with esp-hosted
firmware using a MCU-friendly method.
SPI Frame Format
- Each SPI transaction is fixed 1600 bytes
- Each transaction is prefixed by a 12-byte header, defined as follows:
struct esp_payload_header {
uint8_t if_type:4;
uint8_t if_num:4;
uint8_t flags;
uint16_t len;
uint16_t offset;
uint16_t checksum;
uint16_t seq_num;
uint8_t reserved2;
union {
uint8_t reserved3;
uint8_t hci_pkt_type;
uint8_t priv_pkt_type;
};
} __attribute__((packed));
- The
if_type
field is one of the following enum:
typedef enum {
ESP_STA_IF,
ESP_AP_IF,
ESP_SERIAL_IF,
ESP_HCI_IF,
ESP_PRIV_IF,
ESP_TEST_IF,
ESP_MAX_IF,
} ESP_INTERFACE_TYPE;
- Control requests and responses are handled through
ESP_SERIAL_IF
, which has the following TLV structure:
/*
* TLV (Type - Length - Value) structure is as follows:
* --------------------------------------------------------------------------------------------
* Endpoint Type | Endpoint Length | Endpoint Value | Data Type | Data Length | Data Value |
* --------------------------------------------------------------------------------------------
*
* Bytes used per field as follows:
* --------------------------------------------------------------------------------------------
* 1 | 2 | Endpoint length | 1 | 2 | Data length |
* --------------------------------------------------------------------------------------------
*/
/* For type fields: */
#define PROTO_PSER_TLV_T_EPNAME 0x01
#define PROTO_PSER_TLV_T_DATA 0x02
/* Some stupid constraints in the original code expects the length should be same... even they don't have to */
#define CTRL_EP_NAME_RESP "ctrlResp"
#define CTRL_EP_NAME_EVENT "ctrlEvnt"
- The control messages are encapsulated in protobuf, in the data field of the above TLV.
- For Host-to-ESP messages, the endpoint name
CTRL_EP_NAME_RESP
is used. - For ESP-to-Host messages, the endpoint name
CTRL_EP_NAME_EVENT
orCTRL_EP_NAME_RESP
are used.
Issues
- Only a subset of commands are implemented.
- Jumbo frames (larger than 1518 bytes) are not supported, since no
realloc
available. - Just hope ESP won't send some frame larger than that.
License
Not decided yet, please be patient. At least not before the project is usable.