Commit b164bbbc authored by Philippe Coval's avatar Philippe Coval Committed by Uze Choi

freertos: Build st_app (with stubbed parts)

IMHO, this should be refactored to split generic and platform parts,

I think that files from:
  ./apps/st_app/${port}
Should be relocated into:
  ./api/
And then plaform specific code should be in:
  ./port/${port}
Or eventually:
  ./extra/port/${port}
if not used by lib internals,
just to make app developer easier.

Change-Id: I3b0a5e952f4678a3c2d3c568085df2575cc4eeda
Bug: https://jira.iotivity.org/browse/LITE-8
Origin: https://gerrit.iotivity.org/gerrit/#/c/25547/Signed-off-by: default avatarPhilippe Coval <p.coval@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/25547Tested-by: default avatarIoTivity Jenkins <jenkins-daemon@iotivity.org>
Reviewed-by: default avatarUze Choi <uzchoi@samsung.com>
parent 3b516f19
#!/usr/bin/make -f
# -*- makefile -*-
# ex: set tabstop=4 noexpandtab:
#{
# Copyright 2018 Samsung Electronics France SAS
#
# 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.
#}
port?=linux
srcs?=$(wildcard *.c ${port}/*.c)
objs?=${srcs:.c=.o}
topdir?=../..
CFLAGS+=-I${topdir}
CFLAGS+=-I${topdir}/include
CFLAGS+=-I${topdir}/port
CFLAGS+=-I${topdir}/port/${port}
CFLAGS+=-I${topdir}/service/easy-setup/enrollee/include
CFLAGS+=-I${topdir}/service/cloud-access/include
CFLAGS+=-I${topdir}/service/resource-directory/client/include
CFLAGS+=-I${topdir}/service/easy-setup/enrollee/include/samsung
all: ${objs}
ls $<
clean:
rm -f ${objs}
#! /usr/bin/make -f
# -*- makefile -*-
# ex: set tabstop=4 noexpandtab:
#{
# Copyright 2018 Samsung Electronics France SAS
#
# 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.
#}
port?=freertos
srcs?=$(wildcard *.c)
objs?=${srcs:.c=.o}
topdir?=../../..
CFLAGS+=-I${topdir}
CFLAGS+=-I${topdir}/include
CFLAGS+=-I${topdir}/port/
CFLAGS+=-I${topdir}/port/${port}
all: ${objs}
ls $<
clean:
rm -f ${objs}
/****************************************************************************
*
* Copyright 2018 Samsung Electronics All Rights Reserved.
*
* 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.
*
****************************************************************************/
#define _GNU_SOURCE
#include "oc_assert.h"
#include "../st_port.h"
#include "../st_process.h"
#include "port/oc_assert.h"
#include "port/oc_clock.h"
#include "port/oc_connectivity.h"
#include "util/oc_memb.h"
#include <pthread.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <unistd.h>
typedef struct
{
st_thread_t thread;
st_mutex_t mutex;
st_cond_t cv;
int is_soft_ap_on;
oc_string_t ssid;
oc_string_t pwd;
int channel;
} st_soft_ap_t;
static st_soft_ap_t g_soft_ap;
OC_MEMB(st_mutex_s, pthread_mutex_t, 10);
OC_MEMB(st_cond_s, pthread_cond_t, 10);
OC_MEMB(st_thread_s, pthread_t, 10);
extern int quit;
static void *soft_ap_process_routine(void *data);
static void
handle_signal(int signal)
{
oc_abort(__func__);
}
int
st_port_specific_init(void)
{
oc_abort(__func__);
return 0;
}
void
st_port_specific_destroy(void)
{
oc_abort(__func__);
return;
}
static void
print_menu(void)
{
oc_abort(__func__);
}
st_loop_status_t
st_port_main_loop(int *quit_flag)
{
oc_abort(__func__);
}
void
st_print_log(const char *fmt, ...)
{
oc_abort(__func__);
}
st_mutex_t
st_mutex_init(void)
{
st_mutex_t mutex;
oc_abort(__func__);
return mutex;
}
int
st_mutex_destroy(st_mutex_t mutex)
{
oc_abort(__func__);
return 0;
}
int
st_mutex_lock(st_mutex_t mutex)
{
oc_abort(__func__);
return 0;
}
int
st_mutex_unlock(st_mutex_t mutex)
{
oc_abort(__func__);
return 0;
}
st_cond_t
st_cond_init(void)
{
oc_abort(__func__);
}
int
st_cond_destroy(st_cond_t cv)
{
oc_abort(__func__);
return 0;
}
int
st_cond_wait(st_cond_t cv, st_mutex_t mutex)
{
oc_abort(__func__);
}
int
st_cond_timedwait(st_cond_t cv, st_mutex_t mutex, oc_clock_time_t time)
{
oc_abort(__func__);
}
int
st_cond_signal(st_cond_t cv)
{
oc_abort(__func__);
}
int
st_set_sigint_handler(st_sig_handler_t handler)
{
oc_abort(__func__);
return 0;
}
st_thread_t
st_thread_create(st_thread_process_t handler, const char *name, void *user_data)
{
oc_abort(__func__);
return NULL;
}
int
st_thread_destroy(st_thread_t thread)
{
oc_abort(__func__);
}
int
st_thread_cancel(st_thread_t thread)
{
oc_abort(__func__);
}
void
st_thread_exit(void *retval)
{
oc_abort(__func__);
}
void
st_sleep(int seconds)
{
oc_abort(__func__);
}
void
st_turn_on_soft_AP(const char *ssid, const char *pwd, int channel)
{
oc_abort(__func__);
}
static int
system_ret_chcek(int ret)
{
oc_abort(__func__);
return 0;
}
void
st_turn_off_soft_AP(void)
{
oc_abort(__func__);
}
void
st_connect_wifi(const char *ssid, const char *pwd)
{
oc_abort(__func__);
}
static void *
soft_ap_process_routine(void *data)
{
oc_abort(__func__);
}
/****************************************************************************
*
* Copyright 2018 Samsung Electronics All Rights Reserved.
*
* 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 "oc_assert.h"
#include "../st_process.h"
#include "oc_api.h"
typedef struct
{
st_mutex_t mutex;
st_mutex_t app_mutex;
st_cond_t cv;
st_thread_t thread;
int quit;
} st_process_data_t;
static st_process_data_t g_process_data;
static void *st_process_func(void *data);
int
st_process_init(void)
{
oc_abort(__func__);
return 0;
}
int
st_process_start(void)
{
oc_abort(__func__);
return 0;
}
int
st_process_stop(void)
{
oc_abort(__func__);
return 0;
}
static void *
st_process_func(void *data)
{
oc_abort(__func__);
return NULL;
}
void
st_process_signal(void)
{
oc_abort(__func__);
}
void
st_process_app_sync_lock(void)
{
oc_abort(__func__);
}
void
st_process_app_sync_unlock(void)
{
oc_abort(__func__);
}
/****************************************************************************
*
* Copyright 2018 Samsung Electronics All Rights Reserved.
*
* 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 "oc_assert.h"
#include "../st_manager.h"
#include "../st_port.h"
#include "../st_resource_manager.h"
static const char *switch_rsc_uri = "/capability/switch/main/0";
static const char *switchlevel_rsc_uri = "/capability/switchLevel/main/0";
static const char *color_temp_rsc_uri = "/capability/colorTemperature/main/0";
static const char *power_prop_key = "power";
static const char *dimming_prop_key = "dimmingSetting";
static const char *ct_prop_key = "ct";
static char power[10] = "on";
static int dimmingSetting = 50;
static int dimming_range[2] = { 0, 100 };
static int dimming_step = 5;
static int ct = 50;
static int ct_range[2] = { 0, 100 };
static void
switch_resource_construct(void)
{
oc_abort(__func__);
}
static void
switchlevel_resource_construct(void)
{
oc_abort(__func__);
}
static void
color_temp_resource_construct(void)
{
oc_abort(__func__);
}
static bool
get_resource_handler(oc_request_t *request)
{
oc_abort(__func__);
}
static void
switch_resource_change(oc_rep_t *rep)
{
oc_abort(__func__);
}
static void
switchlevel_resource_change(oc_rep_t *rep)
{
oc_abort(__func__);
}
static void
color_temp_resource_change(oc_rep_t *rep)
{
oc_abort(__func__);
}
static bool
set_resource_handler(oc_request_t *request)
{
oc_abort(__func__);
return true;
}
int
main(void)
{
oc_abort(__func__);
return 0;
}
......@@ -16,6 +16,8 @@
*
****************************************************************************/
#include <stdlib.h>
#include "st_manager.h"
#include "oc_api.h"
#include "oc_core_res.h"
......@@ -333,8 +335,10 @@ st_manager_start(void)
int device_num = 0;
static const oc_handler_t handler = {.init = app_init,
.signal_event_loop = st_process_signal,
.register_resources =
register_resources };
#ifdef OC_SERVER
.register_resources = register_resources
#endif
};
restart:
if (st_store_load() < 0) {
......
......@@ -23,6 +23,8 @@ top_dir?=../../..
extra_dir?=${CURDIR}/${top_dir}/deps
port?=freertos
export port
os_url?=https://github.com/espressif/esp-idf
os_dir?=${extra_dir}/esp-idf
os_branch?=master
......@@ -31,6 +33,10 @@ IDF_PATH=${os_dir}
export IDF_PATH
app_dir?=${top_dir}/port/${port}
sub_dirs+=${app_dir}
sub_dirs+=${top_dir}/apps/st_app/
#TODO: try to build more gemeric code
#sub_dirs+=${top_dir}/apps
toolchain_url?=https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz
toolchain_abi?=xtensa-esp32-elf
......@@ -40,11 +46,15 @@ toolchain_bin?=${toolchain_dir}/bin
CROSSCOMPIL?=${toolchain_bin}/${toolchain_abi}-
CC=${CROSSCOMPIL}gcc
export CC
PATH:=${toolchain_bin}:${PATH}
export PATH
prep_files+=${CC}
CFLAGS+=-Werror
export CFLAGS
${os_dir}:
git clone --depth 1 --recursive -b ${os_branch} ${os_url} $@
......@@ -71,5 +81,6 @@ prep: ${prep_files} ${CC}
build/hello: ${os_dir}
${MAKE} -C $</examples/get-started/hello_world/ all
build: ${app_dir} ${prep_files}
${MAKE} -C $<
build: ${sub_dirs} ${prep_files}
for sub_dir in ${sub_dirs}; do ${MAKE} -C $${sub_dir} ; done
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment