Skip to content

Commit

Permalink
Expose the API implemented for the Tizen service app to the template
Browse files Browse the repository at this point in the history
IoT.js-DCO-1.0-Signed-off-by: Hosung Kim hs852.kim@samsung.com
  • Loading branch information
hs0225 committed May 3, 2018
1 parent 5af9e46 commit d6e1320
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 48 deletions.
3 changes: 3 additions & 0 deletions config/tizen/template/IoTjsApp/project/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ void service_app_terminate(void *data)
void service_app_control(app_control_h app_control, void *data)
{
// Todo: add your code here.

// Emit 'appControl' event to the JavaScript side.
iotjs_tizen_app_control_cb(app_control, data);
return;
}

Expand Down
47 changes: 0 additions & 47 deletions include/iotjs_module_tizen.h

This file was deleted.

2 changes: 1 addition & 1 deletion samples/tizen-bridge-native/tizen_bridge_native.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/

#include "iotjs.h"
#include "iotjs_module_tizen.h"
#include "platform/tizen/iotjs_tizen_service_app.h"

/* thread */
#include <pthread.h>
Expand Down
18 changes: 18 additions & 0 deletions src/platform/tizen/iotjs_tizen_service_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,35 @@
#ifndef IOTJS_TIZEN_SERVICE_APP_H
#define IOTJS_TIZEN_SERVICE_APP_H

#include <app_control.h>
#include <string.h>

#ifdef __cplusplus
#define IOTJS_EXTERN_C extern "C"
#else /* !__cplusplus */
#define IOTJS_EXTERN_C extern
#endif /* !__cplusplus */

typedef void (*user_callback_t)(int error, const char* data);


IOTJS_EXTERN_C int iotjs_service_app_start(int argc, char** argv, char* js_path,
void* event_callbacks,
void* user_data);

IOTJS_EXTERN_C
void iotjs_tizen_app_control_cb(app_control_h app_control, void* user_data);

IOTJS_EXTERN_C
int iotjs_tizen_bridge_native(const char* fn_name, unsigned fn_name_size,
const char* message, unsigned message_size,
user_callback_t cb);

#define IOTJS_TIZEN_CALL_JFUNC(name, msg, cb) \
({ \
if (name != NULL && (msg) != NULL) \
iotjs_tizen_bridge_native(name, strlen(name), msg, strlen(msg), cb); \
})


#endif /* IOTJS_TIZEN_SERVICE_APP_H */

0 comments on commit d6e1320

Please sign in to comment.