code stringlengths 1 1.05M | repo_name stringlengths 6 83 | path stringlengths 3 242 | language stringclasses 222
values | license stringclasses 20
values | size int64 1 1.05M |
|---|---|---|---|---|---|
/*
* Copyright (C) 2015-2019 Alibaba Group Holding Limited
*/
#include "module_mqtt.h"
#include "aiot_state_api.h"
#include "amp_platform.h"
#include "amp_task.h"
#include "aos_system.h"
#include "be_inl.h"
#include "py_defines.h"
#define MOD_STR "MQTT"
#define MQTT_TASK_YIELD_TIMEOUT 200
static ch... | YifuLiu/AliOS-Things | components/py_engine/modules/mqtt/module_mqtt.c | C | apache-2.0 | 10,382 |
/*
* Copyright (C) 2015-2019 Alibaba Group Holding Limited
*/
#include "stdint.h"
/**
* @brief subdev模块内部发生值得用户关注的状态变化时, 通知用户的事件类型
*/
typedef enum {
/**
* @brief 非法的应答报文
*/
MQTT_JSCALLBACK_INVALID_REF,
/**
* @brief 应答报文的id字段非法
*/
MQTT_JSCALLBACK_START_CLIENT_REF,
/**
*... | YifuLiu/AliOS-Things | components/py_engine/modules/mqtt/module_mqtt.h | C | apache-2.0 | 1,450 |
/*
* Copyright (C) 2015-2019 Alibaba Group Holding Limited
*/
#include "aiot_mqtt_api.h"
#include "aiot_state_api.h"
#include "aiot_sysdep_api.h"
#include "amp_platform.h"
#include "amp_task.h"
#include "aos/kv.h"
#include "aos_system.h"
#include "be_inl.h"
#include "module_mqtt.h"
#include "py_defines.h"
#define M... | YifuLiu/AliOS-Things | components/py_engine/modules/mqtt/module_mqtt_client.c | C | apache-2.0 | 10,356 |
#include "MQTTClient.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "py/builtin.h"
#include "py/mperrno.h"
#include "py/obj.h"
#include "py/runtime.h"
#include "ulog/ulog.h"
#define LOG_TAG "MQTT_CLIENT"
#define REQ_BUF_SIZE 2048
// static char mqtt_req_buf[REQ_BUF_SIZE];
// /* @brief ... | YifuLiu/AliOS-Things | components/py_engine/modules/mqtt/mqttclient.c | C | apache-2.0 | 10,351 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "py/builtin.h"
#include "py/mperrno.h"
#include "py/obj.h"
#include "py/runtime.h"
#include "py/stackctrl.h"
#include "ulog/ulog.h"
#if MICROPY_PY_BLECFG
#define LOG_TAG "bleNetconfig"
typedef enum {
BLECFG_WIFIINFO = 0x1,
BLECFG_DEVINFO ... | YifuLiu/AliOS-Things | components/py_engine/modules/netconfig/blecfg.c | C | apache-2.0 | 5,682 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "aos_network.h"
#include "py/builtin.h"
#include "py/mperrno.h"
#include "py/obj.h"
#include "py/runtime.h"
#include "py/stackctrl.h"
#include "aos_log.h"
#include "utility.h"
#include "aos/kernel.h"
#define LOG_TAG "mod_netmgr"
STATIC aos_wifi_man... | YifuLiu/AliOS-Things | components/py_engine/modules/netmgr/modnetmgr.c | C | apache-2.0 | 8,682 |
/*
* Copyright (C) 2015-2019 Alibaba Group Holding Limited
*/
#include <stdarg.h>
#include <string.h>
#include "aos_network.h"
#include "aos_system.h"
#include "be_inl.h"
#include "board_config.h"
#define MOD_STR "CELLULAR"
typedef struct {
int status;
int js_cb_ref;
} network_status_notify_param_t;
stat... | YifuLiu/AliOS-Things | components/py_engine/modules/network/cellular/module_cellular.c | C | apache-2.0 | 11,247 |
#include "httpclient.h"
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "aos/kernel.h"
#include "py/builtin.h"
#include "py/mperrno.h"
#include "py/obj.h"
#include "py/runtime.h"
#include "ulog/ulog.h"
#define LOG_TAG "HTTP_CLIENT"
#define REQ_BUF_SIZE 2048
static char re... | YifuLiu/AliOS-Things | components/py_engine/modules/network/http/aos/httpclient.c | C | apache-2.0 | 27,506 |
/*
* Copyright (C) 2015-2019 Alibaba Group Holding Limited
*/
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "amp_task.h"
#include "board_config.h"
#include "httpclient.h"
#include "py_defines.h"
#include "amp_list.h"
#include "cJSON.h"
#define MOD_STR "... | YifuLiu/AliOS-Things | components/py_engine/modules/network/http/aos/httputility.c | C | apache-2.0 | 15,369 |
/*
* Copyright (C) 2015-2019 Alibaba Group Holding Limited
*/
#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if MICROPY_PY_HTTP
#include "aos/kernel.h"
#include "cJSON.h"
#include "httpclient.h"
#include "py/builtin.h"
#include "py/mperrno.h"
#include "py/obj.h"
... | YifuLiu/AliOS-Things | components/py_engine/modules/network/http/aos/modhttp.c | C | apache-2.0 | 19,796 |
/*
* Copyright (C) 2015-2019 Alibaba Group Holding Limited
*/
#include <stdlib.h>
#include <string.h>
#if MICROPY_PY_HTTP
#include "esp_event.h"
#include "esp_http_client.h"
#include "esp_log.h"
#include "esp_netif.h"
#include "esp_system.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "hapy_... | YifuLiu/AliOS-Things | components/py_engine/modules/network/http/esp32/modhttp.c | C | apache-2.0 | 19,772 |
#ifndef _HAAS_HTTP_CLIENT_H
#define _HAAS_HTTP_CLIENT_H
#include <stdint.h>
#include "py/obj.h"
#define MAX_HTTP_RECV_BUFFER 512
#define MAX_HTTP_RESP_BUFFER 2048
#define HTTP_HEADER_SIZE 1024
#define HTTP_HEADER_COUNT 16
#define HTTP_DEFAULT_HEADER_NAME "content-type"
#define HTTP_DEFAULT_HE... | YifuLiu/AliOS-Things | components/py_engine/modules/network/http/hapy_http_client.h | C | apache-2.0 | 884 |
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* Development of the code in this file was sponsored by Microbric Pty Ltd
* and Mnemote Pty Ltd
*
* The MIT License (MIT)
*
* Copyright (c) 2016, 2017 Nick Moore @mnemote
* Copyright (c) 2017 "Eric Poulsen" <eric@zyxod.com>
*
* Perm... | YifuLiu/AliOS-Things | components/py_engine/modules/network/modnetwork.c | C | apache-2.0 | 26,503 |
#ifndef _MOD_NETWORK_H_
#define _MOD_NETWORK_H_
#include "lwip/ip_addr.h"
#define NETWORK_SSID_MAX_LEN (32)
#define NETWORK_PASSWD_MAX_LEN (64)
typedef struct network_wifi_info {
char ssid[NETWORK_SSID_MAX_LEN + 1];
char bssid[6];
int rssi;
} network_wifi_info_t;
typedef struct wifi_ap_info {
char... | YifuLiu/AliOS-Things | components/py_engine/modules/network/modnetwork.h | C | apache-2.0 | 822 |
#include <stdbool.h>
#include <string.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include "cJSON.h"
#include "dev_info.h"
#include "modnetwork.h"
#include "usb_s_uvc_ioctl.h"
#include "zbar.h"
int network_qrcode_scan(void *gray, int w, int h, char *ouput, int max_len)
{
int ret = -1, len = 0;
char *data =... | YifuLiu/AliOS-Things | components/py_engine/modules/network/qrcode.c | C | apache-2.0 | 2,928 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if MICROPY_PY_TCP
#include "py/builtin.h"
#include "py/mperrno.h"
#include "py/obj.h"
#include "py/runtime.h"
#include "ulog/ulog.h"
#define LOG_TAG "MOD_TCP"
// this is the actual C-structure for our new object
typedef struct {
// base represents some... | YifuLiu/AliOS-Things | components/py_engine/modules/network/tcp/modtcp.c | C | apache-2.0 | 3,180 |
/*
* Copyright (C) 2015-2019 Alibaba Group Holding Limited
*/
#include "amp_platform.h"
#include "amp_task.h"
#include "aos_system.h"
#include "aos_tcp.h"
#include "be_inl.h"
#include "board_config.h"
#include "py_defines.h"
#define MOD_STR "TCP"
#define MAX_TCP_RECV_LEN 256
#define MAX_TCP_RECV_TI... | YifuLiu/AliOS-Things | components/py_engine/modules/network/tcp/module_tcp.c | C | apache-2.0 | 13,352 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if MICROPY_PY_UDP
#include "py/builtin.h"
#include "py/mperrno.h"
#include "py/obj.h"
#include "py/runtime.h"
#include "ulog/ulog.h"
#define LOG_TAG "MOD_UDP"
// this is the actual C-structure for our new object
typedef struct {
// base represents some... | YifuLiu/AliOS-Things | components/py_engine/modules/network/udp/modudp.c | C | apache-2.0 | 3,963 |
/*
* Copyright (C) 2015-2019 Alibaba Group Holding Limited
*/
#include "amp_platform.h"
#include "amp_task.h"
#include "amp_utils.h"
#include "aos_system.h"
#include "aos_udp.h"
#include "be_inl.h"
#include "board_config.h"
#include "py_defines.h"
#ifndef INET_ADDRSTRLEN
#define INET_ADDRSTRLEN 16
#endif
#define M... | YifuLiu/AliOS-Things | components/py_engine/modules/network/udp/module_udp.c | C | apache-2.0 | 14,625 |
/*
* Copyright (C) 2015-2019 Alibaba Group Holding Limited
*/
#include <stdarg.h>
#include <string.h>
#if MICROPY_PY_CHANNEL_ENABLE
#include "board_config.h"
#include "py/builtin.h"
#include "py/obj.h"
#include "py/runtime.h"
#include "py/stackctrl.h"
#include "py_defines.h"
#define MOD_STR "ONLINE_UPGRADE"
exte... | YifuLiu/AliOS-Things | components/py_engine/modules/online_upgrade/modonline_upgrade.c | C | apache-2.0 | 1,434 |
#include "aliot_base64.h"
#include <stdint.h>
#include <stdlib.h>
static int8_t g_encodingTable[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
... | YifuLiu/AliOS-Things | components/py_engine/modules/oss/byhttp/aliot_base64.c | C | apache-2.0 | 3,760 |
#ifndef _ALIOT_COMMON_BASE64_H_
#define _ALIOT_COMMON_BASE64_H_
#include <stdint.h>
int32_t aliot_base64encode(const uint8_t *data, uint32_t inputLength, uint32_t outputLenMax, uint8_t *encodedData,
uint32_t *outputLength);
int32_t aliot_base64decode(const uint8_t *data, uint32_t inputLe... | YifuLiu/AliOS-Things | components/py_engine/modules/oss/byhttp/aliot_base64.h | C | apache-2.0 | 431 |
#include "aliot_hmac.h"
#include <string.h>
#include "aliot_sha1.h"
#define KEY_IOPAD_SIZE (64)
#define SHA1_DIGEST_SIZE (20)
void aliot_hmac_sha1(const char *msg, int msg_len, char *digest, const char *key, int key_len)
{
iot_sha1_context context;
unsigned char k_ipad[KEY_IOPAD_SIZE]; /* inner padding - ... | YifuLiu/AliOS-Things | components/py_engine/modules/oss/byhttp/aliot_hmac.c | C | apache-2.0 | 1,985 |
#ifndef _ALIOT_COMMON_HMAC_H_
#define _ALIOT_COMMON_HMAC_H_
#include <string.h>
void aliot_hmac_md5(const char *msg, int msg_len, char *digest, const char *key, int key_len);
void aliot_hmac_sha1(const char *msg, int msg_len, char *digest, const char *key, int key_len);
#endif
| YifuLiu/AliOS-Things | components/py_engine/modules/oss/byhttp/aliot_hmac.h | C | apache-2.0 | 283 |
#include "aliot_httpapi_oss.h"
#include <fcntl.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "py/mperrno.h"
#include "shared/timeutils/timeutils.h"
#define TAG "OSS_HTTP"
#define CRLF "\r\n"
/* 获取星期 */
const char *getWeekday... | YifuLiu/AliOS-Things | components/py_engine/modules/oss/byhttp/aliot_httpapi_oss.c | C | apache-2.0 | 12,954 |
#ifndef __ALIOT_HTTPAPI_OSS_H__
#define __ALIOT_HTTPAPI_OSS_H__
#include "aliot_base64.h"
#include "aliot_hmac.h"
#include "aliot_sha1.h"
#include "httpclient.h"
#include "ulog/ulog.h"
#define MAX_HTTP_OUTPUT_BUFFER (1024)
typedef struct {
char gmtweek[8];
char gmtmon[8];
} GmtTime_t;
typedef struct {
i... | YifuLiu/AliOS-Things | components/py_engine/modules/oss/byhttp/aliot_httpapi_oss.h | C | apache-2.0 | 1,225 |
#include "aliot_sha1.h"
#include <stdlib.h>
#include <string.h>
/* Implementation that should never be optimized out by the compiler */
static void aliot_sha1_zeroize(void *v, size_t n)
{
unsigned char *p = v;
while (n--) {
*p++ = 0;
}
}
/*
* 32-bit integer manipulation macros (big endian)
*/
... | YifuLiu/AliOS-Things | components/py_engine/modules/oss/byhttp/aliot_sha1.c | C | apache-2.0 | 8,206 |
#ifndef _ALIOT_COMMON_SHA1_H_
#define _ALIOT_COMMON_SHA1_H_
#include <stdint.h>
#include <stddef.h>
/**
* \brief SHA-1 context structure
*/
typedef struct {
uint32_t total[2]; /*!< number of bytes processed */
uint32_t state[5]; /*!< intermediate digest state */
unsigned char buf... | YifuLiu/AliOS-Things | components/py_engine/modules/oss/byhttp/aliot_sha1.h | C | apache-2.0 | 1,891 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if MICROPY_PY_OSS
#include "oss_app.h"
#include "py/builtin.h"
#include "py/mperrno.h"
#include "py/obj.h"
#include "py/runtime.h"
#include "ulog/ulog.h"
#include "utility.h"
#define LOG_TAG "MOD_OSS"
STATIC mp_obj_t obj_uploadFile(size_t n_args, const mp_... | YifuLiu/AliOS-Things | components/py_engine/modules/oss/modoss.c | C | apache-2.0 | 3,873 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if MICROPY_PY_OSS_HTTP
#include "aliot_httpapi_oss.h"
#include "py/builtin.h"
#include "py/mperrno.h"
#include "py/obj.h"
#include "py/runtime.h"
#include "ulog/ulog.h"
#define LOG_TAG "OSS_HTTP"
STATIC mp_obj_t oss_http_uploadFile(size_t n_args, const mp_... | YifuLiu/AliOS-Things | components/py_engine/modules/oss/modosshttp.c | C | apache-2.0 | 3,221 |
/*
* Copyright (C) 2015-2019 Alibaba Group Holding Limited
*/
#include <stdarg.h>
#include <string.h>
#if MICROPY_PY_OTA
#include "board_config.h"
#include "py/builtin.h"
#include "py/obj.h"
#include "py/runtime.h"
#include "py/stackctrl.h"
#include "py_defines.h"
//#include "be_inl.h"
#include "app_upgrade.h"
#in... | YifuLiu/AliOS-Things | components/py_engine/modules/ota/modota.c | C | apache-2.0 | 18,891 |
# CMake fragment for MicroPython port extmod component
set(MICROPY_MODULES_PORT_DIR ${CMAKE_CURRENT_LIST_DIR})
include("${CMAKE_CURRENT_LIST_DIR}/config.cmake")
set(MICROPY_INC_MODULES_PORT
${AOS_COMPONENTS_DIR}/osal_aos/include
${AOS_COMPONENTS_DIR}/ulog/include
)
if(MICROPY_PY_AIAGENT)
list(APPEND MIC... | YifuLiu/AliOS-Things | components/py_engine/modules/portmod.cmake | CMake | apache-2.0 | 14,074 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#if MICROPY_PY_SNTP
#include "lwip/apps/sntp.h"
#include "py/obj.h"
#include "ulog/ulog.h"
#define TAG "MOD_SNTP"
static const char *m_sntp_servaddr[] = {
"cn.pool.ntp.org",
"ntp.aliyun.com",
"ntp.tuna.tsinghua.edu.cn",
};
... | YifuLiu/AliOS-Things | components/py_engine/modules/sntp/aos/modsntp.c | C | apache-2.0 | 1,408 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if MICROPY_PY_SNTP
#include "esp_log.h"
#include "esp_sntp.h"
#include "py/obj.h"
#include "sntp/sntp.h"
#define TAG "MOD_SNTP"
static bool obtain_time(const char *serv_addr)
{
if (sntp_enabled()) {
sntp_stop();
}
sntp_setoperatingmode... | YifuLiu/AliOS-Things | components/py_engine/modules/sntp/esp32/modsntp.c | C | apache-2.0 | 2,693 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if MICROPY_PY_SYSTEM
#include "amp_utils.h"
#include "aos/kernel.h"
#include "aos_system.h"
#include "genhdr/mpversion.h"
#include "py/builtin.h"
#include "py/mpconfig.h"
#include "py/mperrno.h"
#include "py/mphal.h"
#include "py/obj.h"
#include "py/objstr.h... | YifuLiu/AliOS-Things | components/py_engine/modules/system/modsystem.c | C | apache-2.0 | 3,535 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "py/builtin.h"
#include "py/mperrno.h"
#include "py/obj.h"
#include "py/runtime.h"
#include "ucamera_service.h"
#include "ulog/ulog.h"
#include "wifi_camera.h"
#include "stdatomic.h"
#define LOG_TAG "MOD_UCAMERA"
#if MICROPY_PY_UCAMERA
// this is t... | YifuLiu/AliOS-Things | components/py_engine/modules/ucamera/moducamera.c | C | apache-2.0 | 11,067 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "oss_app.h"
#include "py/builtin.h"
#include "py/mperrno.h"
#include "py/obj.h"
#include "py/runtime.h"
#include "ucloud_ai_chatbot.h"
#include "ulog/ulog.h"
#define LOG_TAG "MOD_CHATBOT"
extern const mp_obj_type_t chatbot_type;
#define CHATBOT_CHE... | YifuLiu/AliOS-Things | components/py_engine/modules/ucloud_ai/chatbot.c | C | apache-2.0 | 3,586 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if MICROPY_PY_UCLOUD_AI
#include "py/builtin.h"
#include "py/mperrno.h"
#include "py/obj.h"
#include "py/runtime.h"
#include "ulog/ulog.h"
#include "ucloud_ai_common.h"
#include "utility.h"
#define LOG_TAG "MOD_UCLOUD_AI"
extern const mp_obj_type_t chatbo... | YifuLiu/AliOS-Things | components/py_engine/modules/ucloud_ai/moducloud_ai.c | C | apache-2.0 | 3,922 |
#include <aos/kernel.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if MICROPY_PY_UGRAPHICS
#include "py/builtin.h"
#include "py/obj.h"
#include "py/runtime.h"
#include "py/stackctrl.h"
#include "ugraphics.h"
#include "ulog/ulog.h"
#define LOG_TAG "ugraphics"
STATIC mp_obj_t mp_ugraphics_init(size_t... | YifuLiu/AliOS-Things | components/py_engine/modules/ugraphics/modugraphics.c | C | apache-2.0 | 8,493 |
/*
* Copyright (C) 2015-2019 Alibaba Group Holding Limited
*/
#if MICROPY_PY_ULOG
#include "py/builtin.h"
#include "py/obj.h"
#include "py/runtime.h"
#include "py/stackctrl.h"
#include "py_defines.h"
#include "ulog/ulog.h"
#define MOD_STR "LOG"
#define LOG_LEVEL_DEBUG "debug"
#define LOG_LEVEL_INFO "info... | YifuLiu/AliOS-Things | components/py_engine/modules/ulog/modulog.c | C | apache-2.0 | 6,217 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include "HaasLog.h"
#include "ak_common.h"
#include "ak_common_video.h"
#include "ak_log.h"
#include "ak_mem.h"
#include "ak_thread.h"
#include "ak_venc.h"
#include "ak_vi.h"
#include "ak_vpss.h"
#include "camera_ioctl.h"
#include "dev_... | YifuLiu/AliOS-Things | components/py_engine/modules/video/ak_camera.c | C | apache-2.0 | 11,382 |
#include <stdbool.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include "HaasLog.h"
#include "ak_common.h"
#include "ak_common_video.h"
#include "ak_venc.h"
#include "ak_vi.h"
#include "ak_vpss.h"
#include "dev_info.h"
#include "minIni.h"
#include "usb_... | YifuLiu/AliOS-Things | components/py_engine/modules/video/ak_codec.c | C | apache-2.0 | 2,826 |
#include "ak_rtsp.h"
#include <fcntl.h>
#include <kernel.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include "HaasLog.h"
#include "ak_common.h"
#include "ak_common_video.h"
#include "ak_log.h"
#include "ak_mem.h"
#include "ak_th... | YifuLiu/AliOS-Things | components/py_engine/modules/video/ak_rtsp.c | C | apache-2.0 | 13,217 |
#include <stdbool.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include "HaasLog.h"
#include "ak_common.h"
#include "ak_common_video.h"
#include "ak_log.h"
#include "ak_thread.h"
#include "ak_venc.h"
#include "ak_vi.h"
#include "ak_vpss.h"
#include "dev... | YifuLiu/AliOS-Things | components/py_engine/modules/video/ak_usbcam.c | C | apache-2.0 | 12,219 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if MICROPY_PY_VIDEO
#include "py/builtin.h"
#include "py/obj.h"
#include "py/runtime.h"
extern const mp_obj_type_t video_player_type;
extern const mp_obj_type_t video_recorder_type;
extern const mp_obj_type_t video_camera_type;
STATIC const mp_rom_map_elem... | YifuLiu/AliOS-Things | components/py_engine/modules/video/modvideo.c | C | apache-2.0 | 948 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include "HaasLog.h"
#include "aos/kernel.h"
#include "k_api.h"
#include "py/mperrno.h"
#include "py/mphal.h"
#include "py/nlr.h"
#include "py/runtime.h"
#include "py/runtime0.h"
#include "py/stream.h"
#include "timer.h"
#include "videoc... | YifuLiu/AliOS-Things | components/py_engine/modules/video/videocamera.c | C | apache-2.0 | 8,964 |
#ifndef HAAS_VIDEO_COMMON_H
#define HAAS_VIDEO_COMMON_H
#include "ak_common.h"
#include "ak_vi.h"
#include "py/objlist.h"
#include "py/objstr.h"
#ifdef __cplusplus
extern "C" {
#endif
#define UVC_FILE "/dev/usbuvc"
#define UVC_DEFAULT_FORMAT VIDEO_MEDIA_TYPE_YUV
#define CAMERA_MAIN... | YifuLiu/AliOS-Things | components/py_engine/modules/video/videocommon.h | C | apache-2.0 | 3,536 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "HaasLog.h"
#include "ak_common.h"
#include "ak_mem.h"
#include "ak_vi.h"
#include "k_api.h"
#include "py/mperrno.h"
#include "py/mphal.h"
#include "py/nlr.h"
#include "py/runtime.h"
#include "py/runtime0.h"
#include "py/stream.h"
#include "videocommo... | YifuLiu/AliOS-Things | components/py_engine/modules/video/videoplayer.c | C | apache-2.0 | 7,394 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "HaasLog.h"
#include "ak_common.h"
#include "ak_mem.h"
#include "ak_vi.h"
#include "k_api.h"
#include "py/mperrno.h"
#include "py/mphal.h"
#include "py/nlr.h"
#include "py/runtime.h"
#include "py/runtime0.h"
#include "py/stream.h"
#include "videocommo... | YifuLiu/AliOS-Things | components/py_engine/modules/video/videorecorder.c | C | apache-2.0 | 6,654 |
# all tests need print to work! make sure it does work
print(1)
print('abc')
| YifuLiu/AliOS-Things | components/py_engine/tests/basics/0prelim.py | Python | apache-2.0 | 78 |
# test short circuit expressions outside if conditionals
print(() or 1)
print((1,) or 1)
print(() and 1)
print((1,) and 1)
| YifuLiu/AliOS-Things | components/py_engine/tests/basics/andor.py | Python | apache-2.0 | 123 |
# test PEP 526, varible annotations
x: int
print("x" in globals())
x: int = 1
print(x)
t: tuple = 1, 2
print(t)
# a pure annotation in a function makes that variable local
def f():
x: int
try:
print(x)
except NameError:
print("NameError")
f()
# here, "x" should remain a global
def f():
... | YifuLiu/AliOS-Things | components/py_engine/tests/basics/annotate_var.py | Python | apache-2.0 | 350 |
try:
import uarray as array
except ImportError:
try:
import array
except ImportError:
print("SKIP")
raise SystemExit
a = array.array('B', [1, 2, 3])
print(a, len(a))
i = array.array('I', [1, 2, 3])
print(i, len(i))
print(a[0])
print(i[-1])
a = array.array('l', [-1])
print(len(a), a[... | YifuLiu/AliOS-Things | components/py_engine/tests/basics/array1.py | Python | apache-2.0 | 2,397 |
# test array + array
try:
import uarray as array
except ImportError:
try:
import array
except ImportError:
print("SKIP")
raise SystemExit
a1 = array.array('I', [1])
a2 = array.array('I', [2])
print(a1 + a2)
a1 += array.array('I', [3, 4])
print(a1)
a1.extend(array.array('I', [5]))
... | YifuLiu/AliOS-Things | components/py_engine/tests/basics/array_add.py | Python | apache-2.0 | 330 |
# test construction of array.array from different objects
try:
from uarray import array
except ImportError:
try:
from array import array
except ImportError:
print("SKIP")
raise SystemExit
# tuple, list
print(array('b', (1, 2)))
print(array('h', [1, 2]))
# raw copy from bytes, byte... | YifuLiu/AliOS-Things | components/py_engine/tests/basics/array_construct.py | Python | apache-2.0 | 551 |
try:
from uarray import array
except ImportError:
try:
from array import array
except ImportError:
print("SKIP")
raise SystemExit
# construct from something with unknown length (requires generators)
print(array('i', (i for i in range(10))))
| YifuLiu/AliOS-Things | components/py_engine/tests/basics/array_construct2.py | Python | apache-2.0 | 278 |
# test construction of array.array from different objects
try:
from uarray import array
except ImportError:
try:
from array import array
except ImportError:
print("SKIP")
raise SystemExit
# raw copy from bytes, bytearray
print(array('h', b'12'))
| YifuLiu/AliOS-Things | components/py_engine/tests/basics/array_construct_endian.py | Python | apache-2.0 | 284 |
# test array types QqLl that require big-ints
try:
from uarray import array
except ImportError:
try:
from array import array
except ImportError:
print("SKIP")
raise SystemExit
print(array('L', [0, 2**32-1]))
print(array('l', [-2**31, 0, 2**31-1]))
print(array('q'))
print(array('Q'... | YifuLiu/AliOS-Things | components/py_engine/tests/basics/array_intbig.py | Python | apache-2.0 | 527 |
# test MicroPython-specific features of array.array
try:
import uarray as array
except ImportError:
try:
import array
except ImportError:
print("SKIP")
raise SystemExit
# arrays of objects
a = array.array('O')
a.append(1)
print(a[0])
# arrays of pointers
a = array.array('P')
a.appe... | YifuLiu/AliOS-Things | components/py_engine/tests/basics/array_micropython.py | Python | apache-2.0 | 714 |
# test assignments
a = 1
print(a)
a = b = 2
print(a, b)
a = b = c = 3
print(a, b, c)
| YifuLiu/AliOS-Things | components/py_engine/tests/basics/assign1.py | Python | apache-2.0 | 89 |
(x := 4)
print(x)
if x := 2:
print(True)
print(x)
print(4, x := 5)
print(x)
x = 1
print(x, x := 5, x)
print(x)
def foo():
print("any", any((hit := i) % 5 == 3 and (hit % 2) == 0 for i in range(10)))
return hit
hit = 123
print(foo())
print(hit) # shouldn't be changed by foo
print("any", any((hit := ... | YifuLiu/AliOS-Things | components/py_engine/tests/basics/assign_expr.py | Python | apache-2.0 | 472 |
# test SyntaxError with := operator
def test(code):
try:
print(eval(code))
except SyntaxError:
print('SyntaxError')
test("x := 1")
test("((x, y) := 1)")
# these are currently all allowed in MicroPython, but not in CPython
test("([i := i + 1 for i in range(4)])")
test("([i := -1 for i, j in [(... | YifuLiu/AliOS-Things | components/py_engine/tests/basics/assign_expr_syntaxerror.py | Python | apache-2.0 | 449 |
# test basic await expression
# adapted from PEP0492
async def abinary(n):
print(n)
if n <= 0:
return 1
l = await abinary(n - 1)
r = await abinary(n - 1)
return l + 1 + r
o = abinary(4)
try:
while True:
o.send(None)
except StopIteration:
print('finished')
| YifuLiu/AliOS-Things | components/py_engine/tests/basics/async_await.py | Python | apache-2.0 | 302 |
# test await expression
try:
import usys as sys
except ImportError:
import sys
if sys.implementation.name == 'micropython':
# uPy allows normal generators to be awaitables
coroutine = lambda f: f
else:
import types
coroutine = types.coroutine
@coroutine
def wait(value):
print('wait value:'... | YifuLiu/AliOS-Things | components/py_engine/tests/basics/async_await2.py | Python | apache-2.0 | 640 |
# test async def
def dec(f):
print('decorator')
return f
# test definition with a decorator
@dec
async def foo():
print('foo')
coro = foo()
try:
coro.send(None)
except StopIteration:
print('StopIteration')
| YifuLiu/AliOS-Things | components/py_engine/tests/basics/async_def.py | Python | apache-2.0 | 229 |
# test basic async for execution
# example taken from PEP0492
class AsyncIteratorWrapper:
def __init__(self, obj):
print('init')
self._it = iter(obj)
def __aiter__(self):
print('aiter')
return self
async def __anext__(self):
print('anext')
try:
... | YifuLiu/AliOS-Things | components/py_engine/tests/basics/async_for.py | Python | apache-2.0 | 603 |
# test waiting within "async for" __anext__ function
try:
import usys as sys
except ImportError:
import sys
if sys.implementation.name == 'micropython':
# uPy allows normal generators to be awaitables
coroutine = lambda f: f
else:
import types
coroutine = types.coroutine
@coroutine
def f(x):
... | YifuLiu/AliOS-Things | components/py_engine/tests/basics/async_for2.py | Python | apache-2.0 | 1,025 |
# test syntax errors using async
try:
exec
except NameError:
print("SKIP")
raise SystemExit
def test_syntax(code):
try:
exec(code)
print("no SyntaxError")
except SyntaxError:
print("SyntaxError")
test_syntax("async for x in (): x")
test_syntax("async with x: x")
| YifuLiu/AliOS-Things | components/py_engine/tests/basics/async_syntaxerror.py | Python | apache-2.0 | 312 |
# test simple async with execution
class AContext:
async def __aenter__(self):
print('enter')
return 1
async def __aexit__(self, exc_type, exc, tb):
print('exit', exc_type, exc)
async def f():
async with AContext():
print('body')
o = f()
try:
o.send(None)
except StopIt... | YifuLiu/AliOS-Things | components/py_engine/tests/basics/async_with.py | Python | apache-2.0 | 750 |
# test waiting within async with enter/exit functions
try:
import usys as sys
except ImportError:
import sys
if sys.implementation.name == 'micropython':
# uPy allows normal generators to be awaitables
coroutine = lambda f: f
else:
import types
coroutine = types.coroutine
@coroutine
def f(x):
... | YifuLiu/AliOS-Things | components/py_engine/tests/basics/async_with2.py | Python | apache-2.0 | 906 |
# test async with, escaped by a break
class AContext:
async def __aenter__(self):
print('enter')
return 1
async def __aexit__(self, exc_type, exc, tb):
print('exit', exc_type, exc)
async def f1():
while 1:
async with AContext():
print('body')
break
... | YifuLiu/AliOS-Things | components/py_engine/tests/basics/async_with_break.py | Python | apache-2.0 | 1,171 |
# test async with, escaped by a return
class AContext:
async def __aenter__(self):
print('enter')
return 1
async def __aexit__(self, exc_type, exc, tb):
print('exit', exc_type, exc)
async def f1():
async with AContext():
print('body')
return
o = f1()
try:
o.sen... | YifuLiu/AliOS-Things | components/py_engine/tests/basics/async_with_return.py | Python | apache-2.0 | 887 |
# test attrtuple
# we can't test this type directly so we use sys.implementation object
try:
import usys as sys
except ImportError:
import sys
t = sys.implementation
# It can be just a normal tuple on small ports
try:
t.name
except AttributeError:
print("SKIP")
raise SystemExit
# test printing o... | YifuLiu/AliOS-Things | components/py_engine/tests/basics/attrtuple1.py | Python | apache-2.0 | 416 |
# tests for bool objects
# basic logic
print(not False)
print(not True)
print(False and True)
print(False or True)
# unary operators
print(+True)
print(-True)
# comparison with itself
print(False == False)
print(False == True)
print(True == False)
print(True == True)
print(False != False)
print(False != True)
print(... | YifuLiu/AliOS-Things | components/py_engine/tests/basics/bool1.py | Python | apache-2.0 | 676 |
# tests basics of bound methods
# uPy and CPython differ when printing a bound method, so just print the type
print(type(repr([].append)))
class A:
def f(self):
return 0
def g(self, a):
return a
def h(self, a, b, c, d, e, f):
return a + b + c + d + e + f
# bound method with no ext... | YifuLiu/AliOS-Things | components/py_engine/tests/basics/boundmeth1.py | Python | apache-2.0 | 598 |
while True:
break
for i in range(4):
print('one', i)
if i > 2:
break
print('two', i)
for i in [1, 2, 3, 4]:
if i == 3:
break
print(i)
| YifuLiu/AliOS-Things | components/py_engine/tests/basics/break.py | Python | apache-2.0 | 176 |
# test builtin abs
print(abs(False))
print(abs(True))
print(abs(1))
print(abs(-1))
| YifuLiu/AliOS-Things | components/py_engine/tests/basics/builtin_abs.py | Python | apache-2.0 | 84 |
# test builtin abs
# bignum
print(abs(123456789012345678901234567890))
print(abs(-123456789012345678901234567890))
# edge cases for 32 and 64 bit archs (small int overflow when negating)
print(abs(-0x3fffffff - 1))
print(abs(-0x3fffffffffffffff - 1))
# edge case for nan-boxing with 47-bit small int
i = -0x3fffffffff... | YifuLiu/AliOS-Things | components/py_engine/tests/basics/builtin_abs_intbig.py | Python | apache-2.0 | 341 |
# test builtin "all" and "any"
tests = (
(),
[],
[False],
[True],
[False, True],
[True, False],
[False, False],
[True, True],
range(10),
)
for test in tests:
print(all(test))
for test in tests:
print(any(test))
| YifuLiu/AliOS-Things | components/py_engine/tests/basics/builtin_allany.py | Python | apache-2.0 | 258 |
# test builtin bin function
print(bin(1))
print(bin(-1))
print(bin(15))
print(bin(-15))
print(bin(12345))
print(bin(0b10101))
print(bin(0b10101010101010101010))
| YifuLiu/AliOS-Things | components/py_engine/tests/basics/builtin_bin.py | Python | apache-2.0 | 164 |
# test builtin bin function
print(bin(12345678901234567890))
| YifuLiu/AliOS-Things | components/py_engine/tests/basics/builtin_bin_intbig.py | Python | apache-2.0 | 62 |
# test builtin callable
# primitives should not be callable
print(callable(None))
print(callable(1))
print(callable([]))
print(callable("dfsd"))
# modules should not be callabe
try:
import usys as sys
except ImportError:
import sys
print(callable(sys))
# builtins should be callable
print(callable(callable))
... | YifuLiu/AliOS-Things | components/py_engine/tests/basics/builtin_callable.py | Python | apache-2.0 | 910 |
# test builtin chr (whether or not we support unicode)
print(chr(65))
try:
chr(0x110000)
except ValueError:
print("ValueError")
| YifuLiu/AliOS-Things | components/py_engine/tests/basics/builtin_chr.py | Python | apache-2.0 | 139 |
# test compile builtin
try:
compile
except NameError:
print("SKIP")
raise SystemExit
def test():
global x
c = compile("print(x)", "file", "exec")
try:
exec(c)
except NameError:
print("NameError")
# global variable for compiled code to access
x = 1
exec(c)
... | YifuLiu/AliOS-Things | components/py_engine/tests/basics/builtin_compile.py | Python | apache-2.0 | 859 |
# test builtin delattr
try:
delattr
except:
print("SKIP")
raise SystemExit
class A: pass
a = A()
a.x = 1
print(a.x)
delattr(a, 'x')
try:
a.x
except AttributeError:
print('AttributeError')
try:
delattr(a, 'x')
except AttributeError:
print('AttributeError')
| YifuLiu/AliOS-Things | components/py_engine/tests/basics/builtin_delattr.py | Python | apache-2.0 | 288 |
# test builtin dir
# dir of locals
print('__name__' in dir())
# dir of module
try:
import usys as sys
except ImportError:
import sys
print('version' in dir(sys))
# dir of type
print('append' in dir(list))
class Foo:
def __init__(self):
self.x = 1
foo = Foo()
print('__init__' in dir(foo))
print('... | YifuLiu/AliOS-Things | components/py_engine/tests/basics/builtin_dir.py | Python | apache-2.0 | 685 |
# test builtin divmod
print(divmod(0, 2))
print(divmod(3, 4))
print(divmod(20, 3))
try:
divmod(1, 0)
except ZeroDivisionError:
print("ZeroDivisionError")
try:
divmod('a', 'b')
except TypeError:
print("TypeError")
| YifuLiu/AliOS-Things | components/py_engine/tests/basics/builtin_divmod.py | Python | apache-2.0 | 232 |
# test builtin divmod
try:
divmod(1 << 65, 0)
except ZeroDivisionError:
print("ZeroDivisionError")
# bignum
l = (1 << 65) + 123
print(divmod(3, l))
print(divmod(l, 5))
print(divmod(l + 3, l))
print(divmod(l * 20, l + 2))
| YifuLiu/AliOS-Things | components/py_engine/tests/basics/builtin_divmod_intbig.py | Python | apache-2.0 | 231 |
# tests that .../Ellipsis exists
print(...)
print(Ellipsis)
print(... == Ellipsis)
# Test that Ellipsis can be hashed
print(type(hash(Ellipsis)))
| YifuLiu/AliOS-Things | components/py_engine/tests/basics/builtin_ellipsis.py | Python | apache-2.0 | 149 |
try:
enumerate
except:
print("SKIP")
raise SystemExit
print(list(enumerate([])))
print(list(enumerate([1, 2, 3])))
print(list(enumerate([1, 2, 3], 5)))
print(list(enumerate([1, 2, 3], -5)))
print(list(enumerate(range(100))))
# specifying args with keywords
print(list(enumerate([1, 2, 3], start=1)))
print(... | YifuLiu/AliOS-Things | components/py_engine/tests/basics/builtin_enumerate.py | Python | apache-2.0 | 636 |
# builtin eval
try:
eval
except NameError:
print("SKIP")
raise SystemExit
eval('1 + 2')
eval('1 + 2\n')
eval('1 + 2\n\n#comment\n')
x = 4
eval('x')
eval('lambda x: x + 10')(-5)
y = 6
eval('lambda: y * 2')()
| YifuLiu/AliOS-Things | components/py_engine/tests/basics/builtin_eval.py | Python | apache-2.0 | 224 |
# test builtin eval with a buffer (bytearray/memoryview) input
try:
eval
bytearray
memoryview
except:
print("SKIP")
raise SystemExit
print(eval(bytearray(b'1 + 1')))
print(eval(memoryview(b'2 + 2')))
| YifuLiu/AliOS-Things | components/py_engine/tests/basics/builtin_eval_buffer.py | Python | apache-2.0 | 222 |
# test if eval raises SyntaxError
try:
eval
except NameError:
print("SKIP")
raise SystemExit
try:
print(eval("[1,,]"))
except SyntaxError:
print("SyntaxError")
| YifuLiu/AliOS-Things | components/py_engine/tests/basics/builtin_eval_error.py | Python | apache-2.0 | 182 |
# test builtin exec
try:
exec
except NameError:
print("SKIP")
raise SystemExit
print(exec("def foo(): return 42"))
print(foo())
d = {}
exec("def bar(): return 84", d)
print(d["bar"]())
# passing None/dict as args to globals/locals
foo = 11
exec('print(foo)')
exec('print(foo)', None)
exec('print(foo)', {... | YifuLiu/AliOS-Things | components/py_engine/tests/basics/builtin_exec.py | Python | apache-2.0 | 752 |
# test builtin exec with a buffer (bytearray/memoryview) input
try:
exec
bytearray
memoryview
except:
print("SKIP")
raise SystemExit
exec(bytearray(b'print(1)'))
exec(memoryview(b'print(2)'))
| YifuLiu/AliOS-Things | components/py_engine/tests/basics/builtin_exec_buffer.py | Python | apache-2.0 | 214 |
try:
filter
except:
print("SKIP")
raise SystemExit
print(list(filter(lambda x: x & 1, range(-3, 4))))
print(list(filter(None, range(-3, 4))))
| YifuLiu/AliOS-Things | components/py_engine/tests/basics/builtin_filter.py | Python | apache-2.0 | 155 |
class A:
var = 132
def __init__(self):
self.var2 = 34
def meth(self, i):
return 42 + i
a = A()
print(getattr(a, "var"))
print(getattr(a, "var2"))
print(getattr(a, "meth")(5))
print(getattr(a, "_none_such", 123))
print(getattr(list, "foo", 456))
print(getattr(a, "va" + "r2"))
# test a c... | YifuLiu/AliOS-Things | components/py_engine/tests/basics/builtin_getattr.py | Python | apache-2.0 | 615 |
class A:
var = 132
def __init__(self):
self.var2 = 34
def meth(self, i):
return 42 + i
a = A()
print(hasattr(a, "var"))
print(hasattr(a, "var2"))
print(hasattr(a, "meth"))
print(hasattr(a, "_none_such"))
print(hasattr(list, "foo"))
class C:
def __getattr__(self, attr):
if ... | YifuLiu/AliOS-Things | components/py_engine/tests/basics/builtin_hasattr.py | Python | apache-2.0 | 799 |
# test builtin hash function
print(hash(False))
print(hash(True))
print({():1}) # hash tuple
print({(1,):1}) # hash non-empty tuple
print(hash in {hash:1}) # hash function
try:
hash([])
except TypeError:
print("TypeError")
class A:
def __hash__(self):
return 123
def __repr__(self):
re... | YifuLiu/AliOS-Things | components/py_engine/tests/basics/builtin_hash.py | Python | apache-2.0 | 892 |
# test builtin hash function, on generators
def gen():
yield
print(type(hash(gen)))
print(type(hash(gen())))
| YifuLiu/AliOS-Things | components/py_engine/tests/basics/builtin_hash_gen.py | Python | apache-2.0 | 115 |