Asterisk - The Open Source Telephony Project
21.4.1
|
Bluetooth Mobile Device channel driver. More...
#include "asterisk.h"
#include <pthread.h>
#include <signal.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
#include <bluetooth/hci_lib.h>
#include <bluetooth/sdp.h>
#include <bluetooth/sdp_lib.h>
#include <bluetooth/rfcomm.h>
#include <bluetooth/sco.h>
#include <bluetooth/l2cap.h>
#include "asterisk/compat.h"
#include "asterisk/lock.h"
#include "asterisk/callerid.h"
#include "asterisk/channel.h"
#include "asterisk/config.h"
#include "asterisk/logger.h"
#include "asterisk/module.h"
#include "asterisk/pbx.h"
#include "asterisk/options.h"
#include "asterisk/utils.h"
#include "asterisk/linkedlists.h"
#include "asterisk/cli.h"
#include "asterisk/devicestate.h"
#include "asterisk/causes.h"
#include "asterisk/dsp.h"
#include "asterisk/app.h"
#include "asterisk/manager.h"
#include "asterisk/io.h"
#include "asterisk/smoother.h"
#include "asterisk/format_cache.h"
Go to the source code of this file.
Data Structures | |
struct | adapter_pvt |
struct | adapters |
struct | cidinfo |
struct | devices |
struct | hfp_ag |
This struct holds HFP features the AG supports. More... | |
struct | hfp_cind |
This struct holds mappings for indications. More... | |
struct | hfp_hf |
This struct holds HFP features that we support. More... | |
struct | hfp_pvt |
This struct holds state information about the current hfp connection. More... | |
struct | mbl_pvt |
struct | mbl_pvt::msg_queue |
struct | msg_queue_entry |
Macros | |
#define | CHANNEL_FRAME_SIZE 320 |
#define | DEVICE_FRAME_FORMAT ast_format_slin |
#define | DEVICE_FRAME_SIZE 48 |
#define | FORMAT1 "%-15.15s %-17.17s %-5.5s %-15.15s %-9.9s %-10.10s %-3.3s\n" |
#define | FORMAT1 "%-17.17s %-30.30s %-6.6s %-7.7s %-4.4s\n" |
#define | FORMAT2 "%-17.17s %-30.30s %-6.6s %-7.7s %d\n" |
#define | HFP_AG_CONTROL (1 << 7) |
#define | HFP_AG_CW (1 << 0) |
#define | HFP_AG_ECNR (1 << 1) |
#define | HFP_AG_ERRORS (1 << 8) |
#define | HFP_AG_REJECT (1 << 5) |
#define | HFP_AG_RING (1 << 3) |
#define | HFP_AG_STATUS (1 << 6) |
#define | HFP_AG_TAG (1 << 4) |
#define | HFP_AG_VOICE (1 << 2) |
#define | HFP_CIND_BATTCHG 7 |
#define | HFP_CIND_CALL 2 |
#define | HFP_CIND_CALL_ACTIVE 1 |
#define | HFP_CIND_CALL_NONE 0 |
#define | HFP_CIND_CALLHELD 4 |
#define | HFP_CIND_CALLSETUP 3 |
#define | HFP_CIND_CALLSETUP_ALERTING 3 |
#define | HFP_CIND_CALLSETUP_INCOMING 1 |
#define | HFP_CIND_CALLSETUP_NONE 0 |
#define | HFP_CIND_CALLSETUP_OUTGOING 2 |
#define | HFP_CIND_NONE 0 |
#define | HFP_CIND_ROAM 6 |
#define | HFP_CIND_SERVICE 1 |
#define | HFP_CIND_SERVICE_AVAILABLE 1 |
#define | HFP_CIND_SERVICE_NONE 0 |
#define | HFP_CIND_SIGNAL 5 |
#define | HFP_CIND_UNKNOWN -1 |
#define | HFP_HF_CID (1 << 2) |
#define | HFP_HF_CONTROL (1 << 6) |
#define | HFP_HF_CW (1 << 1) |
#define | HFP_HF_ECNR (1 << 0) |
#define | HFP_HF_STATUS (1 << 5) |
#define | HFP_HF_VOICE (1 << 3) |
#define | HFP_HF_VOLUME (1 << 4) |
#define | MBL_CONFIG "chan_mobile.conf" |
#define | MBL_CONFIG_OLD "mobile.conf" |
#define | rfcomm_read_debug(c) |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
static int | at_match_prefix (char *buf, char *prefix) |
Match the given buffer with the given prefix. More... | |
static const char * | at_msg2str (at_message_t msg) |
Get the string representation of the given AT message. More... | |
static at_message_t | at_read_full (int rsock, char *buf, size_t count) |
Read an AT message and classify it. More... | |
static int | check_unloading () |
Check if the module is unloading. More... | |
static void | do_alignment_detection (struct mbl_pvt *pvt, char *buf, int buflen) |
static void * | do_discovery (void *data) |
static void * | do_monitor_headset (void *data) |
static void * | do_monitor_phone (void *data) |
static void * | do_sco_listen (void *data) |
Service new and existing SCO connections. This thread accepts new sco connections and handles audio data. There is one do_sco_listen thread for each adapter. | |
static char * | handle_cli_mobile_cusd (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_cli_mobile_rfcomm (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_cli_mobile_search (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_cli_mobile_show_devices (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static int | handle_response_brsf (struct mbl_pvt *pvt, char *buf) |
Handle the BRSF response. More... | |
static int | handle_response_busy (struct mbl_pvt *pvt) |
Handle BUSY messages. More... | |
static int | handle_response_ciev (struct mbl_pvt *pvt, char *buf) |
Handle AT+CIEV messages. More... | |
static int | handle_response_cind (struct mbl_pvt *pvt, char *buf) |
Handle the CIND response. More... | |
static int | handle_response_clip (struct mbl_pvt *pvt, char *buf) |
Handle AT+CLIP messages. More... | |
static int | handle_response_cmgr (struct mbl_pvt *pvt, char *buf) |
Handle AT+CMGR messages. More... | |
static int | handle_response_cmti (struct mbl_pvt *pvt, char *buf) |
Handle AT+CMTI messages. More... | |
static int | handle_response_cusd (struct mbl_pvt *pvt, char *buf) |
Handle CUSD messages. More... | |
static int | handle_response_error (struct mbl_pvt *pvt, char *buf) |
Handle ERROR AT messages. More... | |
static int | handle_response_no_carrier (struct mbl_pvt *pvt, char *buf) |
Handle NO CARRIER messages. More... | |
static int | handle_response_no_dialtone (struct mbl_pvt *pvt, char *buf) |
Handle NO DIALTONE messages. More... | |
static int | handle_response_ok (struct mbl_pvt *pvt, char *buf) |
Handle OK AT messages. More... | |
static int | handle_response_ring (struct mbl_pvt *pvt, char *buf) |
Handle RING messages. More... | |
static int | handle_sms_prompt (struct mbl_pvt *pvt, char *buf) |
Send an SMS message from the queue. More... | |
static int | headset_send_ring (const void *data) |
static int | hfp_brsf2int (struct hfp_hf *hf) |
Convert a hfp_hf struct to a BRSF int. More... | |
static struct hfp_ag * | hfp_int2brsf (int brsf, struct hfp_ag *ag) |
Convert a BRSF int to an hfp_ag struct. More... | |
static int | hfp_parse_brsf (struct hfp_pvt *hfp, const char *buf) |
Parse BRSF data. More... | |
static int | hfp_parse_ciev (struct hfp_pvt *hfp, char *buf, int *value) |
Parse a CIEV event. More... | |
static int | hfp_parse_cind (struct hfp_pvt *hfp, char *buf) |
Read the result of the AT+CIND? command. More... | |
static int | hfp_parse_cind_indicator (struct hfp_pvt *hfp, int group, char *indicator) |
Parse and store the given indicator. More... | |
static int | hfp_parse_cind_test (struct hfp_pvt *hfp, char *buf) |
Parse the result of the AT+CIND=? command. More... | |
static struct cidinfo | hfp_parse_clip (struct hfp_pvt *hfp, char *buf) |
Parse a CLIP event. More... | |
static int | hfp_parse_cmgr (struct hfp_pvt *hfp, char *buf, char **from_number, char **text) |
Parse a CMGR message. More... | |
static int | hfp_parse_cmti (struct hfp_pvt *hfp, char *buf) |
Parse a CMTI notification. More... | |
static char * | hfp_parse_cusd (struct hfp_pvt *hfp, char *buf) |
Parse a CUSD answer. More... | |
static int | hfp_parse_ecav (struct hfp_pvt *hfp, char *buf) |
Parse a ECAV event. More... | |
static int | hfp_send_ata (struct hfp_pvt *hfp) |
Send ATA. More... | |
static int | hfp_send_atd (struct hfp_pvt *hfp, const char *number) |
Send ATD. More... | |
static int | hfp_send_brsf (struct hfp_pvt *hfp, struct hfp_hf *brsf) |
Send a BRSF request. More... | |
static int | hfp_send_chup (struct hfp_pvt *hfp) |
Send AT+CHUP. More... | |
static int | hfp_send_cind (struct hfp_pvt *hfp) |
Send the CIND read command. More... | |
static int | hfp_send_cind_test (struct hfp_pvt *hfp) |
Send the CIND test command. More... | |
static int | hfp_send_clip (struct hfp_pvt *hfp, int status) |
Enable or disable calling line identification. More... | |
static int | hfp_send_cmer (struct hfp_pvt *hfp, int status) |
Enable or disable indicator events reporting. More... | |
static int | hfp_send_cmgf (struct hfp_pvt *hfp, int mode) |
Set the SMS mode. More... | |
static int | hfp_send_cmgr (struct hfp_pvt *hfp, int index) |
Read an SMS message. More... | |
static int | hfp_send_cmgs (struct hfp_pvt *hfp, const char *number) |
Start sending an SMS message. More... | |
static int | hfp_send_cnmi (struct hfp_pvt *hfp) |
Setup SMS new message indication. More... | |
static int | hfp_send_cusd (struct hfp_pvt *hfp, const char *code) |
Send CUSD. More... | |
static int | hfp_send_dtmf (struct hfp_pvt *hfp, char digit) |
Send a DTMF command. More... | |
static int | hfp_send_ecam (struct hfp_pvt *hfp) |
Enable Sony Ericsson extensions / indications. More... | |
static int | hfp_send_sms_text (struct hfp_pvt *hfp, const char *message) |
Send the text of an SMS message. More... | |
static int | hfp_send_vgs (struct hfp_pvt *hfp, int value) |
Send the current speaker gain level. More... | |
static int | hsp_send_error (int rsock) |
Send an ERROR AT response. More... | |
static int | hsp_send_ok (int rsock) |
Send an OK AT response. More... | |
static int | hsp_send_ring (int rsock) |
Send a RING unsolicited AT response. More... | |
static int | hsp_send_vgm (int rsock, int gain) |
Send a microphone gain unsolicited AT response. More... | |
static int | hsp_send_vgs (int rsock, int gain) |
Send a speaker gain unsolicited AT response. More... | |
static int | load_module (void) |
static int | mbl_answer (struct ast_channel *ast) |
static int | mbl_ast_hangup (struct mbl_pvt *pvt) |
static int | mbl_call (struct ast_channel *ast, const char *dest, int timeout) |
static int | mbl_devicestate (const char *data) |
static int | mbl_digit_end (struct ast_channel *ast, char digit, unsigned int duration) |
static int | mbl_fixup (struct ast_channel *oldchan, struct ast_channel *newchan) |
static int | mbl_hangup (struct ast_channel *ast) |
static int | mbl_has_service (struct mbl_pvt *pvt) |
Check if a mobile device has service. More... | |
static struct adapter_pvt * | mbl_load_adapter (struct ast_config *cfg, const char *cat) |
Load an adapter from the configuration file. More... | |
static int | mbl_load_config (void) |
static struct mbl_pvt * | mbl_load_device (struct ast_config *cfg, const char *cat) |
Load a device from the configuration file. More... | |
static struct ast_channel * | mbl_new (int state, struct mbl_pvt *pvt, struct cidinfo *cidinfo, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor) |
static int | mbl_queue_control (struct mbl_pvt *pvt, enum ast_control_frame_type control) |
static int | mbl_queue_hangup (struct mbl_pvt *pvt) |
static struct ast_frame * | mbl_read (struct ast_channel *ast) |
static struct ast_channel * | mbl_request (const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, int *cause) |
static int | mbl_sendsms_exec (struct ast_channel *ast, const char *data) |
static int | mbl_status_exec (struct ast_channel *ast, const char *data) |
static int | mbl_write (struct ast_channel *ast, struct ast_frame *frame) |
static void | msg_queue_flush (struct mbl_pvt *pvt) |
Remove all items from the queue and free them. More... | |
static void | msg_queue_free_and_pop (struct mbl_pvt *pvt) |
Remove an item from the front of the queue, and free it. More... | |
static struct msg_queue_entry * | msg_queue_head (struct mbl_pvt *pvt) |
Get the head of a queue. More... | |
static struct msg_queue_entry * | msg_queue_pop (struct mbl_pvt *pvt) |
Remove an item from the front of the queue. More... | |
static int | msg_queue_push (struct mbl_pvt *pvt, at_message_t expect, at_message_t response_to) |
Add an item to the back of the queue. More... | |
static int | msg_queue_push_data (struct mbl_pvt *pvt, at_message_t expect, at_message_t response_to, void *data) |
Add an item to the back of the queue with data. More... | |
static int | parse_next_token (char string[], const int start, const char delim) |
Terminate current token and return an index to start of the next token. More... | |
static void | rfcomm_append_buf (char **buf, size_t count, size_t *in_count, char c) |
Append the given character to the given buffer and increase the in_count. | |
static int | rfcomm_connect (bdaddr_t src, bdaddr_t dst, int remote_channel) |
static ssize_t | rfcomm_read (int rsock, char *buf, size_t count) |
Read one Hayes AT message from an rfcomm socket. More... | |
static int | rfcomm_read_and_append_char (int rsock, char **buf, size_t count, size_t *in_count, char *result, char expected) |
Read a character from the given stream and append it to the given buffer if it matches the expected character. | |
static int | rfcomm_read_and_expect_char (int rsock, char *result, char expected) |
Read a character from the given stream and check if it matches what we expected. | |
static int | rfcomm_read_cmgr (int rsock, char **buf, size_t count, size_t *in_count) |
Read the remainder of a +CMGR message. More... | |
static int | rfcomm_read_command (int rsock, char **buf, size_t count, size_t *in_count) |
Read the remainder of an AT command. More... | |
static int | rfcomm_read_result (int rsock, char **buf, size_t count, size_t *in_count) |
Read and AT result code. More... | |
static int | rfcomm_read_sms_prompt (int rsock, char **buf, size_t count, size_t *in_count) |
Read the remainder of an AT SMS prompt. More... | |
static int | rfcomm_read_until_crlf (int rsock, char **buf, size_t count, size_t *in_count) |
Read until. More... | |
static int | rfcomm_read_until_ok (int rsock, char **buf, size_t count, size_t *in_count) |
Read until a. More... | |
static int | rfcomm_wait (int rsock, int *ms) |
Wait for activity on an rfcomm socket. More... | |
static int | rfcomm_write (int rsock, char *buf) |
Write to an rfcomm socket. More... | |
static int | rfcomm_write_full (int rsock, char *buf, size_t count) |
Write to an rfcomm socket. More... | |
static int | sco_accept (int *id, int fd, short events, void *data) |
Accept SCO connections. This function is an ast_io callback function used to accept incoming sco audio connections. | |
static int | sco_bind (struct adapter_pvt *adapter) |
Bind an SCO listener socket for the given adapter. More... | |
static int | sco_connect (bdaddr_t src, bdaddr_t dst) |
static int | sco_write (int s, char *buf, int len) |
static sdp_session_t * | sdp_register (void) |
static int | sdp_search (char *addr, int profile) |
static void | set_unloading () |
Set the unloading flag. | |
static int | start_monitor (struct mbl_pvt *pvt) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Bluetooth Mobile Device Channel Driver" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "da6642af068ee5e6490c5b1d2cc1d238" , .support_level = AST_MODULE_SUPPORT_EXTENDED, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_CHANNEL_DRIVER, } |
static struct adapters | adapters = { .first = NULL, .last = NULL, .lock = { PTHREAD_RWLOCK_INITIALIZER , NULL, {1, 0} } , } |
static char * | app_mblsendsms = "MobileSendSMS" |
static char * | app_mblstatus = "MobileStatus" |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static struct devices | devices = { .first = NULL, .last = NULL, .lock = { PTHREAD_RWLOCK_INITIALIZER , NULL, {1, 0} } , } |
static int | discovery_interval = 60 |
static pthread_t | discovery_thread = AST_PTHREADT_NULL |
static struct hfp_hf | hfp_our_brsf |
static struct ast_cli_entry | mbl_cli [] |
static struct ast_channel_tech | mbl_tech |
static char * | mblsendsms_desc |
static char * | mblsendsms_synopsis = "MobileSendSMS(Device,Dest,Message)" |
static char * | mblstatus_desc |
static char * | mblstatus_synopsis = "MobileStatus(Device,Variable)" |
static sdp_session_t * | sdp_session |
static ast_mutex_t | unload_mutex = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } |
static int | unloading_flag = 0 |
Bluetooth Mobile Device channel driver.
Definition in file chan_mobile.c.
|
static |
Match the given buffer with the given prefix.
buf | the buffer to match |
prefix | the prefix to match |
Definition at line 2003 of file chan_mobile.c.
Referenced by at_read_full().
|
inlinestatic |
Get the string representation of the given AT message.
msg | the message to process |
Definition at line 2076 of file chan_mobile.c.
Referenced by handle_response_brsf(), handle_response_cind(), handle_response_error(), and handle_response_ok().
|
static |
Read an AT message and classify it.
rsock | an rfcomm socket |
buf | the buffer to store the result in |
count | the size of the buffer or the maximum number of characters to read |
Definition at line 2017 of file chan_mobile.c.
References at_match_prefix(), and rfcomm_read().
|
inlinestatic |
Check if the module is unloading.
0 | not unloading |
1 | unloading |
Definition at line 4684 of file chan_mobile.c.
Referenced by do_sco_listen().
|
static |
Handle the BRSF response.
pvt | a mbl_pvt structure |
buf | a null terminated buffer containing an AT message |
0 | success |
-1 | error |
Definition at line 3198 of file chan_mobile.c.
References ast_debug, at_msg2str(), mbl_pvt::hfp, hfp_parse_brsf(), msg_queue_free_and_pop(), msg_queue_head(), and msg_queue_push().
|
static |
Handle BUSY messages.
pvt | a mbl_pvt structure |
0 | success |
-1 | error |
Definition at line 3833 of file chan_mobile.c.
References AST_CONTROL_BUSY, and mbl_pvt::needchup.
Referenced by handle_response_ciev().
|
static |
Handle AT+CIEV messages.
pvt | a mbl_pvt structure |
buf | a null terminated buffer containing an AT message |
0 | success |
-1 | error |
Definition at line 3561 of file chan_mobile.c.
References mbl_pvt::answered, AST_CONTROL_ANSWER, AST_CONTROL_RINGING, ast_debug, ast_setstate(), AST_STATE_UP, hfp_cind::call, hfp_pvt::cind_map, hfp_pvt::cind_state, handle_response_busy(), mbl_pvt::hfp, hfp_parse_ciev(), mbl_pvt::incoming, mbl_pvt::needcallerid, mbl_pvt::needchup, mbl_pvt::outgoing, and hfp_pvt::sent_alerting.
|
static |
Handle the CIND response.
pvt | a mbl_pvt structure |
buf | a null terminated buffer containing an AT message |
0 | success |
-1 | error |
Definition at line 3233 of file chan_mobile.c.
References ast_debug, at_msg2str(), mbl_pvt::hfp, hfp_parse_cind(), hfp_parse_cind_test(), msg_queue_free_and_pop(), msg_queue_head(), and msg_queue_push().
|
static |
Handle AT+CLIP messages.
pvt | a mbl_pvt structure |
buf | a null terminated buffer containing an AT message |
0 | success |
-1 | error |
Definition at line 3653 of file chan_mobile.c.
References ast_pbx_start(), AST_STATE_RING, mbl_pvt::hfp, hfp_parse_clip(), hfp_send_chup(), msg_queue_free_and_pop(), msg_queue_head(), msg_queue_push(), mbl_pvt::needcallerid, and mbl_pvt::needchup.
|
static |
Handle AT+CMGR messages.
pvt | a mbl_pvt structure |
buf | a null terminated buffer containing an AT message |
0 | success |
-1 | error |
Definition at line 3737 of file chan_mobile.c.
References ast_debug, ast_pbx_start(), AST_STATE_DOWN, mbl_pvt::hfp, hfp_parse_cmgr(), mbl_pvt::incoming_sms, msg_queue_free_and_pop(), msg_queue_head(), and pbx_builtin_setvar_helper().
|
static |
Handle AT+CMTI messages.
pvt | a mbl_pvt structure |
buf | a null terminated buffer containing an AT message |
0 | success |
-1 | error |
Definition at line 3710 of file chan_mobile.c.
References ast_debug, mbl_pvt::hfp, hfp_parse_cmti(), hfp_send_cmgr(), mbl_pvt::incoming_sms, and msg_queue_push().
|
static |
Handle CUSD messages.
pvt | a mbl_pvt structure |
buf | a null terminated buffer containing an AT message |
0 | success |
-1 | error |
Definition at line 3813 of file chan_mobile.c.
References mbl_pvt::hfp, and hfp_parse_cusd().
|
static |
Handle ERROR AT messages.
pvt | a mbl_pvt structure |
buf | a null terminated buffer containing an AT message |
0 | success |
-1 | error |
Definition at line 3444 of file chan_mobile.c.
References AST_CONTROL_CONGESTION, ast_debug, at_msg2str(), mbl_pvt::hfp, hfp_send_cmgf(), hfp_send_vgs(), mbl_pvt::incoming_sms, hfp_pvt::initialized, msg_queue_free_and_pop(), msg_queue_head(), msg_queue_push(), mbl_pvt::needchup, mbl_pvt::outgoing_sms, and mbl_pvt::timeout.
|
static |
Handle NO CARRIER messages.
pvt | a mbl_pvt structure |
buf | a null terminated buffer containing an AT message |
0 | success |
-1 | error |
Definition at line 3863 of file chan_mobile.c.
References AST_CONTROL_CONGESTION, and mbl_pvt::needchup.
|
static |
Handle NO DIALTONE messages.
pvt | a mbl_pvt structure |
buf | a null terminated buffer containing an AT message |
0 | success |
-1 | error |
Definition at line 3848 of file chan_mobile.c.
References AST_CONTROL_CONGESTION, and mbl_pvt::needchup.
|
static |
Handle OK AT messages.
pvt | a mbl_pvt structure |
buf | a null terminated buffer containing an AT message |
0 | success |
-1 | error |
Definition at line 3275 of file chan_mobile.c.
References AST_CONTROL_PROGRESS, ast_debug, at_msg2str(), hfp_cind::call, hfp_cind::callsetup, hfp_pvt::cind_map, hfp_pvt::cind_state, mbl_pvt::hfp, hfp_send_cind(), hfp_send_cind_test(), hfp_send_clip(), hfp_send_cmer(), hfp_send_cmgf(), hfp_send_cnmi(), hfp_send_ecam(), hfp_send_vgs(), hfp_pvt::initialized, msg_queue_free_and_pop(), msg_queue_head(), msg_queue_push(), mbl_pvt::needchup, mbl_pvt::outgoing, mbl_pvt::outgoing_sms, hfp_cind::service, and mbl_pvt::timeout.
|
static |
Handle RING messages.
pvt | a mbl_pvt structure |
buf | a null terminated buffer containing an AT message |
0 | success |
-1 | error |
Definition at line 3693 of file chan_mobile.c.
References ast_debug, msg_queue_push(), and mbl_pvt::needcallerid.
|
static |
Send an SMS message from the queue.
pvt | a mbl_pvt structure |
buf | a null terminated buffer containing an AT message |
0 | success |
-1 | error |
Definition at line 3782 of file chan_mobile.c.
References ast_debug, mbl_pvt::hfp, hfp_send_sms_text(), msg_queue_free_and_pop(), msg_queue_head(), and msg_queue_push().
|
static |
Convert a hfp_hf struct to a BRSF int.
hf | an hfp_hf brsf object |
Definition at line 2470 of file chan_mobile.c.
References hfp_hf::cid, hfp_hf::control, hfp_hf::cw, hfp_hf::ecnr, hfp_hf::status, hfp_hf::voice, and hfp_hf::volume.
Referenced by hfp_send_brsf().
Convert a BRSF int to an hfp_ag struct.
brsf | a brsf integer |
ag | a AG (hfp_ag) brsf object |
Definition at line 2492 of file chan_mobile.c.
References hfp_ag::control, hfp_ag::cw, hfp_ag::ecnr, hfp_ag::errors, hfp_ag::reject, hfp_ag::ring, hfp_ag::status, hfp_ag::tag, and hfp_ag::voice.
Referenced by hfp_parse_brsf().
|
static |
Parse BRSF data.
hfp | an hfp_pvt struct |
buf | the buffer to parse (null terminated) |
Definition at line 2726 of file chan_mobile.c.
References hfp_pvt::brsf, and hfp_int2brsf().
Referenced by handle_response_brsf().
|
static |
Parse a CIEV event.
hfp | an hfp_pvt struct |
buf | the buffer to parse (null terminated) |
value | a pointer to an int to store the event value in (can be NULL) |
Definition at line 2197 of file chan_mobile.c.
References ast_debug, hfp_pvt::cind_index, hfp_pvt::cind_state, and hfp_pvt::owner.
Referenced by handle_response_ciev().
|
static |
Read the result of the AT+CIND? command.
hfp | an hfp_pvt struct |
buf | the buffer to parse (null terminated) |
Definition at line 2770 of file chan_mobile.c.
References hfp_parse_cind_indicator().
Referenced by handle_response_cind().
|
static |
Parse and store the given indicator.
hfp | an hfp_pvt struct |
group | the indicator group |
indicator | the indicator to parse |
Definition at line 2744 of file chan_mobile.c.
References ast_debug, and hfp_pvt::cind_state.
Referenced by hfp_parse_cind().
|
static |
Parse the result of the AT+CIND=? command.
hfp | an hfp_pvt struct |
buf | the buffer to parse (null terminated) |
Definition at line 2820 of file chan_mobile.c.
References ast_debug, hfp_cind::battchg, hfp_cind::call, hfp_cind::callheld, hfp_cind::callsetup, hfp_pvt::cind_index, hfp_pvt::cind_map, hfp_pvt::nocallsetup, hfp_pvt::owner, hfp_cind::roam, hfp_cind::service, and hfp_cind::signal.
Referenced by handle_response_cind().
Parse a CLIP event.
hfp | an hfp_pvt struct |
buf | the buffer to parse (null terminated) |
Definition at line 2226 of file chan_mobile.c.
References ast_debug, ast_isphonenumber(), ast_strip_quoted(), and parse_next_token().
Referenced by handle_response_clip().
|
static |
Parse a CMGR message.
hfp | an hfp_pvt struct |
buf | the buffer to parse (null terminated) |
from_number | a pointer to a char pointer which will store the from number |
text | a pointer to a char pointer which will store the message text |
-1 | parse error |
0 | success |
Definition at line 2354 of file chan_mobile.c.
Referenced by handle_response_cmgr().
|
static |
Parse a CMTI notification.
hfp | an hfp_pvt struct |
buf | the buffer to parse (null terminated) |
Definition at line 2328 of file chan_mobile.c.
References ast_debug, and hfp_pvt::owner.
Referenced by handle_response_cmti().
|
static |
Parse a CUSD answer.
hfp | an hfp_pvt struct |
buf | the buffer to parse (null terminated) |
Definition at line 2418 of file chan_mobile.c.
Referenced by handle_response_cusd().
|
static |
Parse a ECAV event.
hfp | an hfp_pvt struct |
buf | the buffer to parse (null terminated) |
Example:
*ECAV: <ccid>,<ccstatus>,<calltype>[,<processid>] [,exitcause][,<number>,<type>]
Example indicating busy:
*ECAV: 1,7,1
Definition at line 2166 of file chan_mobile.c.
References ast_debug, and hfp_pvt::owner.
|
static |
Send ATA.
hfp | an hfp_pvt struct |
Definition at line 2704 of file chan_mobile.c.
References rfcomm_write(), and hfp_pvt::rsock.
|
static |
Send ATD.
hfp | an hfp_pvt struct |
number | the number to send |
Definition at line 2693 of file chan_mobile.c.
References rfcomm_write(), and hfp_pvt::rsock.
Send a BRSF request.
0 | on success |
-1 | on error |
Definition at line 2516 of file chan_mobile.c.
References hfp_brsf2int(), rfcomm_write(), and hfp_pvt::rsock.
|
static |
Send AT+CHUP.
hfp | an hfp_pvt struct |
Definition at line 2683 of file chan_mobile.c.
References rfcomm_write(), and hfp_pvt::rsock.
Referenced by handle_response_clip().
|
static |
Send the CIND read command.
hfp | an hfp_pvt struct |
Definition at line 2527 of file chan_mobile.c.
References rfcomm_write(), and hfp_pvt::rsock.
Referenced by handle_response_ok().
|
static |
Send the CIND test command.
hfp | an hfp_pvt struct |
Definition at line 2536 of file chan_mobile.c.
References rfcomm_write(), and hfp_pvt::rsock.
Referenced by handle_response_ok().
|
static |
Enable or disable calling line identification.
hfp | an hfp_pvt struct |
status | enable or disable calling line identification (should be 1 or 0) |
Definition at line 2585 of file chan_mobile.c.
References rfcomm_write(), and hfp_pvt::rsock.
Referenced by handle_response_ok().
|
static |
Enable or disable indicator events reporting.
hfp | an hfp_pvt struct |
status | enable or disable events reporting (should be 1 or 0) |
Definition at line 2546 of file chan_mobile.c.
References rfcomm_write(), and hfp_pvt::rsock.
Referenced by handle_response_ok().
|
static |
Set the SMS mode.
hfp | an hfp_pvt struct |
mode | the sms mode (0 = PDU, 1 = Text) |
Definition at line 2627 of file chan_mobile.c.
References rfcomm_write(), and hfp_pvt::rsock.
Referenced by handle_response_error(), and handle_response_ok().
|
static |
Read an SMS message.
hfp | an hfp_pvt struct |
index | the location of the requested message |
Definition at line 2648 of file chan_mobile.c.
References rfcomm_write(), and hfp_pvt::rsock.
Referenced by handle_response_cmti().
|
static |
Start sending an SMS message.
hfp | an hfp_pvt struct |
number | the destination of the message |
Definition at line 2660 of file chan_mobile.c.
References rfcomm_write(), and hfp_pvt::rsock.
|
static |
Setup SMS new message indication.
hfp | an hfp_pvt struct |
Definition at line 2638 of file chan_mobile.c.
References rfcomm_write(), and hfp_pvt::rsock.
Referenced by handle_response_ok().
|
static |
Send CUSD.
hfp | an hfp_pvt struct |
code | the CUSD code to send |
Definition at line 2714 of file chan_mobile.c.
References rfcomm_write(), and hfp_pvt::rsock.
|
static |
Send a DTMF command.
hfp | an hfp_pvt struct |
digit | the dtmf digit to send |
Definition at line 2598 of file chan_mobile.c.
References rfcomm_write(), and hfp_pvt::rsock.
|
static |
Enable Sony Ericsson extensions / indications.
hfp | an hfp_pvt struct |
Definition at line 2184 of file chan_mobile.c.
References rfcomm_write(), and hfp_pvt::rsock.
Referenced by handle_response_ok().
|
static |
Send the text of an SMS message.
hfp | an hfp_pvt struct |
message | the text of the message |
Definition at line 2672 of file chan_mobile.c.
References rfcomm_write(), and hfp_pvt::rsock.
Referenced by handle_sms_prompt().
|
static |
Send the current speaker gain level.
hfp | an hfp_pvt struct |
value | the value to send (must be between 0 and 15) |
Definition at line 2558 of file chan_mobile.c.
References rfcomm_write(), and hfp_pvt::rsock.
Referenced by handle_response_error(), and handle_response_ok().
|
static |
Send an ERROR AT response.
rsock | the rfcomm socket to use |
Definition at line 2935 of file chan_mobile.c.
References rfcomm_write().
|
static |
Send an OK AT response.
rsock | the rfcomm socket to use |
Definition at line 2926 of file chan_mobile.c.
References rfcomm_write().
|
static |
Send a RING unsolicited AT response.
rsock | the rfcomm socket to use |
Definition at line 2968 of file chan_mobile.c.
References rfcomm_write().
|
static |
Send a microphone gain unsolicited AT response.
rsock | the rfcomm socket to use |
gain | the microphone gain value |
Definition at line 2957 of file chan_mobile.c.
References rfcomm_write().
|
static |
Send a speaker gain unsolicited AT response.
rsock | the rfcomm socket to use |
gain | the speaker gain value |
Definition at line 2945 of file chan_mobile.c.
References rfcomm_write().
|
static |
Check if a mobile device has service.
pvt | a mbl_pvt struct |
1 | this device has service |
0 | no service |
Definition at line 1369 of file chan_mobile.c.
References hfp_pvt::cind_map, hfp_pvt::cind_state, mbl_pvt::hfp, and hfp_cind::service.
|
static |
Load an adapter from the configuration file.
cfg | the config to load the adapter from |
cat | the adapter to load |
This function loads the given adapter and starts the sco listener thread for that adapter.
Definition at line 4366 of file chan_mobile.c.
References adapter_pvt::accept_io, address, ast_calloc, ast_copy_string(), ast_debug, ast_io_add(), AST_IO_IN, ast_io_remove(), AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_true(), do_sco_listen(), adapter_pvt::io, io_context_create(), io_context_destroy(), ast_variable::name, ast_variable::next, sco_accept(), sco_bind(), adapter_pvt::sco_id, adapter_pvt::sco_listener_thread, adapter_pvt::sco_socket, and ast_variable::value.
|
static |
Load a device from the configuration file.
cfg | the config to load the device from |
cat | the device to load |
Definition at line 4482 of file chan_mobile.c.
References address, ast_calloc, ast_copy_string(), ast_debug, ast_dsp_new(), ast_dsp_set_digitmode(), ast_dsp_set_features(), AST_LIST_HEAD_INIT_NOLOCK, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_sched_context_create(), ast_sched_context_destroy(), ast_true(), DSP_DIGITMODE_DTMF, DSP_DIGITMODE_RELAXDTMF, mbl_pvt::hfp, mbl_pvt::lock, ast_variable::name, ast_variable::next, hfp_pvt::nocallsetup, hfp_pvt::owner, hfp_pvt::rport, mbl_pvt::timeout, and ast_variable::value.
|
static |
Remove all items from the queue and free them.
pvt | a mbl_pvt structure |
Definition at line 3048 of file chan_mobile.c.
References msg_queue_free_and_pop(), and msg_queue_head().
|
static |
Remove an item from the front of the queue, and free it.
pvt | a mbl_pvt structure |
Definition at line 3034 of file chan_mobile.c.
References msg_queue_pop().
Referenced by handle_response_brsf(), handle_response_cind(), handle_response_clip(), handle_response_cmgr(), handle_response_error(), handle_response_ok(), handle_sms_prompt(), and msg_queue_flush().
|
static |
Get the head of a queue.
pvt | a mbl_pvt structure |
Definition at line 3060 of file chan_mobile.c.
References AST_LIST_FIRST.
Referenced by handle_response_brsf(), handle_response_cind(), handle_response_clip(), handle_response_cmgr(), handle_response_error(), handle_response_ok(), handle_sms_prompt(), and msg_queue_flush().
|
static |
Remove an item from the front of the queue.
pvt | a mbl_pvt structure |
Definition at line 3025 of file chan_mobile.c.
References AST_LIST_REMOVE_HEAD.
Referenced by msg_queue_free_and_pop().
|
static |
Add an item to the back of the queue.
pvt | a mbl_pvt structure |
expect | the msg we expect to receive |
response_to | the message that was sent to generate the expected response |
Definition at line 2984 of file chan_mobile.c.
References ast_calloc, and AST_LIST_INSERT_TAIL.
Referenced by handle_response_brsf(), handle_response_cind(), handle_response_clip(), handle_response_cmti(), handle_response_error(), handle_response_ok(), handle_response_ring(), and handle_sms_prompt().
|
static |
Add an item to the back of the queue with data.
pvt | a mbl_pvt structure |
expect | the msg we expect to receive |
response_to | the message that was sent to generate the expected response |
data | data associated with this message, it will be freed when the message is freed |
Definition at line 3006 of file chan_mobile.c.
References ast_calloc, and AST_LIST_INSERT_TAIL.
|
static |
Terminate current token and return an index to start of the next token.
string | the null-terminated string being parsed (will be altered!) |
start | where the current token starts |
delim | the token termination delimiter. \0 is also considered a terminator. |
Definition at line 2299 of file chan_mobile.c.
Referenced by hfp_parse_clip().
|
static |
Read one Hayes AT message from an rfcomm socket.
rsock | the rfcomm socket to read from |
buf | the buffer to store the result in |
count | the size of the buffer or the maximum number of characters to read |
Here we need to read complete Hayes AT messages. The AT message formats we support are listed below.
* \r\n<result code>\r\n * <at command>\r * \r\n> *
These formats correspond to AT result codes, AT commands, and the AT SMS prompt respectively. When messages are read the leading and trailing
'\r'
and
'\n'
characters are discarded. If the given buffer is not large enough to hold the response, what does not fit in the buffer will be dropped.
0 | end of file |
-1 | read error |
-2 | parse error |
other | the number of characters added to buf |
Definition at line 1808 of file chan_mobile.c.
References rfcomm_append_buf(), rfcomm_read_and_expect_char(), rfcomm_read_command(), and rfcomm_read_result().
Referenced by at_read_full().
|
static |
Read the remainder of a +CMGR message.
'+CMGR: ...\r\n...\r\n...\r\n...\r\nOK\r\n'
Definition at line 1706 of file chan_mobile.c.
References rfcomm_append_buf(), and rfcomm_read_until_ok().
Referenced by rfcomm_read_result().
|
static |
Read the remainder of an AT command.
'<at command>\r'
Definition at line 1763 of file chan_mobile.c.
References rfcomm_append_buf().
Referenced by rfcomm_read().
|
static |
Read and AT result code.
'\r\n<result code>\r\n'
Definition at line 1725 of file chan_mobile.c.
References rfcomm_append_buf(), rfcomm_read_and_append_char(), rfcomm_read_and_expect_char(), rfcomm_read_cmgr(), rfcomm_read_sms_prompt(), and rfcomm_read_until_crlf().
Referenced by rfcomm_read().
|
static |
Read the remainder of an AT SMS prompt.
'\r\n> '
By the time this function is executed, only a ' ' is left to read.
Definition at line 1593 of file chan_mobile.c.
References rfcomm_read_and_append_char().
Referenced by rfcomm_read_result().
|
static |
Read until.
'\r\n'.
This function consumes the
'\r\n'
but does not add it to buf.
Definition at line 1564 of file chan_mobile.c.
References rfcomm_append_buf(), and rfcomm_read_and_expect_char().
Referenced by rfcomm_read_result(), and rfcomm_read_until_ok().
|
static |
Read until a.
\r\nOK\r\n
message.
Definition at line 1609 of file chan_mobile.c.
References rfcomm_append_buf(), rfcomm_read_and_expect_char(), and rfcomm_read_until_crlf().
Referenced by rfcomm_read_cmgr().
|
static |
Wait for activity on an rfcomm socket.
rsock | the socket to watch |
ms | a pointer to an int containing a timeout in ms |
0 | timeout |
Definition at line 1479 of file chan_mobile.c.
References ast_waitfor_n_fd().
|
static |
Write to an rfcomm socket.
rsock | the socket to write to |
buf | the null terminated buffer to write |
This function will write characters from buf. The buffer must be null terminated.
-1 | error |
0 | success |
Definition at line 1436 of file chan_mobile.c.
References rfcomm_write_full().
Referenced by hfp_send_ata(), hfp_send_atd(), hfp_send_brsf(), hfp_send_chup(), hfp_send_cind(), hfp_send_cind_test(), hfp_send_clip(), hfp_send_cmer(), hfp_send_cmgf(), hfp_send_cmgr(), hfp_send_cmgs(), hfp_send_cnmi(), hfp_send_cusd(), hfp_send_dtmf(), hfp_send_ecam(), hfp_send_sms_text(), hfp_send_vgs(), hsp_send_error(), hsp_send_ok(), hsp_send_ring(), hsp_send_vgm(), and hsp_send_vgs().
|
static |
Write to an rfcomm socket.
rsock | the socket to write to |
buf | the buffer to write |
count | the number of characters from the buffer to write |
This function will write count characters from buf. It will always write count chars unless it encounters an error.
-1 | error |
0 | success |
Definition at line 1454 of file chan_mobile.c.
References ast_debug.
Referenced by rfcomm_write().
|
static |
Bind an SCO listener socket for the given adapter.
adapter | an adapter_pvt |
Definition at line 1958 of file chan_mobile.c.
References adapter_pvt::sco_socket.
Referenced by mbl_load_adapter().
|
static |
Definition at line 211 of file chan_mobile.c.
|
static |
Definition at line 203 of file chan_mobile.c.