Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose the API implemented for the Tizen service app to the template #1620

Merged
merged 1 commit into from May 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions config/tizen/template/IoTjsApp/project/src/main.c
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
Expand Up @@ -14,7 +14,7 @@
*/

#include "iotjs.h"
#include "iotjs_module_tizen.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sample assumes that an include path containing iotjs_tizen_service_app.h is set in compile time. So we can use iotjs_tizen_service_app.h.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed it.

#include "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
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 */