2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 /*****************************************************************************
19 *****************************************************************************/
26 /*****************************************************************************
28 *****************************************************************************/
33 /*****************************************************************************
34 * Application Service Platform Daemon headers
35 *****************************************************************************/
36 #include "asp-manager-util.h"
37 #include "asp-service.h"
38 #include "asp-session.h"
41 /*****************************************************************************
43 *****************************************************************************/
45 /* TODO : define service data structure */
47 /*****************************************************************************
49 *****************************************************************************/
51 /* TODO : define local memory for service data structure */
53 extern asp_tech_ops_s asp_tech_p2p_ops;
54 extern asp_tech_ops_s asp_tech_ble_ops;
55 extern asp_tech_ops_s asp_tech_nfc_ops;
56 extern asp_tech_ops_s asp_tech_infra_ops;
57 extern asp_tech_ops_s asp_tech_nan_ops;
59 asp_tech_ops_s *asp_techs[] = {
69 /*****************************************************************************
70 * Local Functions Definition
71 *****************************************************************************/
75 __ASP_LOG_FUNC_ENTER__;
78 result = asp_techs[ASP_TECH_P2P]->init();
80 ASP_LOGE("Failed to initialize p2p");
81 /* TODO : exclude p2p technology */
85 result = asp_techs[ASP_TECH_INFRA]->init();
87 ASP_LOGE("Failed to initialize infra");
88 /* TODO : exclude infra technology */
91 __ASP_LOG_FUNC_EXIT__;
95 void asp_tech_deinit()
97 __ASP_LOG_FUNC_ENTER__;
100 result = asp_techs[ASP_TECH_P2P]->deinit();
102 ASP_LOGE("Failed to deinitialize p2p");
103 /* TODO : exclude p2p technology */
107 result = asp_techs[ASP_TECH_INFRA]->deinit();
109 ASP_LOGE("Failed to deinitialize infra");
110 /* TODO : exclude infra technology */
113 __ASP_LOG_FUNC_EXIT__;
117 int asp_tech_advertise(int tech, asp_service_advertise_s *service, int replace)
119 __ASP_LOG_FUNC_ENTER__;
124 for (i = ASP_TECH_P2P; i != ASP_TECH_MAX; i++) {
125 tech_idx = 1 << (i - 1);
126 if (tech & tech_idx) {
127 ASP_LOGD("Advertise using tech %d", tech);
128 result = asp_techs[i]->advertise(service, replace);
134 __ASP_LOG_FUNC_EXIT__;
138 int asp_tech_cancel_advertise(int tech, asp_service_advertise_s *service)
140 __ASP_LOG_FUNC_ENTER__;
145 for (i = ASP_TECH_P2P; i != ASP_TECH_MAX; i++) {
146 tech_idx = 1 << (i - 1);
147 if (tech & tech_idx) {
148 ASP_LOGD("Cancel advertise using tech %d", tech_idx);
149 result = asp_techs[i]->cancel_advertise(service);
154 __ASP_LOG_FUNC_EXIT__;
158 int asp_tech_seek(int tech, asp_service_seek_s *service)
160 __ASP_LOG_FUNC_ENTER__;
165 for (i = 1; i != ASP_TECH_MAX; i++) {
166 tech_idx = 1 << (i - 1);
167 if (tech & tech_idx) {
168 ASP_LOGD("Seek service using tech %d", tech_idx);
169 result = asp_techs[i]->seek(service);
174 __ASP_LOG_FUNC_EXIT__;
178 int asp_tech_cancel_seek(int tech, asp_service_seek_s *service)
180 __ASP_LOG_FUNC_ENTER__;
185 for (i = 1; i != ASP_TECH_MAX; i++) {
186 tech_idx = 1 << (i - 1);
187 if (tech & tech_idx) {
188 ASP_LOGD("Cancel seek service using tech %d", tech_idx);
189 result = asp_techs[i]->cancel_seek(service);
194 __ASP_LOG_FUNC_EXIT__;
198 int asp_tech_connect_session(int tech, asp_connect_session_params *params)
200 __ASP_LOG_FUNC_ENTER__;
205 for (i = 1; i != ASP_TECH_MAX; i++) {
206 tech_idx = 1 << (i - 1);
207 if (tech & tech_idx) {
208 ASP_LOGD("Connect session using tech %d", tech_idx);
209 result = asp_techs[i]->connect_session(params);
215 __ASP_LOG_FUNC_EXIT__;
219 int asp_tech_confirm_session(int tech, unsigned char *session_mac, int session_id, int confirm, const char *pin)
221 __ASP_LOG_FUNC_ENTER__;
226 for (i = 1; i != ASP_TECH_MAX; i++) {
227 tech_idx = 1 << (i - 1);
228 if (tech & tech_idx) {
229 ASP_LOGD("Confirm session using tech %d", tech_idx);
230 result = asp_techs[i]->confirm_session(session_mac, session_id, confirm, pin);
236 __ASP_LOG_FUNC_EXIT__;
240 int asp_tech_destroy_connection(int tech)
242 __ASP_LOG_FUNC_ENTER__;
247 for (i = 1; i != ASP_TECH_MAX; i++) {
248 tech_idx = 1 << (i - 1);
249 if (tech & tech_idx) {
250 ASP_LOGD("Destroy connection using tech %d", tech_idx);
251 result = asp_techs[i]->destroy_connection();
256 __ASP_LOG_FUNC_EXIT__;