Home | History | Annotate | Download | only in server

Lines Matching refs:handle

40 /* Handle object to hold required info to initialize and maintain
55 * telephony - A reference of current telephony handle.
82 int (*callback) (struct hfp_slc_handle *handle, const char *cmd);
86 static int hfp_send(struct hfp_slc_handle *handle, const char *buf)
90 if (handle->rfcomm_fd < 0)
94 err = write(handle->rfcomm_fd, "\r\n", 2);
101 err = write(handle->rfcomm_fd,
108 err = write(handle->rfcomm_fd, "\r\n", 2);
116 static int hfp_send_ind_event_report(struct hfp_slc_handle *handle,
122 if (handle->is_hsp || !handle->ind_event_report)
126 return hfp_send(handle, cmd);
131 static int hfp_send_calling_line_identification(struct hfp_slc_handle *handle,
137 if (handle->is_hsp)
140 if (handle->telephony->call) {
145 return hfp_send(handle, cmd);
149 static int answer_call(struct hfp_slc_handle *handle, const char *cmd)
152 rc = hfp_send(handle, "OK");
161 static int call_waiting_notify(struct hfp_slc_handle *handle, const char *buf)
163 return hfp_send(handle, "OK");
169 static int cli_notification(struct hfp_slc_handle *handle, const char *cmd)
171 handle->cli_active = (cmd[8] == '1');
172 return hfp_send(handle, "OK");
179 static int dial_number(struct hfp_slc_handle *handle, const char *cmd)
186 /* Handle memory dial. Extract memory location from command
190 if (handle->telephony->dial_number == NULL || memory_location != 1)
191 return hfp_send(handle, "ERROR");
198 rc = hfp_send(handle, "OK");
202 handle->telephony->callsetup = 2;
203 return hfp_send_ind_event_report(handle, CALLSETUP_IND_INDEX, 2);
207 static int dtmf_tone(struct hfp_slc_handle *handle, const char *buf)
209 return hfp_send(handle, "OK");
216 static int event_reporting(struct hfp_slc_handle *handle, const char *cmd)
244 handle->ind_event_report = atoi(tmp);
246 err = hfp_send(handle, "OK");
255 if (!handle->initialized) {
256 handle->initialized = 1;
257 if (handle->init_cb)
258 handle->init_cb(handle);
269 static int extended_errors(struct hfp_slc_handle *handle, const char *buf)
271 return hfp_send(handle, "OK");
274 /* AT+CKPD command to handle the user initiated action from headset profile
277 static int key_press(struct hfp_slc_handle *handle, const char *buf)
279 hfp_send(handle, "OK");
282 if (handle->telephony->call || handle->telephony->callsetup) {
284 handle->disconnect_cb(handle);
293 static int last_dialed_number(struct hfp_slc_handle *handle, const char *buf)
297 if (!handle->telephony->dial_number)
298 return hfp_send(handle, "ERROR");
300 rc = hfp_send(handle, "OK");
304 handle->telephony->callsetup = 2;
305 return hfp_send_ind_event_report(handle, CALLSETUP_IND_INDEX, 2);
313 static int list_current_calls(struct hfp_slc_handle *handle, const char *cmd)
322 * handle the basic case that one call is active and
324 if (handle->telephony->callheld)
327 rc = hfp_send(handle, buf);
332 if (handle->telephony->call)
335 rc = hfp_send(handle, buf);
340 return hfp_send(handle, "OK");
346 static int operator_selection(struct hfp_slc_handle *handle, const char *buf)
356 rc = hfp_send(handle, "+COPS: 0");
360 return hfp_send(handle, "OK");
367 static int report_indicators(struct hfp_slc_handle *handle, const char *cmd)
374 err = hfp_send(handle, INDICATOR_UPDATE_RSP);
384 handle->battery,
385 handle->signal,
386 handle->service,
387 handle->telephony->call,
388 handle->telephony->callsetup,
389 handle->telephony->callheld
391 err = hfp_send(handle, buf);
397 return hfp_send(handle, "OK");
404 static int indicator_activation(struct hfp_slc_handle *handle, const char *cmd)
408 return hfp_send(handle, "OK");
414 static int signal_gain_setting(struct hfp_slc_handle *handle,
428 cras_bt_device_update_hardware_volume(handle->device,
432 return hfp_send(handle, "OK");
438 static int subscriber_number(struct hfp_slc_handle *handle, const char *buf)
440 return hfp_send(handle, "OK");
447 static int supported_features(struct hfp_slc_handle *handle, const char *cmd)
459 err = hfp_send(handle, response);
463 return hfp_send(handle, "OK");
466 int hfp_event_speaker_gain(struct hfp_slc_handle *handle, int gain)
474 return hfp_send(handle, command);
480 static int terminate_call(struct hfp_slc_handle *handle, const char *cmd)
483 rc = hfp_send(handle, "OK");
561 struct hfp_slc_handle *handle = (struct hfp_slc_handle *)arg;
565 bytes_read = read(handle->rfcomm_fd,
566 &handle->buf[handle->buf_write_idx],
567 SLC_BUF_SIZE_BYTES - handle->buf_write_idx - 1);
571 handle->disconnect_cb(handle);
574 handle->buf_write_idx += bytes_read;
575 handle->buf[handle->buf_write_idx] = '\0';
577 while (handle->buf_read_idx != handle->buf_write_idx) {
579 end_char = strchr(&handle->buf[handle->buf_read_idx], '\r');
584 err = handle_at_command(handle,
585 &handle->buf[handle->buf_read_idx]);
590 handle->buf_read_idx = 1 + end_char - handle->buf;
591 if (handlehandle->buf_write_idx) {
592 handle->buf_read_idx = 0;
593 handle->buf_write_idx = 0;
597 /* Handle the case when buffer is full and no command found. */
598 if (handle->buf_write_idx == SLC_BUF_SIZE_BYTES - 1) {
599 if (handle->buf_read_idx) {
600 memmove(handle->buf,
601 &handle->buf[handle->buf_read_idx],
602 handle->buf_write_idx - handle->buf_read_idx);
603 handle->buf_write_idx -= handle->buf_read_idx;
604 handle->buf_read_idx = 0;
608 handle->buf_write_idx = 0;
623 struct hfp_slc_handle *handle;
625 handle = (struct hfp_slc_handle*) calloc(1, sizeof(*handle));
626 if (!handle)
629 handle->rfcomm_fd = fd;
630 handle->is_hsp = is_hsp;
631 handle->device = device;
632 handle->init_cb = init_cb;
633 handle->disconnect_cb = disconnect_cb;
634 handle->cli_active = 0;
635 handle->battery = 5;
636 handle->signal = 5;
637 handle->service = 1;
638 handle->ind_event_report = 0;
639 handle->telephony = cras_telephony_get();
641 cras_system_add_select_fd(handle->rfcomm_fd,
642 slc_watch_callback, handle);
644 return handle;
654 int hfp_set_call_status(struct hfp_slc_handle *handle, int call)
656 int old_call = handle->telephony->call;
661 handle->telephony->call = call;
662 return hfp_event_update_call(handle);
672 int hfp_event_incoming_call(struct hfp_slc_handle *handle,
678 if (handle->is_hsp)
681 if (handle->cli_active) {
682 rc = hfp_send_calling_line_identification(handle, number, type);
687 if (handle->telephony->call)
690 return hfp_send(handle, "RING");
693 int hfp_event_update_call(struct hfp_slc_handle *handle)
695 return hfp_send_ind_event_report(handle, CALL_IND_INDEX,
696 handle->telephony->call);
699 int hfp_event_update_callsetup(struct hfp_slc_handle *handle)
701 return hfp_send_ind_event_report(handle, CALLSETUP_IND_INDEX,
702 handle->telephony->callsetup);
705 int hfp_event_update_callheld(struct hfp_slc_handle *handle)
707 return hfp_send_ind_event_report(handle, CALLHELD_IND_INDEX,
708 handle->telephony->callheld);
711 int hfp_event_set_battery(struct hfp_slc_handle *handle, int level)
713 handle->battery = level;
714 return hfp_send_ind_event_report(handle, BATTERY_IND_INDEX, level);
717 int hfp_event_set_signal(struct hfp_slc_handle *handle, int level)
719 handle->signal = level;
720 return hfp_send_ind_event_report(handle, SIGNAL_IND_INDEX, level);
723 int hfp_event_set_service(struct hfp_slc_handle *handle, int avail)
727 handle->service = !!avail;
728 return hfp_send_ind_event_report(handle, SERVICE_IND_INDEX, avail);