add packet class
This commit is contained in:
parent
1099716986
commit
e2652f8aac
@ -433,6 +433,7 @@ SRC_COMMON_HAL_ALL = \
|
||||
watchdog/WatchDogMode.c \
|
||||
watchdog/WatchDogTimer.c \
|
||||
watchdog/__init__.c \
|
||||
wifi/Monitor.c \
|
||||
wifi/Network.c \
|
||||
wifi/Radio.c \
|
||||
wifi/ScannedNetworks.c \
|
||||
@ -475,6 +476,7 @@ $(filter $(SRC_PATTERNS), \
|
||||
paralleldisplay/ParallelBus.c \
|
||||
supervisor/RunReason.c \
|
||||
wifi/AuthMode.c \
|
||||
wifi/Packet.c \
|
||||
)
|
||||
|
||||
SRC_BINDINGS_ENUMS += \
|
||||
|
70
shared-bindings/wifi/Packet.c
Normal file
70
shared-bindings/wifi/Packet.c
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* This file is part of the Micro Python project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#include "py/enum.h"
|
||||
|
||||
#include "shared-bindings/wifi/Packet.h"
|
||||
|
||||
MAKE_ENUM_VALUE(wifi_packet_type, packet, CH, PACKET_CH);
|
||||
MAKE_ENUM_VALUE(wifi_packet_type, packet, LEN, PACKET_LEN);
|
||||
MAKE_ENUM_VALUE(wifi_packet_type, packet, RAW, PACKET_RAW);
|
||||
MAKE_ENUM_VALUE(wifi_packet_type, packet, RSSI, PACKET_RSSI);
|
||||
|
||||
//| class Packet:
|
||||
//| """The packet parameters."""
|
||||
//|
|
||||
//| CH: object
|
||||
//| """The packet's channel."""
|
||||
//|
|
||||
//| LEN: object
|
||||
//| """The packet's length."""
|
||||
//|
|
||||
//| RAW: object
|
||||
//| """The packet's payload."""
|
||||
//|
|
||||
//| RSSI: object
|
||||
//| """The packet's rssi."""
|
||||
//|
|
||||
MAKE_ENUM_MAP(wifi_packet) {
|
||||
MAKE_ENUM_MAP_ENTRY(packet, CH),
|
||||
MAKE_ENUM_MAP_ENTRY(packet, LEN),
|
||||
MAKE_ENUM_MAP_ENTRY(packet, RAW),
|
||||
MAKE_ENUM_MAP_ENTRY(packet, RSSI),
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(wifi_packet_locals_dict, wifi_packet_locals_table);
|
||||
|
||||
MAKE_PRINTER(wifi, wifi_packet);
|
||||
|
||||
const mp_obj_type_t wifi_packet_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_Packet,
|
||||
.print = wifi_packet_print,
|
||||
.locals_dict = (mp_obj_t)&wifi_packet_locals_dict,
|
||||
.flags = MP_TYPE_FLAG_EXTENDED,
|
||||
MP_TYPE_EXTENDED_FIELDS(
|
||||
.unary_op = mp_generic_unary_op,
|
||||
),
|
||||
};
|
41
shared-bindings/wifi/Packet.h
Normal file
41
shared-bindings/wifi/Packet.h
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* This file is part of the Micro Python project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_WIFI_PACKET_H
|
||||
#define MICROPY_INCLUDED_SHARED_BINDINGS_WIFI_PACKET_H
|
||||
|
||||
#include "py/enum.h"
|
||||
|
||||
typedef enum {
|
||||
PACKET_CH,
|
||||
PACKET_LEN,
|
||||
PACKET_RAW,
|
||||
PACKET_RSSI,
|
||||
} wifi_packet_t;
|
||||
|
||||
extern const mp_obj_type_t wifi_packet_type;
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_WIFI_PACKET_H
|
@ -27,9 +27,10 @@
|
||||
#include "py/objexcept.h"
|
||||
#include "py/runtime.h"
|
||||
#include "shared-bindings/wifi/__init__.h"
|
||||
#include "shared-bindings/wifi/AuthMode.h"
|
||||
#include "shared-bindings/wifi/Network.h"
|
||||
#include "shared-bindings/wifi/Radio.h"
|
||||
#include "shared-bindings/wifi/Network.h"
|
||||
#include "shared-bindings/wifi/AuthMode.h"
|
||||
#include "shared-bindings/wifi/Packet.h"
|
||||
|
||||
//| """
|
||||
//| The `wifi` module provides necessary low-level functionality for managing
|
||||
@ -51,16 +52,17 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(wifi___init___obj, wifi___init__);
|
||||
|
||||
STATIC const mp_rom_map_elem_t wifi_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_wifi) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_Radio), MP_ROM_PTR(&wifi_radio_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_Network), MP_ROM_PTR(&wifi_network_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_AuthMode), MP_ROM_PTR(&wifi_authmode_type) },
|
||||
|
||||
// Properties
|
||||
{ MP_ROM_QSTR(MP_QSTR_radio), MP_ROM_PTR(&common_hal_wifi_radio_obj) },
|
||||
|
||||
// Initialization
|
||||
{ MP_ROM_QSTR(MP_QSTR___init__), MP_ROM_PTR(&wifi___init___obj) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_Radio), MP_ROM_PTR(&wifi_radio_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_Network), MP_ROM_PTR(&wifi_network_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_AuthMode), MP_ROM_PTR(&wifi_authmode_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_Packet), MP_ROM_PTR(&wifi_packet_type) },
|
||||
|
||||
// Properties
|
||||
{ MP_ROM_QSTR(MP_QSTR_radio), MP_ROM_PTR(&common_hal_wifi_radio_obj) },
|
||||
};
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(wifi_module_globals, wifi_module_globals_table);
|
||||
|
Loading…
Reference in New Issue
Block a user