blob: 5f101e001b50ecb2eaa1956c6f6fa7a5781d6c67 [file] [log] [blame]
Aleksander Drewnicki4fe00032014-10-09 14:45:11 +02001/*
2 * Copyright (C) 2014 Intel Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18#include "if-main.h"
19#include "../hal-utils.h"
20
21const btmce_interface_t *if_mce = NULL;
22
23/*
24 * Callback for get_remote_mas_instances
25 */
26static void btmce_remote_mas_instances_cb(bt_status_t status,
27 bt_bdaddr_t *bd_addr,
28 int num_instances,
29 btmce_mas_instance_t *instances)
30{
Aleksander Drewnicki5deee3d2014-10-09 14:45:12 +020031 int i;
32
33 haltest_info("%s: status=%s bd_addr=%s num_instance=%d\n", __func__,
34 bt_status_t2str(status), bdaddr2str(bd_addr),
35 num_instances);
36
37 for (i = 0; i < num_instances; i++)
38 haltest_info("id=%d scn=%d msg_types=%d name=%s\n",
39 instances[i].id, instances[i].scn,
40 instances[i].msg_types, instances[i].p_name);
Aleksander Drewnicki4fe00032014-10-09 14:45:11 +020041}
42
43static btmce_callbacks_t mce_cbacks = {
44 .size = sizeof(mce_cbacks),
45 .remote_mas_instances_cb = btmce_remote_mas_instances_cb,
46};
47
48/* init */
49
50static void init_p(int argc, const char **argv)
51{
52 RETURN_IF_NULL(if_mce);
53
54 EXEC(if_mce->init, &mce_cbacks);
55}
56
Aleksander Drewnicki9c53fe32014-10-09 14:45:14 +020057static void get_remote_mas_instances_c(int argc, const char **argv,
58 enum_func *enum_func, void **user)
59{
60 if (argc == 3) {
61 *user = NULL;
62 *enum_func = enum_devices;
63 }
64}
65
Aleksander Drewnicki4fe00032014-10-09 14:45:11 +020066/* search for MAS instances on remote device */
67
68static void get_remote_mas_instances_p(int argc, const char **argv)
69{
Aleksander Drewnicki4c2386b2014-10-09 14:45:13 +020070 bt_bdaddr_t addr;
71
72 RETURN_IF_NULL(if_mce);
73 VERIFY_ADDR_ARG(2, &addr);
74
75 EXEC(if_mce->get_remote_mas_instances, &addr);
Aleksander Drewnicki4fe00032014-10-09 14:45:11 +020076}
77
78static struct method methods[] = {
79 STD_METHOD(init),
Aleksander Drewnicki9c53fe32014-10-09 14:45:14 +020080 STD_METHODCH(get_remote_mas_instances, "<addr>"),
Aleksander Drewnicki4fe00032014-10-09 14:45:11 +020081 END_METHOD
82};
83
84const struct interface mce_if = {
85 .name = "mce",
86 .methods = methods
87};