Configuration file format: AT mode

Configuration file examples

You may find some predefined configuration files in cfg-data/AT-mode directory. After investigation of these configuration files You became more familiar with its format.

Format

Line starting with a % considered as a comment line.

%This is a comment

Long command can be splitted into the several lines. You have to put backslash (\) as the last character to continue a command to the next line.

1=Exec(echo "this is first line");\
Exec(echo "this is second line");

Parameters section

AutoConnect=false

Auto-connect to phone on startup, default value is false. Used when anyRemote is in AT-mode.

AutoRepeat=false

Auto repeat feature (as on PC keyboard - about 10 events per second). Usefull for mouse emulation, for example. Default value is false.

Baudrate=19200

Baudrate to use; default value is 19200

CharSet=8859-1

Charset to use; default value is 8859-1. Used when anyRemote is in AT-mode.

Device=/dev/rfcommX

Connect string. Default value is bluetooth:19 (which is used in Server mode, so You have to set this parameter up if plans to use anyRemote in AT mode)

Log=true|false|debug

Print or not to print logging info to the file $HOME/.anyRemote/anyremote.log, default value is false. Use Log=debug for verbose logging.

By default all logging informationin will be stored in $HOME/.anyRemote/anyremote.log file. This could be altered by setting AR_TMPDIR environment variable. If AR_TMPDIR environment variable is set then logging information will be printed to ${AR_TMPDIR}/anyremote.log.${USER}

RetrySecs=60

Duration in seconds beetween attempts to reconnect to the phone in case if connection fails. Default value is 60. Works in conjunction with AutoConnect parameter. Used when anyRemote is in AT-mode.

Screen=true

Send or don't send any commands (SendCKPD(), etc.) to the phone. Default value is false.

CmerOn=AT+CMER=3,1,0,0,0

AT+CMER command which enters phone in "echo" mode. In "echo" mode phone will send key codes of buttons pressed over bluetooth; no default value. If this parameter is not specified program will try to determine it automatically. Used when anyRemote is in AT-mode.

CmerOff=AT+CMER=0,0,0,0,0

AT+CMER command which exits phone from "echo" mode; no default value. If this parameter is not specified program will try to determine it automatically. Used when anyRemote is in AT-mode.

ToMainMenu=E

CKPD sequence which used to reach main screen of the phone from any of phone's menus. On Motorola-V500 to press "Red Cancel" button is enough to get out from any menu. Default value is empty string. This parameter is a kind of shortcut which allows not to specify SendCKPD(E) command (see below) for each Key_Code. Used when anyRemote is in AT-mode.

GuiAppName="application name"

GuiAppBinary="name of executable"

GuiAppRun="command do determine is application running or not; must returns OK or NOK"

GuiAppIcon="icon name"

GuiAppType=Application|Custom|Example

GuiAppDesc=Some text

These parameters is used by GUI frontends only.

GuiAppName=Amarok
GuiAppBinary=amarok
GuiAppRun=echo 'A=`dcop | grep amarok`; \
   if [ "x$A" == "x" ]; then echo NOK; \
   else echo OK; fi' | bash -f -s
GuiAppIcon=amarok.png
GuiAppType=Application
GuiAppDesc=Application decription

[Aliases] section

Format:

Key_Code=New_alias

Different phones uses the different keycodes, for example: Button 1 on Motorola generates keycode 1 but the same button on Sagem generates keycode 49. So, if You plans to use this tools with different phones, it could be useful to redefine:

1=One
49=One

and then use "One" in [Keys] section instead of "1" or "49":

[Keys]
One=Exec(echo "Hello world!");
...

[Keys] section

A short example:

[Keys]
(Init)=Exec(kdialog --msgbox "Initialized");
(InCall)=Exec(kdialog --msgbox "A call from $(CallId)");\
         Make(remote,off);
(EndCall)=Make(remote,on);Exec(kdialog --msgbox CALL_END)
(Connect)=Exec(kdialog --msgbox "Connected")
(Disconnect)=Exec(kdialog --msgbox "Disconnected")
1=Exec(kdialog --msgbox 1)
2=Exec(kdialog --msgbox 2)
3=Exec(kdialog --msgbox 3)
4=Exec(kdialog --msgbox 4)
5=Exec(kdialog --msgbox 5)
[End]

Format:

Key_Codes=Command1;Command2;Command3;....

Where CommandX could be:

Exec() command

1=Exec(kdialog --msgbox 1)
2=Exec(kdialog --msgbox 2)

It is possible to define multi-key commands

3 1=Exec(kdialog --msgbox 3_1)
3 2=Exec(kdialog --msgbox 3_2)
3 3 1=Exec(kdialog --msgbox 3_3_1)

It is not good idea to define:

3 3=Exec(kdialog --msgbox 3_3)
3 3 1=Exec(kdialog --msgbox 3_3_1)

simultaneously, since only one command will works (which one - depends on search order).

It is possible to group keymappings in so-called "mode" to set more than one command to the key:

1=Exec(kdialog --msgbox 1)
2=Exec(kdialog --msgbox 2)
[Mode]=1
1=Exec(kdialog --msgbox 1_in_Mode_1)
2=Exec(kdialog --msgbox 2_in_Mode_1)
[ModeEnd]
[Mode]=2
1=Exec(kdialog --msgbox 1_in_Mode_2)
2=Exec(kdialog --msgbox 2_in_Mode_2)
[ModeEnd]

If current mode is not default mode (see Make(mode ...); command), then firstly key will be searched in current mode and if not found then it will be searched in default mode. As a result it needs to use (EnterMode) and (ExitMode) "events" very carefully in default mode.

It is possible to write quite complex commands inside Exec(), for example:

1=Exec(echo 'D=`dcop | grep digikam`; \
     if [ "x$D" == "x" ]; then digikam \
     else dcop $D MainApplication-Interface quit;' | bash -f -s)

Macro() command

This command used to create new keymapping:

1=Macro(Macro1)
Macro1=Exec(kdialog --msgbox 1);Exec(kdialog --msgbox 2)

Macro() command can contain condition:

1=Macro(Macro2, if [ -f /tmp/file_name ]; \
       then true; else false; fi; echo $?)
Macro2=Exec(kdialog --msgbox "Condition is OK")

Conditional Macro() will be execute only if a result of execution of command is equal to string "0".

Note: In shells result code of command execution stored in $? environment variable.

Timer() command

Format:

Timer(key, timeout, maxTimes) or

Timer(key, cancel|pause|continue)

This command sets/removes a timer for the key specified. A command sequence, associated with this key will be executed periodically.

For example, the following commands run 'ls -1' command 2 times with timeout equal to 5 seconds:

7=Timer(TimerCmd, 5, 2)
TimerCmd=Exec(ls -1)

The following command run 'date' command every 10 seconds:

8=Timer(Timer2, 10, 0)
Timer2=Exec(date)

It is impossible to have two active timer commands with the same key.

To delete existing timer use the following command:

9=Timer(TimerName,cancel)

Load() command

This command used to load commands from file and execute them:

1=Load(file_name.cmds)

Include() command

This command used to include definitions from external configuration file:

1=Include(xmms.cfg)

Only [Keys], [Aliases] and [Alarms] sections will be loaded (Parameters section will not be loaded). Definitions from included file will not rewrite any of existing definitions.

Make() command

Format:

Make(flush|disconnect|mode|remote|var[,....])

This command used control local state of anyRemote.

0=Make(flush)
1=Make(mode,mode_2)
2=Make(remote,on)
3=Make(var,my_var,date)

See detailed description here.

SendCKPD() command

1=Exec(kdialog --msgbox 1);SendCKPD(E PAUSE E)

This command sends CKPD sequence back to phone and could be useful if You can't lock the keyboard and needs to clean-up phone screen after each key pressing on phone keypad. It is possible to use word PAUSE to make a 1-second pause before next CKPD command will be sent. This command works when anyRemote is in AT-mode.

Exit

Exit command used to exit from application.

2=Exit;

Event handlers

There are several "events" could be triggered. See Event handlers page for details.

Variable substitution

In Exec(), Make(var,...), Load(), Include() commands is it possible to use internal "variables". See Variable substitution page for details.

[Alarms] section

Format:

Alarm_file=command1;command2;...

When file Alarm_file will be created, then command1, command2 ... will be executed.

/tmp/alarm1=SendCKPD(* 1 *)

In principle, (since this just keyboard emulation stuff) smart guys ;-) could even make a call with this feature.

For example, the following command will dial number 1111111, waits 6 seconds, then finish the call and type "* 3 *" on screen of phone (valid for Motorola-V500).

/tmp/alarm3=SendCKPD(E 1 1 1 1 1 1 1 S \
                PAUSE PAUSE PAUSE PAUSE PAUSE PAUSE E E * 3 *)