/*
- * Bluetooth-frwk
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>
- * Girishashok Joshi <girish.joshi@samsung.com>
- * Chanyeol Park <chanyeol.park@samsung.com>
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <stdint.h>
#include <string.h>
#include <glib.h>
-#include <dbus/dbus-glib.h>
-
#include "bluetooth-api.h"
GMainLoop *main_loop = NULL;
-typedef struct
-{
+typedef struct {
const char *tc_name;
int tc_code;
} tc_table_t;
-tc_table_t tc_table[] =
-{
+tc_table_t tc_table[] = {
{"Send alert to remote le device" , 1},
{"Set Link loss alert" , 2},
};
#define tc_result(success, tc_index) \
- TC_PRT("Test case [%d - %s] %s", tc_table[tc_index].tc_code, tc_table[tc_index].tc_name, ((success == TC_PASS)?"Success":"Failed"));
+ TC_PRT("Test case [%d - %s] %s", tc_table[tc_index].tc_code, tc_table[tc_index].tc_name, ((success == TC_PASS) ? "Success" : "Failed"));
char *g_alert_char_handle = NULL;
guint8 g_alert_level = 0;
addr = get_bd_from_file(BD_ADDR_FILE);
if (addr) {
- TC_PRT("Remote bd adress from file: %s", addr);
+ TC_PRT("Remote bd address from file: %s", addr);
convert_addr_string_to_addr_type(device_address, addr);
+ g_free(addr);
return;
}
TC_PRT("Enter bd address: ");
- scanf("%s", str_address);
+ int ret = 0;
+ ret = scanf("%s", str_address);
+ if (ret < 0)
+ TC_PRT("Some read error");
TC_PRT("You have entered bd address %s\n", str_address);
convert_addr_string_to_addr_type(device_address, str_address);
}
static void __accept_alert_level()
{
TC_PRT("Enter alert level \n 0 - no alert 1 - mild alert 2 - High alert : ");
- scanf("%d", &g_alert_level);
- TC_PRT("You have selected alert level %d ", g_alert_level);
+ int ret = 0;
+ ret = scanf("%c", &g_alert_level);
+ if (ret < 0)
+ TC_PRT("Some read error");
+ TC_PRT("You have selected alert level %hu ", g_alert_level);
}
int test_input_callback(void *data)
{
TC_PRT("bluetooth framework TC startup");
- if (!g_thread_supported())
- g_thread_init(NULL);
-
- dbus_g_thread_init();
+ dbus_threads_init_default();
- g_type_init();
main_loop = g_main_loop_new(NULL, FALSE);
}
void cleanup()
{
TC_PRT("bluetooth framework TC cleanup");
- if ( main_loop != NULL)
+ if (main_loop != NULL)
g_main_loop_unref(main_loop);
}
{
TC_PRT(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
TC_PRT("bt event callback 0x%04x", event);
- switch(event) {
+ switch (event) {
case BLUETOOTH_EVENT_GATT_GET_CHAR_FROM_UUID:
{
TC_PRT("BLUETOOTH_EVENT_GATT_GET_CHAR_FROM_UUID");
unsigned int len = 0;
int test_id;
- if (g_io_channel_read(chan, buf, sizeof(buf), &len) !=
- G_IO_ERROR_NONE) {
+ if (g_io_channel_read_chars(chan, buf, sizeof(buf),
+ &len, NULL) == G_IO_STATUS_ERROR) {
printf("IO Channel read error");
return FALSE;
}
- printf("%s\n",buf);
+ printf("%s\n", buf);
tc_usage_print();
test_id = atoi(buf);