return ST_THINGS_ERROR_OPERATION_FAILED;
}
-int st_things_stop(void)
-{
- ST_LOG_ENTRY(ST_INFO);
-
- if (STACK_STARTED != g_stack_status) {
- int ret_val = ST_THINGS_ERROR_OPERATION_FAILED;
- switch (g_stack_status) {
- case STACK_NOT_INITIALIZED:
- ST_LOG(ST_ERROR, "Stack is not initialized.");
- ret_val = ST_THINGS_ERROR_STACK_NOT_INITIALIZED;
- break;
- case STACK_INITIALIZED:
- ST_LOG(ST_ERROR, "Stack is not started.");
- ret_val = ST_THINGS_ERROR_STACK_NOT_STARTED;
- break;
- default:
- ST_LOG_V(ST_ERROR, "Invalid stack state: %d.", g_stack_status);
- break;
- }
-
- ST_LOG_EXIT(ST_INFO);
- return ret_val;
- }
-
- int result = 0;
-
- // Terminate DA Stack.
- if (1 != (result = things_stop())) {
- ST_LOG_V(ST_ERROR, "things_stop failed (result:%d)", result);
- ST_LOG_EXIT(ST_INFO);
- return ST_THINGS_ERROR_OPERATION_FAILED;
- }
-
- g_stack_status = STACK_INITIALIZED;
-
- ST_LOG_EXIT(ST_INFO);
- ST_LOG_DEINIT();
- return ST_THINGS_ERROR_NONE;
-}
-
int st_things_register_request_cb(st_things_get_request_cb get_cb, st_things_set_request_cb set_cb)
{
ST_LOG_ENTRY(ST_INFO);
int things_reset(void *remote_owner, things_es_enrollee_reset_e reset_type);
-int things_stop(void);
-
typedef int (*things_handle_request_func_type)(struct things_resource_s *p_resource);
int things_register_handle_request_func(things_handle_request_func_type get_func, things_handle_request_func_type set_func);
THINGS_LOG_V_ERROR(THINGS_ERROR, TAG, "Easy Setup Memory allocation is failed.");
return ESM_ERROR;
}
-// es_device_property device_property = {
-// {{WiFi_11G, WiFi_11N, WiFi_11AC, WiFi_EOF}, WiFi_5G}, {"Test Device"}
-// };
if (server_builder != NULL) {
g_server_builder = server_builder;
if (ESM_OK != esm_init_easysetup(1, NULL)) {
THINGS_LOG_ERROR(THINGS_ERROR, TAG, "Easy-Setup Module Initialization failed");
- things_stop();
return NULL;
}
bool esm_get_network_status(void)
{
- //THINGS_LOG_D(THINGS_DEBUG, TAG, "Enter.");
-
bool is_ok = false;
if (things_is_net_initialize() != 1) {
es_set_state(ES_STATE_INIT);
}
- //THINGS_LOG_D(THINGS_DEBUG, TAG, "Exit.");
return is_ok;
}
{
if (func) {
g_pin_generated_cb = func;
- // SetGeneratePinCB(generate_pin_cb);
return 1;
} else {
THINGS_LOG_ERROR(THINGS_ERROR, TAG, "Invalid PINGeneratedCB function");
{
if (func) {
g_pin_close_cb = func;
- // SetGeneratePinCB(generate_pin_cb);
return 1;
} else {
THINGS_LOG_ERROR(THINGS_ERROR, TAG, "Invalid PINGeneratedCB function");
{
if (func) {
g_user_confirm_cb = func;
-
- // SetUserConfirmCB(NULL, get_user_confirmation);
return 1;
} else {
THINGS_LOG_ERROR(THINGS_ERROR, TAG, "Invalid UserConformCB function");
THINGS_LOG_D(THINGS_DEBUG, TAG, "RESOURCE TO REGISTER : %s", resource->uri);
memset(res_uri, 0, (size_t) MAX_URI_LENGTH);
- /*SVACE warning fix */
strncat(res_uri, resource->uri, MAX_URI_LENGTH);
ret = p_builder->create_resource(p_builder, res_uri, resource->resource_types[0], resource->interface_types[0], CHECK_DISCOVERABLE(resource->policy), CHECK_OBSERVABLE(resource->policy), CHECK_SECURE(resource->policy));
device = (st_device_s *) hashmap_get(g_device_hmap, (unsigned long)device_num);
if (NULL != device) {
- /*SVACE warning fix */
snprintf(id, sizeof(id), "%d", device->no);
THINGS_LOG_D(THINGS_DEBUG, TAG, "==================== Device (%s) ====================", id);
return Parse_things_files(devJsonPath);
}
-//
-
int dm_termiate_module()
{
// Need to backup all the keys in order to delete from the map.
// the result of additional verification
result = 0;
- // if(gValidator == NULL )
- // {s
- // THINGS_LOG_ERROR(THINGS_ERROR, TAG, "Validator not registered");
- // goto EXIT_VALIDATION;
- // }
-
// If the given resource does not have sensor nor read interface type..
if (!(resource->things_is_supporting_interface_type(resource, OIC_INTERFACE_SENSOR))
&& !(resource->things_is_supporting_interface_type(resource, OC_RSRVD_INTERFACE_READ))) {
{
g_quit_flag = false;
-//#ifdef __ST_THINGS_RTOS__
-// pthread_create_rtos(&g_req_handle, NULL, message_handling_loop, (void *)NULL, THINGS_STACK_MESSAGE_HANDLING_THREAD);
-//#else
-// things_thread_create (&g_req_handle, NULL, message_handling_loop, (void *)NULL);
-//#endif
-
}
void deinit_handler()
return res;
}
-// BTD
things_resource_s *clone_resource_inst(things_resource_s *pori)
{
if (pori == NULL) {
return OIC_SEC_OK;
}
-// ++ Added by Chul Lee : To support MAC based UUID
+// To support MAC based UUID
int sm_generate_mac_based_device_id(bool is_forced)
{
THINGS_LOG_D(THINGS_DEBUG, TAG, "In %s", __func__);
return res;
}
-// ++ Added by Chul Lee : To support MAC based UUID
+// To support MAC based UUID
//
int sm_init_things_security(int auth_type, const char *db_path)
}
//
-// ++ Added by Chul Lee : to test certificate based (D)TLS connection for D2D & D2S
+// To test certificate based (D)TLS connection for D2D & D2S
#ifndef _EXCLUDE_TEST_KEY_
static OicSecKey_t primary_cert;
THINGS_LOG_D(THINGS_DEBUG, TAG, THINGS_FUNC_ENTRY);
if (OCStartPresence(0) == OC_STACK_OK) {
- /* while (!g_quit_flag)
- {
- g_presence_flag++;
- //THINGS_LOG_D(THINGS_DEBUG, TAG, "COUNT : %d", g_presence_flag);
- if (g_presence_flag > g_presence_duration)
- {
- g_presence_flag = 0;
- OCStopPresence();
- THINGS_LOG(THINGS_INFO, TAG, "Stop Sending Presence Packet");
- is_presence = false;
- break;
- }
- sleep(1);
- }
- */
+ THINGS_LOG_D(THINGS_DEBUG, TAG, "OC Stack is available");
} else {
THINGS_LOG_ERROR(THINGS_ERROR, TAG, "OCStartPresence Error");
}
if (1 == isObserable) {
rsc_properties |= OC_OBSERVABLE;
}
- // if( strstr(uri, URI_ACCESSPOINTLIST) == 0
- // && strstr(uri, URI_PROVINFO) == 0 )
+
if (1 == isSecure) {
#ifdef __SECURED__
rsc_properties |= OC_SECURE;
void init_builder(struct things_server_builder_s *builder, request_handler_cb cb)
{
- //if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK)
- //if(OC_STACK_OK != OCInit1 (OC_CLIENT_SERVER,OC_IP_USE_V4, OC_IP_USE_V4) )
OCTransportAdapter m_transport = (OC_ADAPTER_IP | OC_ADAPTER_TCP);
if (OC_STACK_OK != OCInit2(OC_CLIENT_SERVER, OC_IP_USE_V4, OC_IP_USE_V4, m_transport)) {
THINGS_LOG_ERROR(THINGS_ERROR, TAG, "RESOURCE SERVER START FAILED");
static list_s *list = NULL;
static const char INTERVAL_ARRAY[] = "inarray";
static const char INTERVAL[] = "in";
-things_ping_s *pPing = NULL; //SKKIM for ping command
static void *thd_ping_loop(things_ping_s *ping);
static OCStackApplicationResult discover_ping_resource_handler(void *ctx, OCDoHandle handle, OCClientResponse *client_response);
res = true;
}
- pPing = NULL;
THINGS_LOG(THINGS_DEBUG, TAG, "Exit.");
return res;
}
sleep(sleepTime);
} while (!ping->continue_thread);
- pPing = ping;
int sleepDelay = 10;
THINGS_LOG_D(THINGS_DEBUG, TAG, "Start common-Ping request for /oic/ping to Cloud(%s)", ping->addr);
unset_mask(ping, PING_ST_STARTTHREAD | PING_ST_DISCOVERY | PING_ST_REQUEST | PING_ST_INTUPDATE | PING_ST_TIMEOUT);
ping->continue_thread = false;
set_def_interval(ping);
- pPing = NULL;
THINGS_LOG(THINGS_DEBUG, TAG, "Exit.");
return (void *)1;
}
-//void CommandPing() //SKKIM for ping command
-//{
-// if (pPing != NULL) {
-// send_things_ping_request(pPing);
-// }
-//}
-
static OCStackApplicationResult discover_ping_resource_handler(void *ctx, OCDoHandle handle, OCClientResponse *client_response)
{
THINGS_LOG(THINGS_DEBUG, TAG, "Enter.");
return 0;
}
- /*[Jaehong] (Need to consider trim to remove space in query) */
// Remove empty space
char queries[MAX_INPUT_QUERY_LEN + 1] = { 0, };
int index = 0;
if (0 != sm_init_things_security(auty_type, dm_get_svrdb_file_path())) {
THINGS_LOG_ERROR(THINGS_ERROR, TAG, "Failed to initialize OICSecurity features");
- things_stop();
return 0;
}
sm_set_otm_event_handler(otm_event_cb);
g_req_handler = get_handler_instance();
if (NULL == g_req_handler) {
THINGS_LOG_ERROR(THINGS_ERROR, TAG, "Failed to initialize Request Handler");
- things_stop();
return 0;
}
// Will be refactored to received callbacks for GET/PUT/POST/DELETE/OBSERVE ..
g_server_builder = get_builder_instance();
if (NULL == g_server_builder) {
THINGS_LOG_ERROR(THINGS_ERROR, TAG, "Failed to initialize Resource Server");
- things_stop();
return 0;
}
//5. Generate MAC based device UUID
if (0 != sm_generate_mac_based_device_id(false)) {
THINGS_LOG(THINGS_WARNING, TAG, "Failed to generate MAC based device_id");
- things_stop();
return 0;
}
#endif
// 6. Register Device-ID & Resources
if (dm_register_device_id() == false) {
THINGS_LOG_ERROR(THINGS_ERROR, TAG, "Failed to register Device ID");
- things_stop();
return 0;
}
if (!dm_register_resource(g_server_builder)) {
THINGS_LOG_ERROR(THINGS_ERROR, TAG, "Failed to register Resource");
- things_stop();
return 0;
}
// 7. Initiate Easy-Setup & Login to Cloud
if (ESM_OK != esm_init_easysetup(0, g_server_builder)) {
THINGS_LOG_ERROR(THINGS_ERROR, TAG, "Failed to initialize Easy-Setup Module");
- things_stop();
return 0;
}
// Register Callback
if (es_cloud_init(g_server_builder) == NULL) {
THINGS_LOG_ERROR(THINGS_ERROR, TAG, "Failed to initialize Cloud");
- things_stop();
return 0;
}
return res;
}
-int things_stop(void)
-{
- pthread_mutex_lock(&g_things_stop_mutex);
-
- THINGS_LOG_D(THINGS_DEBUG, TAG, THINGS_FUNC_ENTRY);
- g_quit_flag = 1;
- is_things_module_inited = 0;
-
- pthread_mutex_lock(&m_thread_oic_reset);
- if (b_thread_things_reset == true) {
- b_reset_continue_flag = false;
- h_thread_things_reset = 0;
- b_thread_things_reset = false;
- }
- pthread_mutex_unlock(&m_thread_oic_reset);
-
- THINGS_LOG_D(THINGS_DEBUG, TAG, "Terminate Cloud Session Managing");
- es_cloud_terminate();
-
- THINGS_LOG_D(THINGS_DEBUG, TAG, "Terminate EasySetup");
- esm_terminate_easysetup();
-
- if (g_server_builder != NULL) {
- g_server_builder->deinit_module(g_server_builder);
- release_builder_instance(g_server_builder);
- g_server_builder = NULL;
- }
- if (g_req_handler != NULL) {
- g_req_handler->deinit_module();
- release_handler_instance(g_req_handler);
- g_req_handler = NULL;
- }
- // Need to add memory release for the Queue..
- THINGS_LOG_D(THINGS_DEBUG, TAG, THINGS_FUNC_EXIT);
-
- pthread_mutex_unlock(&g_things_stop_mutex);
- return 1;
-}
-
int things_register_confirm_reset_start_func(things_reset_confirm_func_type func)
{
if (func != NULL) {