提交 9488e671 编写于 作者: Z zgit2021

optimize the iot_link repository and directory

Signed-off-by: Nzgit2021 <zhaowenqiang14@huawei.com>
Change-Id: Iad4e73333da1f2c54c4dcfa2a75008dee4067fab
上级 b33bd106
...@@ -12,10 +12,11 @@ ...@@ -12,10 +12,11 @@
# limitations under the License. # limitations under the License.
static_library("example_demolink") { static_library("example_demolink") {
sources = [ "helloworld.c" ] sources = [
"demosdk.c",
include_dirs = [ "demosdk_adapter.c",
"//utils/native/lite/include", "helloworld.c",
"//domains/iot/link/libbuild",
] ]
include_dirs = [ "//utils/native/lite/include" ]
} }
/*
* Copyright (c) 2020 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "demosdk.h"
#include <stdio.h>
#include "demosdk_adapter.h"
#define TASK_STACK_SIZE 1000
#define TASK_PRIO 20
#define SECOND_CNT 1000
void *DemoSdkBiz(const char *arg)
{
(void)arg;
while (1) {
printf("it is demo biz: hello world.\n");
DemoSdkSleepMs(SECOND_CNT);
}
return NULL;
}
int DemoSdkEntry(void)
{
printf("it is demosdk entry.\n");
struct TaskPara para = {0};
para.name = "demotask";
para.func = (void *)DemoSdkBiz;
para.prio = TASK_PRIO;
para.size = TASK_STACK_SIZE;
unsigned int handle;
int ret = DemoSdkCreateTask(&handle, &para);
if (ret != 0) {
printf("create task fail.\n");
return -1;
}
return 0;
}
/*
* Copyright (c) 2020 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef DEMOSDK_H
#define DEMOSDK_H
int DemoSdkEntry(void);
#endif // DEMOSDK_H
/*
* Copyright (c) 2020 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "demosdk_adapter.h"
#include <stdio.h>
#include "cmsis_os2.h"
#define MS_CNT 1000
int DemoSdkCreateTask(unsigned int *handle, const struct TaskPara *para)
{
osThreadAttr_t attr = {0};
osThreadId_t threadId;
if (handle == 0 || para == 0) {
return DEMOSDK_ERR;
}
if (para->func == 0) {
return DEMOSDK_ERR;
}
if (para->name == 0) {
return DEMOSDK_ERR;
}
attr.name = para->name;
attr.priority = para->prio;
attr.stack_size = para->size;
threadId = osThreadNew((osThreadFunc_t)para->func, para->arg, &attr);
if (threadId == 0) {
printf("osThreadNew fail\n");
return DEMOSDK_ERR;
}
*(unsigned int *)handle = (unsigned int)threadId;
return DEMOSDK_OK;
}
void DemoSdkSleepMs(int ms)
{
usleep(MS_CNT * ms);
}
/*
* Copyright (c) 2020 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef DEMOSDK_ADAPTER_H
#define DEMOSDK_ADAPTER_H
#define DEMOSDK_ERR (-1)
#define DEMOSDK_OK 0
struct TaskPara {
char *name;
void *(*func)(char* arg);
void *arg;
unsigned char prio;
unsigned int size;
};
int DemoSdkCreateTask(unsigned int *handle, const struct TaskPara *para);
void DemoSdkSleepMs(int ms);
#endif // DEMOSDK_ADAPTER_H
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册