4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YoungHwan An <younghwan_.an@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
24 #include "mm_radio_rt_api_test.h"
26 #define MENU_ITEM_MAX 20
27 #define _MAX_INPUT_STRING_ 100
29 static int __menu(void);
30 static void __call_api(int choosen);
31 static int __msg_rt_callback(int message, void *param, void *user_param);
33 static MMHandleType g_my_radio = 0;
35 void __call_api(int choosen)
37 int ret = MM_ERROR_NONE;
41 RADIO_TEST__(mm_radio_create(&g_my_radio);)
42 RADIO_TEST__(mm_radio_set_message_callback(g_my_radio, __msg_rt_callback, g_my_radio);)
47 RADIO_TEST__(mm_radio_destroy(g_my_radio);)
53 RADIO_TEST__(mm_radio_realize(g_my_radio);)
58 RADIO_TEST__(mm_radio_unrealize(g_my_radio);)
63 MMRadioStateType state = 0;
64 RADIO_TEST__(mm_radio_get_state(g_my_radio, &state);)
66 printf("state : %d\n", state);
71 RADIO_TEST__(mm_radio_start(g_my_radio);)
76 RADIO_TEST__(mm_radio_stop(g_my_radio);)
82 printf("input seek direction(0:UP/1:DOWN) : ");
83 if (scanf("%d", &direction) == 0)
86 RADIO_TEST__(mm_radio_seek(g_my_radio, direction);)
92 printf("input freq : ");
93 if (scanf("%d", &freq) == 0)
96 RADIO_TEST__(mm_radio_set_frequency(g_my_radio, freq);)
102 RADIO_TEST__(mm_radio_get_frequency(g_my_radio, &freq);)
104 printf("freq : %d\n", freq);
109 RADIO_TEST__(mm_radio_scan_start(g_my_radio);)
114 RADIO_TEST__(mm_radio_scan_stop(g_my_radio);)
120 printf("select one(0:UNMUTE/1:MUTE) : ");
121 if (scanf("%d", &muted) == 0)
123 RADIO_TEST__(mm_radio_set_mute(g_my_radio, muted);)
128 MMRadioRegionType type = 0;
129 RADIO_TEST__(mm_radio_get_region_type(g_my_radio, &type);)
130 printf("region type : %d\n", type);
135 unsigned int min_freq = 0;
136 unsigned int max_freq = 0;
137 RADIO_TEST__(mm_radio_get_region_frequency_range(g_my_radio, &min_freq, &max_freq);)
138 printf("region band range: %d ~ %d KHz\n", min_freq, max_freq);
142 int signal_strength = 0;
143 RADIO_TEST__(mm_radio_get_signal_strength(g_my_radio, &signal_strength);)
144 printf("signal strength is : %d \n", signal_strength);
148 int channel_spacing = 0;
149 RADIO_TEST__(mm_radio_get_channel_spacing(g_my_radio, &channel_spacing);)
150 printf("channel_spacing is : %d \n", channel_spacing);
159 int mm_radio_rt_api_test(void)
175 printf("radio test client finished\n");
184 printf("---------------------------------------------------------\n");
185 printf("mm-radio rt api test. try now!\n");
186 printf("---------------------------------------------------------\n");
187 printf("[1] mm_radio_create\n");
188 printf("[2] mm_radio_destroy\n");
189 printf("[3] mm_radio_realize\n");
190 printf("[4] mm_radio_unrealize\n");
191 printf("[7] mm_radio_get_state\n");
192 printf("[8] mm_radio_start\n");
193 printf("[9] mm_radio_stop\n");
194 printf("[10] mm_radio_seek\n");
195 printf("[11] mm_radio_set_frequency(ex.107700)\n");
196 printf("[12] mm_radio_get_frequency\n");
197 printf("[13] mm_radio_scan_start\n");
198 printf("[14] mm_radio_scan_stop\n");
199 printf("[16] mm_radio_set_mute\n");
200 printf("[17] mm_radio_get_region_type\n");
201 printf("[18] mm_radio_get_region_frequency_range\n");
202 printf("[19] mm_radio_signal_strength\n");
203 printf("[20] mm_radio_get_channel_spacing\n");
204 printf("[0] quit\n");
205 printf("---------------------------------------------------------\n");
206 printf("choose one : ");
208 if (scanf("%d", &menu_item) == 0) {
209 char temp[_MAX_INPUT_STRING_];
210 if (scanf("%s", temp) == 0) {
211 printf("Error while flushing the input buffer - but lets continue\n");
217 if (menu_item > MENU_ITEM_MAX)
224 int __msg_rt_callback(int message, void *pParam, void *user_param)
226 MMMessageParamType *param = (MMMessageParamType *)pParam;
227 MMHandleType radio = (MMHandleType) user_param;
230 printf("incomming message : %d\n", message);
233 case MM_MESSAGE_STATE_CHANGED:
235 printf("MM_MESSAGE_STATE_CHANGED: current : %d old : %d\n"
236 , param->state.current, param->state.previous);
238 case MM_MESSAGE_RADIO_SCAN_START:
239 printf("MM_MESSAGE_RADIO_SCAN_START\n");
241 case MM_MESSAGE_RADIO_SCAN_INFO:
243 printf("MM_MESSAGE_RADIO_SCAN_INFO : freq : %d\n", param->radio_scan.frequency);
245 case MM_MESSAGE_RADIO_SCAN_STOP:
246 printf("MM_MESSAGE_RADIO_SCAN_STOP\n");
248 case MM_MESSAGE_RADIO_SCAN_FINISH:
249 printf("MM_MESSAGE_RADIO_SCAN_FINISHED\n");
250 RADIO_TEST__(mm_radio_scan_stop(radio);)
252 case MM_MESSAGE_RADIO_SEEK_START:
253 printf("MM_MESSAGE_RADIO_SEEK_START\n");
255 case MM_MESSAGE_RADIO_SEEK_FINISH:
256 printf("MM_MESSAGE_RADIO_SEEK_FINISHED : freq : %d\n", param->radio_scan.frequency);
258 case MM_MESSAGE_STATE_INTERRUPTED:
259 printf("MM_MESSAGE_STATE_INTERRUPTED code - %d\n", param->code);
261 case MM_MESSAGE_READY_TO_RESUME:
262 printf("MM_MESSAGE_READY_TO_RESUME\n");
263 RADIO_TEST__(mm_radio_start(radio);)
266 printf("ERROR : unknown message received!\n");