2023-02-01 07:24:51 -05:00
|
|
|
/*
|
|
|
|
* This file is part of the Micro Python project, http://micropython.org/
|
|
|
|
*
|
|
|
|
* The MIT License (MIT)
|
|
|
|
*
|
|
|
|
* Copyright (c) 2023 MicroDev
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2023-02-02 11:04:24 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "py/obj.h"
|
2023-02-01 07:24:51 -05:00
|
|
|
#include "py/ringbuf.h"
|
|
|
|
|
2023-02-02 11:04:24 -05:00
|
|
|
#include "bindings/espnow/Peers.h"
|
|
|
|
|
2023-02-01 07:24:51 -05:00
|
|
|
#include "esp_wifi.h"
|
|
|
|
|
|
|
|
typedef struct _espnow_obj_t {
|
|
|
|
mp_obj_base_t base;
|
2023-03-09 01:34:50 -05:00
|
|
|
ringbuf_t *recv_buffer;
|
|
|
|
size_t recv_buffer_size;
|
|
|
|
wifi_phy_rate_t phy_rate;
|
|
|
|
espnow_peers_obj_t *peers;
|
|
|
|
volatile size_t send_success;
|
|
|
|
volatile size_t send_failure;
|
|
|
|
volatile size_t read_success;
|
|
|
|
volatile size_t read_failure;
|
2023-02-01 07:24:51 -05:00
|
|
|
} espnow_obj_t;
|
|
|
|
|
|
|
|
extern void espnow_reset(void);
|
|
|
|
|
2023-02-03 14:33:33 -05:00
|
|
|
extern void common_hal_espnow_construct(espnow_obj_t *self, mp_int_t buffer_size, mp_int_t phy_rate);
|
2023-02-01 07:24:51 -05:00
|
|
|
extern void common_hal_espnow_init(espnow_obj_t *self);
|
|
|
|
extern void common_hal_espnow_deinit(espnow_obj_t *self);
|
|
|
|
extern bool common_hal_espnow_deinited(espnow_obj_t *self);
|
|
|
|
|
|
|
|
extern void common_hal_espnow_set_phy_rate(espnow_obj_t *self, mp_int_t value);
|
|
|
|
extern void common_hal_espnow_set_pmk(espnow_obj_t *self, const uint8_t *key);
|
|
|
|
|
2023-02-04 14:48:18 -05:00
|
|
|
extern mp_obj_t common_hal_espnow_send(espnow_obj_t *self, const mp_buffer_info_t *message, const uint8_t *mac);
|
2023-02-05 02:01:08 -05:00
|
|
|
extern mp_obj_t common_hal_espnow_read(espnow_obj_t *self);
|