Skip to content

Commit

Permalink
Make st regarding logic to library.
Browse files Browse the repository at this point in the history
To st_things modules use commonly, it need to
make that library. Make st_framework module in service
layer, and move st_app modules to there.

To make prebuilt library for st-app-fw, use make_prebuilt.py
script in tools folder. thil will copy dependency header in
prebuilt folder and copy library about st-app-fw(libst-app-framwork.a)
Detailed usage can check in make_prebuilt.py script file.

Please Add build option ST_APP_FW to build st-app-fw library.

-------------------------------
Test Case
  st_app (out of box)
     Create Soft-AP  : OK
     Provisioning : OK
     Controlled by ST android app :OK
  st_app (setup is done)  -  OK
  st_app (with reset)  - OK

Change-Id: Ie44b7053a69afe9ad230ecde1655f252bdd45ae7
Signed-off-by: Jaehyun Cho <[email protected]>
Reviewed-on: https://gerrit.iotivity.org/gerrit/25629
Tested-by: IoTivity Jenkins <[email protected]>
Reviewed-by: Uze Choi <[email protected]>
  • Loading branch information
looksgoood authored and uzchoi committed Jun 15, 2018
1 parent ea2508e commit 72abe3c
Show file tree
Hide file tree
Showing 32 changed files with 561 additions and 431 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ port/linux/server_multithread_linux
port/linux/client_multithread_linux
port/linux/easysetup_linux
port/linux/easysetup_linux_creds/
port/linux/sc_easysetup_linux
port/linux/sc_easysetup_linux_creds/
port/linux/mfgserver
port/linux/mfgserver_creds/
port/linux/st_things
Expand All @@ -26,6 +28,7 @@ port/linux/libiotivity-constrained-client-server.*
port/linux/libiotivity-constrained-cloudaccess.*
port/linux/libiotivity-constrained-rd-client.*
port/linux/libiotivity-constrained-easysetup.*
port/linux/libst-app-framework.*
port/linux/iotivity-constrained-server.pc
port/linux/iotivity-constrained-client.pc
port/linux/iotivity-constrained-client-server.pc
Expand All @@ -49,6 +52,7 @@ port/openthread/output
.clang-format
_clang-format
port/linux/platformtest
prebuilt

#creds files
port/linux/client_creds
Expand All @@ -63,6 +67,7 @@ port/linux/multi_device_client_creds
port/linux/multi_device_server_creds
port/linux/server_multithread_linux_creds
port/linux/client_multithread_linux_creds
port/linux/cloud_linux_creds

#vscode setting files
.vscode
38 changes: 0 additions & 38 deletions apps/st_app/Makefile

This file was deleted.

5 changes: 5 additions & 0 deletions apps/st_app/freertos/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ 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
CFLAGS+=-I${topdir}/service/st-app-fw/include

all: ${objs}
ls $<
Expand Down
5 changes: 2 additions & 3 deletions apps/st_app/freertos/st_ref_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
****************************************************************************/

#include "oc_assert.h"
#include "../st_manager.h"
#include "../st_port.h"
#include "../st_resource_manager.h"
#include "st_manager.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";
Expand Down
11 changes: 11 additions & 0 deletions apps/st_app/linux/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CC = gcc
CFLAGS=-fPIC -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -ffreestanding -Os -fno-stack-protector -ffunction-sections -fdata-sections -fno-reorder-functions -fno-defer-pop -fno-strict-overflow -I./ -I../ -I../../ -I../../include/ -std=gnu99 -Wall -Wextra #-Wl,-Map,client.map
CFLAGS += -I./include
LIBS?= -lm -pthread -lrt

all: st_things

st_things:
@mkdir -p $@_creds
${CC} -o $@ st_ref_app.c \
lib/libst-app-framework.a ${CFLAGS} ${LIBS}
27 changes: 12 additions & 15 deletions apps/st_app/linux/st_ref_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
*
****************************************************************************/

#include "../st_manager.h"
#include "../st_port.h"
#include "../st_resource_manager.h"
#include "st_manager.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";
Expand Down Expand Up @@ -71,8 +70,7 @@ get_resource_handler(oc_request_t *request)
strlen(color_temp_rsc_uri)) == 0) {
color_temp_resource_construct();
} else {
st_print_log("[ST_APP] invalid uri %s\n",
oc_string(request->resource->uri));
printf("[ST_APP] invalid uri %s\n", oc_string(request->resource->uri));
return false;
}

Expand All @@ -86,7 +84,7 @@ switch_resource_change(oc_rep_t *rep)
if (oc_rep_get_string(rep, power_prop_key, &m_power, &len)) {
strncpy(power, m_power, len);
power[len] = '\0';
st_print_log("[ST_APP] %s : %s\n", oc_string(rep->name), power);
printf("[ST_APP] %s : %s\n", oc_string(rep->name), power);

// TODO: device specific behavior.
}
Expand All @@ -96,7 +94,7 @@ static void
switchlevel_resource_change(oc_rep_t *rep)
{
if (oc_rep_get_int(rep, dimming_prop_key, &dimmingSetting)) {
st_print_log("[ST_APP] %s : %d\n", oc_string(rep->name), dimmingSetting);
printf("[ST_APP] %s : %d\n", oc_string(rep->name), dimmingSetting);

// TODO: device specific behavior.
}
Expand All @@ -106,7 +104,7 @@ static void
color_temp_resource_change(oc_rep_t *rep)
{
if (oc_rep_get_int(rep, ct_prop_key, &ct)) {
st_print_log("[ST_APP] %s : %d\n", oc_string(rep->name), ct);
printf("[ST_APP] %s : %d\n", oc_string(rep->name), ct);

// TODO: device specific behavior.
}
Expand All @@ -128,8 +126,7 @@ set_resource_handler(oc_request_t *request)
color_temp_resource_change(request->request_payload);
color_temp_resource_construct();
} else {
st_print_log("[ST_APP] invalid uri %s\n",
oc_string(request->resource->uri));
printf("[ST_APP] invalid uri %s\n", oc_string(request->resource->uri));
return false;
}

Expand All @@ -139,14 +136,14 @@ set_resource_handler(oc_request_t *request)
static bool
otm_confirm_handler(void)
{
st_print_log("[ST_APP] OTM request is comming. Will you confirm?[y/n]\n");
printf("[ST_APP] OTM request is comming. Will you confirm?[y/n]\n");
char ret[10];
scanf("%s", ret);
if (ret[0] == 'y' || ret[0] == 'Y') {
st_print_log("[ST_APP] CONFIRMED.\n");
printf("[ST_APP] CONFIRMED.\n");
return true;
} else {
st_print_log("[ST_APP] DENIED.\n");
printf("[ST_APP] DENIED.\n");
return false;
}
}
Expand All @@ -155,15 +152,15 @@ int
main(void)
{
if (st_manager_initialize() != 0) {
st_print_log("[ST_APP] st_manager_initialize failed.\n");
printf("[ST_APP] st_manager_initialize failed.\n");
return -1;
}

st_register_resource_handler(get_resource_handler, set_resource_handler);
st_register_otm_confirm_handler(otm_confirm_handler);

if (st_manager_start() != 0) {
st_print_log("[ST_APP] st_manager_start failed.\n");
printf("[ST_APP] st_manager_start failed.\n");
}

st_manager_stop();
Expand Down
21 changes: 9 additions & 12 deletions apps/st_app/tizenrt/st_ref_app_tizenrt.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
*
****************************************************************************/

#include "../st_manager.h"
#include "../st_port.h"
#include "../st_resource_manager.h"
#include "st_manager.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";
Expand Down Expand Up @@ -71,8 +70,7 @@ get_resource_handler(oc_request_t *request)
strlen(color_temp_rsc_uri)) == 0) {
color_temp_resource_construct();
} else {
st_print_log("[ST_APP] invalid uri %s\n",
oc_string(request->resource->uri));
printf("[ST_APP] invalid uri %s\n", oc_string(request->resource->uri));
return false;
}

Expand All @@ -86,7 +84,7 @@ switch_resource_change(oc_rep_t *rep)
if (oc_rep_get_string(rep, power_prop_key, &m_power, &len)) {
strncpy(power, m_power, len);
power[len] = '\0';
st_print_log("[ST_APP] %s : %s\n", oc_string(rep->name), power);
printf("[ST_APP] %s : %s\n", oc_string(rep->name), power);

// TODO: device specific behavior.
}
Expand All @@ -96,7 +94,7 @@ static void
switchlevel_resource_change(oc_rep_t *rep)
{
if (oc_rep_get_int(rep, dimming_prop_key, &dimmingSetting)) {
st_print_log("[ST_APP] %s : %d\n", oc_string(rep->name), dimmingSetting);
printf("[ST_APP] %s : %d\n", oc_string(rep->name), dimmingSetting);

// TODO: device specific behavior.
}
Expand All @@ -106,7 +104,7 @@ static void
color_temp_resource_change(oc_rep_t *rep)
{
if (oc_rep_get_int(rep, ct_prop_key, &ct)) {
st_print_log("[ST_APP] %s : %d\n", oc_string(rep->name), ct);
printf("[ST_APP] %s : %d\n", oc_string(rep->name), ct);

// TODO: device specific behavior.
}
Expand All @@ -128,8 +126,7 @@ set_resource_handler(oc_request_t *request)
color_temp_resource_change(request->request_payload);
color_temp_resource_construct();
} else {
st_print_log("[ST_APP] invalid uri %s\n",
oc_string(request->resource->uri));
printf("[ST_APP] invalid uri %s\n", oc_string(request->resource->uri));
return false;
}

Expand All @@ -141,7 +138,7 @@ int
stapp_main(void)
{
if (st_manager_initialize() != 0) {
st_print_log("[ST_APP] st_manager_initialize failed.\n");
printf("[ST_APP] st_manager_initialize failed.\n");
return -1;
}

Expand All @@ -150,7 +147,7 @@ stapp_main(void)
// TODO: callback registration. (ex. user confirm cb)

if (st_manager_start() != 0) {
st_print_log("[ST_APP] st_manager_start failed.\n");
printf("[ST_APP] st_manager_start failed.\n");
}

st_manager_stop();
Expand Down
Loading

0 comments on commit 72abe3c

Please sign in to comment.