Home AMX User Forum NetLinx Studio
Options

Advice for Telephone Keypad Buttons

Please bare with me as I am fresh out of P2.

I have a project I am working on currently that involves an Audio Conferencing system. I have designed a TP that has all of the pertinent buttons for dialing, and a text input button for displaying the inputs. Here's what I am trying to achieve:

-Press any of the buttons and have the parsed data display in the text box.
-Press any of the buttons and send that string to the telecon (confident I can figure that part out).
-Ability to clear the text
-Ability to delete the last character
-Ability to dial the entire text box once there is dial-tone

I've tried this several ways experimenting. First I downloaded a TP from the UI Resources library and tried using this telecon page in which they had the keypad channels setup. This worked for inputting characters into the text input and achieved everything I want, except I can't figure out how to utilize these buttons to send strings to my device since they are using the setup port. If there's an easy way to do this, let me know. Also, I am using the keypad function in another portion of my touch panel, so input values on that page appeared in my text input box on the telco page. Probably an easy fix there (I hope).

I also played around with giving these buttons a channel port for this telecon page, and then using an array to send the stored array values to the touch panel and send them into the text input. For some reason beyond me, this worked but it would only give one value at a time. I created a buffer, but every time a different button is pushed the previous value disappeared. I've been playing around with this for several days now, and have exhausted all the ideas I can think of.

Any tips or example code would be extremely helpful.

THANKS!
Matt

Comments

  • Options
    Here is a chunk of sample code that I acquired from somewhere and use. There are probably some variables missing and such but you should get the idea. This was cut from a program that uses a Biamp DSP.
  • Options
    nickmnickm Posts: 152
    Here's a bit of code that I wrote specifically for Polycom SoundStructure. It can, however, be adapter for any dialer really.

    It works for both pre-building dial strings, as well as off-hook dialing. The UX is much like that of a mobile phone. It also features press-and-hold speed dial saving.

    Let me know if you have any questions.
    DEFINE_TYPE
    	STRUCTURE _Dialer {
    		INTEGER nLineActive
    		INTEGER nAutoAnswer
    		INTEGER nPresetSave
    		INTEGER nPrivacy
    
    		CHAR cCurrentDialString[20]
    		CHAR cLastDialString[20]
    		CHAR cPresetDialString[4][20]
    		
    		CHAR cChannelName[32]
    	}
    	
    DEFINE_VARIABLE
    	PERSISTENT _Dialer TelcoDialer
    	VOLATILE INTEGER nDebugLevel
    
    //-----------------------------------------------------------------------------
    
    DEFINE_FUNCTION CHAR[32] AppendToDialString (CHAR cChar[]) {
    	IF(LENGTH_STRING(TelcoDialer.cCurrentDialString)<20) {
    		TelcoDialer.cCurrentDialString = "TelcoDialer.cCurrentDialString,cChar"
    		SEND_COMMAND dvTP_Telco,"'^TXT-1,0,',TelcoDialer.cCurrentDialString"
    	}
    	ELSE {
    		//UserMessage("'Maximum length has been exceeded.'")
    	}
    	RETURN TelcoDialer.cCurrentDialString
    }
    DEFINE_FUNCTION SLONG SendDTMFTone (CHAR cChar[]) {
    	SEND_COMMAND vdvDSP,"'DTMF-',TelcoDialer.cChannelName,',',cChar"
    	RETURN 0
    }
    DEFINE_FUNCTION SLONG ClearDialString () {
    	TelcoDialer.cCurrentDialString = "''"
    	SEND_COMMAND dvTP_Telco,"'^TXT-1,0,',TelcoDialer.cCurrentDialString"
    	RETURN 0
    }
    
    //-----------------------------------------------------------------------------
    
    DEFINE_FUNCTION DebugString(INTEGER nLevel,CHAR cString[]) {
    	IF(nLevel<=nDebugLevel) {
    		SEND_STRING 0,"'Polycom SS UI - Telco - ',cString"
    	}
    }
    
    //-----------------------------------------------------------------------------
    
    DEFINE_EVENT
    	DATA_EVENT [vdvDSP] {
    		STRING : {
    			SELECT {
    				ACTIVE (FIND_STRING(DATA.TEXT,"'RING-',TelcoDialer.cChannelName",1)) : {
    					SEND_COMMAND dvTP_Telco,"'ADBEEP'"
    					SEND_COMMAND dvTP_Telco,"'@PPN-[Phone Ringing]'"
    				}
    				ACTIVE (FIND_STRING(DATA.TEXT,"'HOOK-',TelcoDialer.cChannelName,',1'",1)) : {
    					ON[TelcoDialer.nLineActive]
    				}
    				ACTIVE (FIND_STRING(DATA.TEXT,"'HOOK-',TelcoDialer.cChannelName,',0'",1)) : {
    					OFF[TelcoDialer.nLineActive]
    				}
    			}
    		}
    	}
    
    //-----------------------------------------------------------------------------
    
    DEFINE_EVENT
    	BUTTON_EVENT [dvTP_Telco,10]
    	BUTTON_EVENT [dvTP_Telco,11]
    	BUTTON_EVENT [dvTP_Telco,12]
    	BUTTON_EVENT [dvTP_Telco,13]
    	BUTTON_EVENT [dvTP_Telco,14]
    	BUTTON_EVENT [dvTP_Telco,15]
    	BUTTON_EVENT [dvTP_Telco,16]
    	BUTTON_EVENT [dvTP_Telco,17]
    	BUTTON_EVENT [dvTP_Telco,18]
    	BUTTON_EVENT [dvTP_Telco,19] {		//---Digits
    		PUSH : {
    			TO[BUTTON.INPUT]
    			
    			IF(TelcoDialer.nLineActive)
    				SendDTMFTone(ITOA(BUTTON.INPUT.CHANNEL-10))
    			ELSE
    				AppendToDialString(ITOA(BUTTON.INPUT.CHANNEL-10))
    		}
    	}
    	BUTTON_EVENT [dvTP_Telco,20] {		//---*
    		PUSH : {
    			TO[BUTTON.INPUT]
    			
    			IF(TelcoDialer.nLineActive)
    				SendDTMFTone('*')
    			ELSE
    				AppendToDialString('*')
    		}
    	}
    	BUTTON_EVENT [dvTP_Telco,21] {		//---#
    		PUSH : {
    			TO[BUTTON.INPUT]
    			
    			IF(TelcoDialer.nLineActive)
    				SendDTMFTone('#')
    			ELSE
    				AppendToDialString('#')
    		}
    	}
    	BUTTON_EVENT [dvTP_Telco,22] {		//---, (Pause)
    		PUSH : {
    			TO[BUTTON.INPUT]
    			
    			IF(TelcoDialer.nLineActive)
    				SendDTMFTone(',')
    			ELSE
    				AppendToDialString(',')
    		}
    	}
    
    DEFINE_EVENT
    	BUTTON_EVENT [dvTP_Telco,27] {		//---Dial/Off Hook (Active Line)
    		PUSH : {
    			IF(!TelcoDialer.nLineActive) {
    				IF(LENGTH_STRING(TelcoDialer.cCurrentDialString)>0) {
    					SEND_COMMAND vdvDSP,"'DIALNUMBER-',TelcoDialer.cChannelName,',',TelcoDialer.cCurrentDialString"		//---Dial TelcoDialer.cCurrentDialString
    					TelcoDialer.cLastDialString = TelcoDialer.cCurrentDialString
    				}
    				ELSE {
    					SEND_COMMAND vdvDSP,"'HOOK-',TelcoDialer.cChannelName,',1'"
    				}
    			}
    		}
    	}
    	BUTTON_EVENT [dvTP_Telco,28] {		//---Cancel/On Hook (Inactive Line)
    		PUSH : {
    			IF(TelcoDialer.nLineActive)
    				SEND_COMMAND vdvDSP,"'HOOK-',TelcoDialer.cChannelName,',0'"
    			ELSE {
    				ClearDialString()
    			}
    		}
    	}
    	
    //-----------------------------------------------------------------------------
    
    DEFINE_EVENT
    	BUTTON_EVENT [dvTP_Telco,101] {		//---Backspace
    		PUSH : {
    			SET_LENGTH_STRING(TelcoDialer.cCurrentDialString,LENGTH_STRING(TelcoDialer.cCurrentDialString)-1)
    			SEND_COMMAND dvTP_Telco,"'^TXT-1,0,',TelcoDialer.cCurrentDialString"
    		}
    	}
    	BUTTON_EVENT [dvTP_Telco,102] {		//---Clear
    		PUSH : ClearDialString()
    	}
    	BUTTON_EVENT [dvTP_Telco,103]	{		//---Recall
    		PUSH : {
    			TelcoDialer.cCurrentDialString = TelcoDialer.cLastDialString
    			SEND_COMMAND dvTP_Telco,"'^TXT-1,0,',TelcoDialer.cCurrentDialString"
    		}
    	}
    	BUTTON_EVENT [dvTP_Telco,104] {		//---Auto Answer
    		PUSH : {
    			//!!!
    		}
    	}
    
    //-----------------------------------------------------------------------------
    
    DEFINE_EVENT
    	BUTTON_EVENT [dvTP_Telco,111]
    	BUTTON_EVENT [dvTP_Telco,112]
    	BUTTON_EVENT [dvTP_Telco,113]
    	BUTTON_EVENT [dvTP_Telco,114] {		//---Speed Dials
    		HOLD[10] : {            
    			TelcoDialer.cPresetDialString[BUTTON.INPUT.CHANNEL-110] = TelcoDialer.cCurrentDialString
    			ON[TelcoDialer.nPresetSave]
    		}
    		RELEASE : {
    			IF(!TelcoDialer.nPresetSave) {
    				TelcoDialer.cCurrentDialString = TelcoDialer.cPresetDialString[BUTTON.INPUT.CHANNEL-110]
    				SEND_COMMAND dvTP_Telco,"'^TXT-1,0,',TelcoDialer.cCurrentDialString"
    			}
    			OFF[TelcoDialer.nPresetSave]
    		}
    	}
    
Sign In or Register to comment.