[asterisk-addons-commits] dcb: trunk r436 - in /trunk: ./ configs/ doc/

SVN commits to the Asterisk addons project asterisk-addons-commits at lists.digium.com
Sat Sep 1 21:33:21 CDT 2007


Author: dcb
Date: Sat Sep  1 21:33:20 2007
New Revision: 436

URL: http://svn.digium.com/view/asterisk-addons?view=rev&rev=436
Log:
* Implemented 'trunk groups' for those wanting to create GSM gateways
  Dial(Mobile/gn/NNNNNN) will call NNNNNN on the first free connected
  phone in group n.

Modified:
    trunk/chan_mobile.c
    trunk/configs/mobile.conf.sample
    trunk/doc/chan_mobile.txt

Modified: trunk/chan_mobile.c
URL: http://svn.digium.com/view/asterisk-addons/trunk/chan_mobile.c?view=diff&rev=436&r1=435&r2=436
==============================================================================
--- trunk/chan_mobile.c (original)
+++ trunk/chan_mobile.c Sat Sep  1 21:33:20 2007
@@ -123,6 +123,7 @@
 	struct ast_frame fr;			/* "null" frame */
 	enum mbl_type type;				/* Phone or Headset */
 	char id[31];					/* The id from mobile.conf */
+	int group;						/* group number for group dialling */
 	bdaddr_t addr;					/* address of device */
 	struct adapter_pvt *adapter;	/* the adapter we use */
 	char context[AST_MAX_CONTEXT];	/* the context for incoming calls */
@@ -244,13 +245,15 @@
 
 	struct mbl_pvt *pvt;
 	char bdaddr[18];
-
-	#define FORMAT "%-15.15s %-17.17s %-15.15s %-9.9s %-5.5s %-3.3s\n"
-
-	ast_cli(fd, FORMAT, "ID", "Address", "Adapter", "Connected", "State", "SMS");
+	char group[6];
+
+	#define FORMAT "%-15.15s %-17.17s %-5.5s %-15.15s %-9.9s %-5.5s %-3.3s\n"
+
+	ast_cli(fd, FORMAT, "ID", "Address", "Group", "Adapter", "Connected", "State", "SMS");
 	AST_LIST_TRAVERSE(&devices, pvt, entry) {
 		ba2str(&pvt->addr, bdaddr);
-		ast_cli(fd, FORMAT, pvt->id, bdaddr, pvt->adapter->id, pvt->connected?"Yes":"No", (pvt->state == MBL_STATE_IDLE)?"Free":(pvt->state < MBL_STATE_IDLE)?"Init":"Busy", (pvt->has_sms)?"Yes":"No");
+		snprintf(group, 5, "%d", pvt->group);
+		ast_cli(fd, FORMAT, pvt->id, bdaddr, group, pvt->adapter->id, pvt->connected?"Yes":"No", (pvt->state == MBL_STATE_IDLE)?"Free":(pvt->state < MBL_STATE_IDLE)?"Init":"Busy", (pvt->has_sms)?"Yes":"No");
 	}	
 
 	return RESULT_SUCCESS;
@@ -448,7 +451,7 @@
 	struct mbl_pvt *pvt;
 	char *dest_dev = NULL;
 	char *dest_num = NULL;
-	int oldformat;
+	int oldformat, group;
 	
 	if (!data) {
 		ast_log(LOG_WARNING, "Channel requested with no data\n");
@@ -472,7 +475,11 @@
 
 	/* Find requested device and make sure its connected. */
 	AST_LIST_TRAVERSE(&devices, pvt, entry) {
-		if (!strcmp(pvt->id, dest_dev)) {
+		if ((dest_dev[0] == 'g') || (dest_dev[0] == 'G')) {
+			group = atoi(dest_dev+1);
+			if (pvt->group == group)
+				break;
+		} else if (!strcmp(pvt->id, dest_dev)) {
 			break;
 		}
 	}
@@ -1805,7 +1812,7 @@
 	struct ast_config *cfg = NULL;
 	char *cat = NULL;
 	struct ast_variable *var;
-	const char *id, *address, *useadapter, *port, *context, *type, *skip;
+	const char *id, *address, *useadapter, *port, *context, *type, *skip, *group;
 	struct mbl_pvt *pvt;
 	struct adapter_pvt *adapter;
 	uint16_t vs;
@@ -1882,6 +1889,7 @@
 			context = ast_variable_retrieve(cfg, cat, "context");
 			type = ast_variable_retrieve(cfg, cat, "type");
 			skip = ast_variable_retrieve(cfg, cat, "dtmfskip");
+			group = ast_variable_retrieve(cfg, cat, "group");
 			if (address && port && useadapter) {
 				/* find the adapter */
 				AST_LIST_TRAVERSE(&adapters, adapter, entry) {
@@ -1900,6 +1908,10 @@
 					ast_copy_string(pvt->id, cat, sizeof(pvt->id));
 					str2ba(address, &pvt->addr);
 					ast_copy_string(pvt->context, S_OR(context, "default"), sizeof(pvt->context));
+					if (group)
+						pvt->group = atoi(group);	/* group 0 if invalid */
+					else
+						pvt->group = 0;
 					pvt->connected = 0;
 					pvt->state = MBL_STATE_INIT;
 					pvt->rfcomm_socket = -1;

Modified: trunk/configs/mobile.conf.sample
URL: http://svn.digium.com/view/asterisk-addons/trunk/configs/mobile.conf.sample?view=diff&rev=436&r1=435&r2=436
==============================================================================
--- trunk/configs/mobile.conf.sample (original)
+++ trunk/configs/mobile.conf.sample Sat Sep  1 21:33:20 2007
@@ -25,20 +25,22 @@
 ; Use the CLI command 'mobile search' to discover devices.
 ; Use the CLI command 'mobile show devices' to see device status.
 ;
-; To place a call out through a mobile phone use Dial(Mobile/[device]/NNN.....) in your dialplan.
+; To place a call out through a mobile phone use Dial(Mobile/[device]/NNN.....) or Dial(Mobile/gn/NNN......) in your dialplan.
 ; To call a headset use Dial(Mobile/[device]).
 
 [LGTU550]
 address=00:E0:91:7F:46:44	; the address of the phone
 port=4				; the rfcomm port number (from mobile search)
 context=incoming-mobile		; dialplan context for incoming calls
-adapter=dlink			; adapter to use
+adapter=dlink				; adapter to use
+group=1						; this phone is in channel group 1
 
 [6310i]
 address=00:60:57:32:7E:B1
 port=13
 context=incoming-mobile
 adapter=dlink
+group=1						; this phone is in channel group 1 also.
 
 [headset]
 address=00:0B:9E:11:AE:C6

Modified: trunk/doc/chan_mobile.txt
URL: http://svn.digium.com/view/asterisk-addons/trunk/doc/chan_mobile.txt?view=diff&rev=436&r1=435&r2=436
==============================================================================
--- trunk/doc/chan_mobile.txt (original)
+++ trunk/doc/chan_mobile.txt Sat Sep  1 21:33:20 2007
@@ -17,6 +17,7 @@
 Application MobileStatus can be used in the dialplan to see if a mobile phone / headset is connected.
 Supports devicestate for dialplan hinting.
 Supports Inbound and Outbound SMS.
+Supports 'channel' groups for implementing 'GSM Gateways'
 
 
 Requirements :-
@@ -97,9 +98,9 @@
 and whether or not the device is capable of sending / receiving SMS via bluetooth.
 
 *CLI> mobile show devices 
-ID              Address           Adapter         Connected State SMS
-headset         00:0B:9E:11:AE:C6 blue            No        Init  No 
-LGTU550         00:E0:91:7F:46:44 dlink           No        Init  No 
+ID              Address           Group Adapter         Connected State SMS
+headset         00:0B:9E:11:AE:C6 0     blue            No        Init  No 
+LGTU550         00:E0:91:7F:46:44 1     dlink           No        Init  No 
 *CLI>
 
 As each phone is connected you will see a message on the Asterisk console :-
@@ -113,6 +114,14 @@
 ; Calls via LGTU5500
 exten => _9X.,1,Dial(Mobile/LGTU550/${EXTEN:1},45)
 exten => _9X.,n,Hangup
+
+To use channel groups, add an entry to each phones definition in mobile.conf like group=n
+where n is a number.
+
+Then if you do something like Dial(Mobile/g1/123456) Asterisk will dial 123456 on the first
+connected free phone in group 1.
+
+Phones which do not have a specific 'group=n' will be in group 0.
 
 
 To dial out on a headset, you need to use some other mechanism, because the headset is not likely




More information about the asterisk-addons-commits mailing list