1 Star 0 Fork 1

Bluejeams/haas_dev_demo

forked from AliOS Things/haas_dev_demo 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
haas_dev_demo.c 1.49 KB
一键复制 编辑 原始数据 按行查看 历史
skylarCai 提交于 2021-10-29 14:13 . release version:rel_3.3.0-20211028_1000
/*
* Copyright (C) 2015-2020 Alibaba Group Holding Limited
*/
#include "aos/init.h"
#include "board.h"
#include <aos/errno.h>
#include <aos/kernel.h>
#include <k_api.h>
#include <stdio.h>
#include <stdlib.h>
#include <uservice/uservice.h>
#include <uservice/eventid.h>
#include "aos/cli.h"
#include "haas_main.h"
#define AMP_TYPE_MAX_LEN 32
#define AMP_TYPE_JS "JS"
#define AMP_TYPE_PYTHON "Python"
extern int amp_main(void);
static void amp_set_command(int argc, char **argv)
{
if (argc < 2) {
printf("Usge: amp_set [JS/Python]\r\n");
return;
}
if (strcmp(argv[1], AMP_TYPE_JS) == 0) {
aos_kv_set("amp_type", AMP_TYPE_JS, strlen(AMP_TYPE_JS));
} else if (strcmp(argv[1], AMP_TYPE_PYTHON) == 0) {
aos_kv_set("amp_type", AMP_TYPE_PYTHON, strlen(AMP_TYPE_PYTHON));
}
}
/* reg args: fun, cmd, description*/
ALIOS_CLI_CMD_REGISTER(amp_set_command, amp_set, set amp startup type)
int application_start(int argc, char *argv[])
{
int len = 0;
int ret = 0;
aos_task_t amp_task;
char amp_type[AMP_TYPE_MAX_LEN] = {0};
printf("haas dev demp entry here!\r\n");
len = 32;
ret = aos_kv_get("amp_type", amp_type, &len);
if ((ret == 0) && (strcmp(amp_type, AMP_TYPE_JS) == 0)) {
/* Start JS engine. */
aos_task_new_ext(&amp_task, "amp_task", amp_main, NULL, 8192, AOS_DEFAULT_APP_PRI - 2);
} else {
/* Start Python engine. */
haas_main(argc, argv);
}
while (1) {
aos_msleep(10000);
};
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Bluejeams/haas_dev_demo.git
git@gitee.com:Bluejeams/haas_dev_demo.git
Bluejeams
haas_dev_demo
haas_dev_demo
rel_3.3.0

搜索帮助