Aleksander Drewnicki | 4fe0003 | 2014-10-09 14:45:11 +0200 | [diff] [blame] | 1 | /* |
| 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 | |
| 21 | const btmce_interface_t *if_mce = NULL; |
| 22 | |
| 23 | /* |
| 24 | * Callback for get_remote_mas_instances |
| 25 | */ |
| 26 | static 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 Drewnicki | 5deee3d | 2014-10-09 14:45:12 +0200 | [diff] [blame] | 31 | 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 Drewnicki | 4fe0003 | 2014-10-09 14:45:11 +0200 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | static 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 | |
| 50 | static 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 Drewnicki | 9c53fe3 | 2014-10-09 14:45:14 +0200 | [diff] [blame] | 57 | static 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 Drewnicki | 4fe0003 | 2014-10-09 14:45:11 +0200 | [diff] [blame] | 66 | /* search for MAS instances on remote device */ |
| 67 | |
| 68 | static void get_remote_mas_instances_p(int argc, const char **argv) |
| 69 | { |
Aleksander Drewnicki | 4c2386b | 2014-10-09 14:45:13 +0200 | [diff] [blame] | 70 | 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 Drewnicki | 4fe0003 | 2014-10-09 14:45:11 +0200 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | static struct method methods[] = { |
| 79 | STD_METHOD(init), |
Aleksander Drewnicki | 9c53fe3 | 2014-10-09 14:45:14 +0200 | [diff] [blame] | 80 | STD_METHODCH(get_remote_mas_instances, "<addr>"), |
Aleksander Drewnicki | 4fe0003 | 2014-10-09 14:45:11 +0200 | [diff] [blame] | 81 | END_METHOD |
| 82 | }; |
| 83 | |
| 84 | const struct interface mce_if = { |
| 85 | .name = "mce", |
| 86 | .methods = methods |
| 87 | }; |