언어 설정

Menu
Sites
Language
Bluetooth AVRCP controller returns BT_ERROR_NOT_SUPPORTED

Hello everyone,

I'm new at programming with tizen, I tried yesterday a small watchface with a bluetooth avrcp controller. Bluetooth is working and I can scan my devices, but when ich found my device and want to use the audio controller, it returns with the error "BT_ERROR_NOT_SUPPORTED". I don't understand why this is?

I started with a new tizen project in tizen studio and selected "watch", cause i want a new watch face. I initialize BT via bt_initialize() -> working. then I call  bt_avrcp_control_initialize -> not working.

Can I not use AVRCP at a watch face? Or do i have to do something before call avrcp_control_initilize?

#include <tizen.h>
#include <bluetooth.h>
#include "classiccontrolwatch.h"

typedef struct appdata {
    Evas_Object *win;
	Evas_Object *conform;
	Evas_Object *label;
} appdata_s;

#define TEXT_BUF_SIZE 256

static void
update_watch(appdata_s *ad, watch_time_h watch_time, int ambient)
{
	char watch_text[TEXT_BUF_SIZE];
	int hour24, minute, second;

	if (watch_time == NULL)
		return;

	watch_time_get_hour24(watch_time, &hour24);
	watch_time_get_minute(watch_time, &minute);
	watch_time_get_second(watch_time, &second);
	if (!ambient) {
		snprintf(watch_text, TEXT_BUF_SIZE, "<align=center>Hello Watch<br/>%02d:%02d:%02d</align>",
			hour24, minute, second);
	} else {
		snprintf(watch_text, TEXT_BUF_SIZE, "<align=center>Hello Watch<br/>%02d:%02d</align>",
			hour24, minute);
	}

	elm_object_text_set(ad->label, watch_text);
}

static void
create_base_gui(appdata_s *ad, int width, int height)
{
	int ret;
	watch_time_h watch_time = NULL;

	/* Window */
	ret = watch_app_get_elm_win(&ad->win);
	if (ret != APP_ERROR_NONE) {
		dlog_print(DLOG_ERROR, LOG_TAG, "failed to get window. err = %d", ret);
		return;
	}

	evas_object_resize(ad->win, width, height);

	/* Conformant */
	ad->conform = elm_conformant_add(ad->win);
	evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	elm_win_resize_object_add(ad->win, ad->conform);
	evas_object_show(ad->conform);

	/* Label*/
	ad->label = elm_label_add(ad->conform);
	evas_object_resize(ad->label, width, height / 3);
	evas_object_move(ad->label, 0, height / 3);
	evas_object_show(ad->label);

	ret = watch_time_get_current_time(&watch_time);
	if (ret != APP_ERROR_NONE)
		dlog_print(DLOG_ERROR, LOG_TAG, "failed to get current time. err = %d", ret);

	update_watch(ad, watch_time, 0);
	watch_time_delete(watch_time);

	/* Show window after base gui is set up */
	evas_object_show(ad->win);
}

static bool
app_create(int width, int height, void *data)
{
	/* Hook to take necessary actions before main event loop starts
		Initialize UI resources and application's data
		If this function returns true, the main loop of application starts
		If this function returns false, the application is terminated */
	appdata_s *ad = data;

	create_base_gui(ad, width, height);

	return true;
}

static void
app_control(app_control_h app_control, void *data)
{
	/* Handle the launch request. */
}

static void
app_pause(void *data)
{
	/* Take necessary actions when application becomes invisible. */
}

static void
app_resume(void *data)
{
	/* Take necessary actions when application becomes visible. */
}

static void
app_terminate(void *data)
{
	/* Release all resources. */
}

static void
app_time_tick(watch_time_h watch_time, void *data)
{
	/* Called at each second while your app is visible. Update watch UI. */
	appdata_s *ad = data;
	update_watch(ad, watch_time, 0);
}

static void
app_ambient_tick(watch_time_h watch_time, void *data)
{
	/* Called at each minute while the device is in ambient mode. Update watch UI. */
	appdata_s *ad = data;
	update_watch(ad, watch_time, 1);
}

static void
app_ambient_changed(bool ambient_mode, void *data)
{
	/* Update your watch UI to conform to the ambient mode */
}

static void
watch_app_lang_changed(app_event_info_h event_info, void *user_data)
{
	/*APP_EVENT_LANGUAGE_CHANGED*/
	char *locale = NULL;
	app_event_get_language(event_info, &locale);
	elm_language_set(locale);
	free(locale);
	return;
}

static void
watch_app_region_changed(app_event_info_h event_info, void *user_data)
{
	/*APP_EVENT_REGION_FORMAT_CHANGED*/
}

static void myCallback(int result, bt_device_sdp_info_s *sdp_info, void *user_data){
	for(int i = 0; i< sdp_info->service_count;i++){
		dlog_print(DLOG_ERROR, LOG_TAG, "BT is callback. info = %s", sdp_info->service_uuid[i]);
	}
}

static void remoteControlCallback(bool connected, const char* remote_address, void *user_data){
	if(connected){

	bt_avrcp_control_send_player_command(BT_AVRCP_CONTROL_PLAY);
	}
}

static bool forEach(bt_device_info_s *device_info, void *user_data){
	dlog_print(DLOG_ERROR, LOG_TAG, "Got device infoo %s", device_info->remote_name);
	if(strcmp(device_info->remote_name, "Galaxy S9") == 0){
		int i = bt_avrcp_control_connect(device_info->remote_address);
			dlog_print(DLOG_ERROR, LOG_TAG, "BT is not failed. err = %d", i);
	return false;
	}else{
		return true;
	}
}

int
main(int argc, char *argv[])
{
	appdata_s ad = {0,};
	appdata_s ad2 = {0,};
	appdata_s ad3 = {0,};
	int ret = 0;

	watch_app_lifecycle_callback_s event_callback = {0,};
	app_event_handler_h handlers[5] = {NULL, };

	event_callback.create = app_create;
	event_callback.terminate = app_terminate;
	event_callback.pause = app_pause;
	event_callback.resume = app_resume;
	event_callback.app_control = app_control;
	event_callback.time_tick = app_time_tick;
	event_callback.ambient_tick = app_ambient_tick;
	event_callback.ambient_changed = app_ambient_changed;

	watch_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED],
		APP_EVENT_LANGUAGE_CHANGED, watch_app_lang_changed, &ad);
	watch_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED],
		APP_EVENT_REGION_FORMAT_CHANGED, watch_app_region_changed, &ad);

	int i = bt_initialize();
	if(i != BT_ERROR_NONE){
		dlog_print(DLOG_ERROR, LOG_TAG, "BT is failed. err = %d", i);
	}	 bt_avrcp_control_deinitialize() ;
	  i = bt_avrcp_control_initialize(&remoteControlCallback, &ad3); //RETURNS BT_NOT_SUPPORTED

				dlog_print(DLOG_ERROR, LOG_TAG, "BT is not failed. err = %d", i);
	i =  bt_device_set_service_searched_cb(&myCallback, &ad2);
	 if(i != BT_ERROR_NONE){
		 		dlog_print(DLOG_ERROR, LOG_TAG, "BT is failed 2. err = %d", i);
		 	}

	i = bt_adapter_foreach_bonded_device(&forEach ,&ad2);



	 if(i != BT_ERROR_NONE){
	 		dlog_print(DLOG_ERROR, LOG_TAG, "BT is failed 3. err = %d", i);
	 	}


	ret = watch_app_main(argc, argv, &event_callback, &ad);



	if (ret != APP_ERROR_NONE) {
		dlog_print(DLOG_ERROR, LOG_TAG, "watch_app_main() is failed. err = %d", ret);
	}
	 bt_avrcp_control_deinitialize() ;
	 bt_deinitialize();
	return ret;
}

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<manifest xmlns="http://tizen.org/ns/packages" api-version="4.0" package="de.schoendort" version="1.0.0">
    <profile name="wearable"/>
    <watch-application ambient-support="true" appid="de.schoendort" exec="classiccontrolwatch">
        <label>classiccontrolwatch</label>
        <icon>classiccontrolwatch.png</icon>
    </watch-application>
    <privileges>
        <privilege>http://tizen.org/privilege/mediacontroller.client</privilege>
        <privilege>http://tizen.org/privilege/bluetooth</privilege>
        <privilege>http://tizen.org/privilege/alarm.set</privilege>
    </privileges>
    <feature name="http://tizen.org/feature/network.bluetooth">true</feature>
    <feature name="http://tizen.org/feature/network.bluetooth.audio.media">true</feature>
    <feature name="http://tizen.org/feature/network.bluetooth.audio.controller">true</feature>
</manifest>

 

Edited by: Schoendorfer on 09 9월, 2019