mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
test wifi sacn on linux
This commit is contained in:
parent
ecd12f75a1
commit
262bc09f1e
6
examples/network/network_scan.py
Normal file
6
examples/network/network_scan.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import network
|
||||||
|
|
||||||
|
wlan = network.WLAN(network.STA_IF)
|
||||||
|
wlan.active(True)
|
||||||
|
wlan.scan()
|
||||||
|
wlan.close()
|
@ -118,10 +118,7 @@ static const int _pika_hal_cmd_arg_cnt[] = {
|
|||||||
(sizeof _pika_hal_cmd_arg_cnt / sizeof _pika_hal_cmd_arg_cnt[0])
|
(sizeof _pika_hal_cmd_arg_cnt / sizeof _pika_hal_cmd_arg_cnt[0])
|
||||||
|
|
||||||
static int _pika_hal_get_arg_cnt(PIKA_HAL_IOCTL_CMD cmd) {
|
static int _pika_hal_get_arg_cnt(PIKA_HAL_IOCTL_CMD cmd) {
|
||||||
if (cmd >= _PIKA_HAL_CMD_ARG_CNT_MAX) {
|
return _pika_hal_cmd_arg_cnt[PIKA_HAL_IOCTL_CONFIG];
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return _pika_hal_cmd_arg_cnt[cmd];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int _pika_hal_ioctl_merge_config(pika_dev* dev, void* config_in) {
|
int _pika_hal_ioctl_merge_config(pika_dev* dev, void* config_in) {
|
||||||
@ -144,18 +141,26 @@ int pika_hal_ioctl(pika_dev* dev, PIKA_HAL_IOCTL_CMD cmd, ...) {
|
|||||||
if (impl->ioctl == NULL) {
|
if (impl->ioctl == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
void* config_in = NULL;
|
void* arg_in = NULL;
|
||||||
if (cmd != 0) {
|
if (cmd != 0) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, cmd);
|
va_start(args, cmd);
|
||||||
config_in = va_arg(args, void*);
|
arg_in = va_arg(args, void*);
|
||||||
ret = _pika_hal_ioctl_merge_config(dev, config_in);
|
if (cmd_origin == PIKA_HAL_IOCTL_CONFIG) {
|
||||||
|
ret = _pika_hal_ioctl_merge_config(dev, arg_in);
|
||||||
|
} else {
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
va_end(args);
|
va_end(args);
|
||||||
if (0 != ret) {
|
if (0 != ret) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret = impl->ioctl(dev, cmd_origin, dev->ioctl_config);
|
if (cmd_origin == PIKA_HAL_IOCTL_CONFIG) {
|
||||||
|
ret = impl->ioctl(dev, cmd_origin, dev->ioctl_config);
|
||||||
|
} else {
|
||||||
|
ret = impl->ioctl(dev, cmd_origin, arg_in);
|
||||||
|
}
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
if (cmd_origin == PIKA_HAL_IOCTL_ENABLE) {
|
if (cmd_origin == PIKA_HAL_IOCTL_ENABLE) {
|
||||||
dev->is_enabled = 1;
|
dev->is_enabled = 1;
|
||||||
|
@ -86,7 +86,9 @@
|
|||||||
int pika_hal_platform_##dev_name##_ioctl_enable(pika_dev* dev); \
|
int pika_hal_platform_##dev_name##_ioctl_enable(pika_dev* dev); \
|
||||||
int pika_hal_platform_##dev_name##_ioctl_disable(pika_dev* dev); \
|
int pika_hal_platform_##dev_name##_ioctl_disable(pika_dev* dev); \
|
||||||
int pika_hal_platform_##dev_name##_ioctl_config( \
|
int pika_hal_platform_##dev_name##_ioctl_config( \
|
||||||
pika_dev* dev, pika_hal_##dev_name##_config* cfg);
|
pika_dev* dev, pika_hal_##dev_name##_config* cfg); \
|
||||||
|
int pika_hal_platform_##dev_name##_ioctl_others( \
|
||||||
|
pika_dev* dev, PIKA_HAL_IOCTL_CMD cmd, void* arg);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PIKA_HAL_TABLE_DEV_CONFIG_SIZE)
|
#if defined(PIKA_HAL_TABLE_DEV_CONFIG_SIZE)
|
||||||
|
@ -37,5 +37,7 @@ class WLAN:
|
|||||||
|
|
||||||
def scan(self) -> list: ...
|
def scan(self) -> list: ...
|
||||||
|
|
||||||
|
def close(self): ...
|
||||||
|
|
||||||
|
|
||||||
def __init__(): ...
|
def __init__(): ...
|
||||||
|
@ -209,3 +209,11 @@ PikaObj* _network_WLAN_scan(PikaObj* self) {
|
|||||||
pika_platform_free(result);
|
pika_platform_free(result);
|
||||||
return scan_list;
|
return scan_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _network_WLAN_close(PikaObj* self) {
|
||||||
|
pika_dev* hal_wifi = obj_getPtr(self, "hal_wifi");
|
||||||
|
if (hal_wifi == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pika_hal_close(hal_wifi);
|
||||||
|
}
|
||||||
|
@ -37,5 +37,7 @@ class WLAN:
|
|||||||
|
|
||||||
def scan(self) -> list: ...
|
def scan(self) -> list: ...
|
||||||
|
|
||||||
|
def close(self): ...
|
||||||
|
|
||||||
|
|
||||||
def __init__(): ...
|
def __init__(): ...
|
||||||
|
@ -118,10 +118,7 @@ static const int _pika_hal_cmd_arg_cnt[] = {
|
|||||||
(sizeof _pika_hal_cmd_arg_cnt / sizeof _pika_hal_cmd_arg_cnt[0])
|
(sizeof _pika_hal_cmd_arg_cnt / sizeof _pika_hal_cmd_arg_cnt[0])
|
||||||
|
|
||||||
static int _pika_hal_get_arg_cnt(PIKA_HAL_IOCTL_CMD cmd) {
|
static int _pika_hal_get_arg_cnt(PIKA_HAL_IOCTL_CMD cmd) {
|
||||||
if (cmd >= _PIKA_HAL_CMD_ARG_CNT_MAX) {
|
return _pika_hal_cmd_arg_cnt[PIKA_HAL_IOCTL_CONFIG];
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return _pika_hal_cmd_arg_cnt[cmd];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int _pika_hal_ioctl_merge_config(pika_dev* dev, void* config_in) {
|
int _pika_hal_ioctl_merge_config(pika_dev* dev, void* config_in) {
|
||||||
@ -144,18 +141,26 @@ int pika_hal_ioctl(pika_dev* dev, PIKA_HAL_IOCTL_CMD cmd, ...) {
|
|||||||
if (impl->ioctl == NULL) {
|
if (impl->ioctl == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
void* config_in = NULL;
|
void* arg_in = NULL;
|
||||||
if (cmd != 0) {
|
if (cmd != 0) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, cmd);
|
va_start(args, cmd);
|
||||||
config_in = va_arg(args, void*);
|
arg_in = va_arg(args, void*);
|
||||||
ret = _pika_hal_ioctl_merge_config(dev, config_in);
|
if (cmd_origin == PIKA_HAL_IOCTL_CONFIG) {
|
||||||
|
ret = _pika_hal_ioctl_merge_config(dev, arg_in);
|
||||||
|
} else {
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
va_end(args);
|
va_end(args);
|
||||||
if (0 != ret) {
|
if (0 != ret) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret = impl->ioctl(dev, cmd_origin, dev->ioctl_config);
|
if (cmd_origin == PIKA_HAL_IOCTL_CONFIG) {
|
||||||
|
ret = impl->ioctl(dev, cmd_origin, dev->ioctl_config);
|
||||||
|
} else {
|
||||||
|
ret = impl->ioctl(dev, cmd_origin, arg_in);
|
||||||
|
}
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
if (cmd_origin == PIKA_HAL_IOCTL_ENABLE) {
|
if (cmd_origin == PIKA_HAL_IOCTL_ENABLE) {
|
||||||
dev->is_enabled = 1;
|
dev->is_enabled = 1;
|
||||||
|
@ -86,7 +86,9 @@
|
|||||||
int pika_hal_platform_##dev_name##_ioctl_enable(pika_dev* dev); \
|
int pika_hal_platform_##dev_name##_ioctl_enable(pika_dev* dev); \
|
||||||
int pika_hal_platform_##dev_name##_ioctl_disable(pika_dev* dev); \
|
int pika_hal_platform_##dev_name##_ioctl_disable(pika_dev* dev); \
|
||||||
int pika_hal_platform_##dev_name##_ioctl_config( \
|
int pika_hal_platform_##dev_name##_ioctl_config( \
|
||||||
pika_dev* dev, pika_hal_##dev_name##_config* cfg);
|
pika_dev* dev, pika_hal_##dev_name##_config* cfg); \
|
||||||
|
int pika_hal_platform_##dev_name##_ioctl_others( \
|
||||||
|
pika_dev* dev, PIKA_HAL_IOCTL_CMD cmd, void* arg);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PIKA_HAL_TABLE_DEV_CONFIG_SIZE)
|
#if defined(PIKA_HAL_TABLE_DEV_CONFIG_SIZE)
|
||||||
|
@ -209,3 +209,11 @@ PikaObj* _network_WLAN_scan(PikaObj* self) {
|
|||||||
pika_platform_free(result);
|
pika_platform_free(result);
|
||||||
return scan_list;
|
return scan_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _network_WLAN_close(PikaObj* self) {
|
||||||
|
pika_dev* hal_wifi = obj_getPtr(self, "hal_wifi");
|
||||||
|
if (hal_wifi == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pika_hal_close(hal_wifi);
|
||||||
|
}
|
||||||
|
6
test/python/network/network_scan.py
Normal file
6
test/python/network/network_scan.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import network
|
||||||
|
|
||||||
|
wlan = network.WLAN(network.STA_IF)
|
||||||
|
wlan.active(True)
|
||||||
|
wlan.scan()
|
||||||
|
wlan.close()
|
Loading…
x
Reference in New Issue
Block a user