1.2.5. Examples
Now that you have learned how to configure Gnokii. You may be wondering how to apply that knowledge in real-world scenarios. In the following sections, we will provide a few examples that demonstrate how to connect an actual mobile phone to a Linux PC step by step and how to make necessary changes in the configuration file of Gnokii.
1.2.5.1. Using Gnokii with Nokia 6021 and Bluetooth on Fedora Core 5
Below shows the steps to use Gnokii 0.6.14 with Nokia 6021 through the Bluetooth wireless technology on Fedora Core 5. The steps may be slightly different on other Linux distributions. Fedora Core 5 loads some services and kernel modules that are required to use Bluetooth and USB (suppose you are using a USB Bluetooth adapter/dongle) by default. If you are not using Fedora Core 5, you may need to load these services and kernel modules manually. Consult the documentation of the Linux distribution you are using for the detailed instructions on using Bluetooth and USB.
1. On Fedora Core 5, open the HCI daemon configuration file located at /etc/bluetooth/hcid.conf with a text editor. Lines that begin with the "#" character are comments. The default settings are used except the following line:
security user;
We change it to:
security auto;
After doing this, the PIN specified in the file /etc/bluetooth/pin will be used for pairing with another Bluetooth device in the future. More details about the hcid.conf file can be found by entering the command line "man hcid.conf" under Fedora Linux.
Here are the contents of our hcid.conf file:
options
{
autoinit yes;
security auto;
pairing
multi;
#pin_helper
/usr/bin/bluepin;
dbus_pin_helper;
}
device {
name
"%h-%d";
class 0x120104;
#pkt_type
DH1,DM1,HV1;
iscan enable; pscan enable;
lm accept;
lp
rswitch,hold,sniff,park;
#auth enable;
#encrypt enable;
}
2. Open the file /etc/bluetooth/pin with a text editor. Enter a PIN you like. This PIN will be used for pairing with another Bluetooth device, such as a mobile phone. In our case, we enter 654321.
3. Attach a Bluetooth adapter (Bluetooth dongle) to the PC. The one we are using is a USB Bluetooth adapter. Skip this step if your PC has a built-in Bluetooth adapter. Many notebook computers have built-in support of Bluetooth these days.
4. Start the HCI daemon on Fedora Linux by typing the command below:
# hcid
5. Enter the command hciconfig to see some basic information about the Bluetooth adapter. You should see "UP RUNNING" at the beginning of the third line, which means the Bluetooth adapter is active.
#
hciconfig
hci0: Type: USB
BD Address:
00:11:AB:B3:10:EB ACL MTU: 678:8 SCO MTU: 48:10
UP RUNNING
PSCAN ISCAN
RX bytes:385 acl:0 sco:0 events:18
errors:0
TX bytes:322 acl:0 sco:0 commands:18 errors:0
6. Turn on the Bluetooth function of the Nokia 6021 mobile phone by selecting Menu -> Settings -> Connectivity -> Bluetooth -> Bluetooth -> On.
7. Next we need to go through the pairing process. Once completed, the PC will appear in the list of paired devices on the mobile phone. (On Nokia 6021, the list of paired devices is available at Menu -> Settings -> Connectivity -> Bluetooth -> Paired devices.) You do not have to go through the pairing process next time, unless you delete the PC from the list of paired devices on the mobile phone.
To pair the PC with Nokia 6021, go to Menu -> Settings -> Connectivity -> Bluetooth -> Paired devices on Nokia 6021, and then select New. Wait a few seconds for Nokia 6021 to detect Bluetooth devices available nearby. After that, a list of devices found appears. Highlight the name of the PC and select Pair. Nokia 6021 then asks for a passcode. Enter the number you specified in the /etc/bluetooth/pin file in step 2. Since we specified 654321 in the /etc/bluetooth/pin file in step 2, we enter 654321 here.
8. Now we want to find out the Bluetooth address of the mobile phone. If you know it, you can go directly to the next step.
First, on Nokia 6021, specify Shown to all at Menu -> Settings -> Connectivity -> Bluetooth -> Bluetooth settings -> My phone's visibility to allow other devices to detect the presence of Nokia 6021 through Bluetooth.
Second, on Fedora Linux, use the hcitool command to detect Bluetooth devices nearby. If success, you will see something like this:
#
hcitool scan
Scanning ...
00:62:25:25:1A:4B Nokia
6021
"00:62:25:25:1A:4B" is the Bluetooth address of our Nokia 6021 mobile phone. (Your mobile phone should have a different value.) Mark it down since it will be required in later steps. "Nokia 6021" is the name we specified on the Nokia 6021 mobile phone and it has nothing to do here, although you can change it at Menu -> Settings -> Connectivity -> Bluetooth -> Bluetooth settings -> My phone's name.
Third, on Nokia 6021, go to Menu -> Settings -> Connectivity -> Bluetooth -> Bluetooth settings -> My phone's visibility and change the value back to Hidden to ensure higher level of security.
What to do in step 9 depends on whether you would like to use AT mode and whether you would like to use a RFCOMM connection. There are three possibilities:
Step 9b. You are going to use AT mode but not a RFCOMM connection.
Step 9c. You are going to use AT mode and a RFCOMM connection.
All three possibilities are discussed below for completeness. To save time, you may just read one of them. With our Nokia 6021 mobile phone, XGnokii provides more features in non-AT mode than in AT mode. For example, when operating in AT mode, only "Inbox" and "Outbox" are available in XGnokii's Short Message Service window (see figure 2). But when operating in non-AT mode, "Sent items", "Templates", etc are accessible additionally. Regarding RFCOMM, Gnokii/XGnokii works in the same way no matter RFCOMM is used or not. However, if you do not compile Gnokii/XGnokii's source code with Bluetooth support, Gnokii/XGnokii can only operate with a RFCOMM connection between the PC and mobile phone.
1.2.5.1.1. For Non-AT Mode
9a. Open Gnokii's configuration file in a text editor under Fedora Linux. Change the values of the port parameter, model parameter and connection parameter to 00:62:25:25:1A:4B (the Bluetooth address of the mobile phone found previously), 6021 and bluetooth respectively:
port
= 00:62:25:25:1A:4B
model = 6021
connection = bluetooth
The other parameters remain unchanged:
#
irda_string = Nokia 6610i
initlength = default
use_locking =
yes
serial_baudrate = 19200
#serial_write_usleep =
10000
#handshake = software
#require_dcd = 1
#rfcomm_channel
= 1
#sm_retry = 1
#connect_script =
/absolute/path/to/gnokii/Docs/sample/cimd-connect
#disconnect_script
=
smsc_timeout = 10
[gnokiid]
bindir =
/usr/local/sbin/
[connect_script]
TELEPHONE =
12345678
[disconnect_script]
[logging]
debug = on
rlpdebug
= off
xdebug = off
1.2.5.1.2. For AT Mode without RFCOMM Connection
9b.Open Gnokii's configuration file in a text editor under Fedora Linux. Change the values of the port parameter, model parameter and connection parameter to 00:62:25:25:1A:4B (the Bluetooth address of the mobile phone found previously), AT and bluetooth respectively:
port
= 00:62:25:25:1A:4B
model = AT
connection = bluetooth
The other parameters remain unchanged:
#
irda_string = Nokia 6610i
initlength = default
use_locking =
yes
serial_baudrate = 19200
#serial_write_usleep =
10000
#handshake = software
#require_dcd = 1
#rfcomm_channel
= 1
#sm_retry = 1
#connect_script =
/absolute/path/to/gnokii/Docs/sample/cimd-connect
#disconnect_script
=
smsc_timeout = 10
[gnokiid]
bindir =
/usr/local/sbin/
[connect_script]
TELEPHONE =
12345678
[disconnect_script]
[logging]
debug = on
rlpdebug
= off
xdebug = off
1.2.5.1.3. For AT Mode with RFCOMM Connection
9c. Establish a RFCOMM connection between the PC and the Nokia 6021 mobile phone by the rfcomm command, like below:
# rfcomm connect 0 00:62:25:25:1A:4B 1
After the rfcomm command, the first argument connect tells Fedora Linux to initiate a RFCOMM connection to another Bluetooth device.
The second argument specifies the value of n in /dev/rfcommn for the connection to the mobile phone. For example, if this argument is 0, then Fedora Linux will use the /dev/rfcomm0 port for the RFCOMM connection; if this argument is 1, then Fedora Linux will use the /dev/rfcomm1 port instead.
The third argument specifies the Bluetooth address of the device to connect to. It should be the value you found in step 8.
The fourth argument specifies the channel number to be used for the RFCOMM connection. If this argument is not specified, channel 1 will be used by default.
After typing the rfcomm command line and pressing the Enter key on the PC, the screen of Nokia 6021 shows a dialog box saying the PC attempts to connect to it. Select Accept on Nokia 6021.
If the PC connects to the Nokia 6021 mobile phone successfully, you will see something like this under Fedora Linux:
#
rfcomm connect 0 00:62:25:25:1A:4B 1
Connected /dev/rfcomm0 to
00:62:25:25:1A:4B on channel 1
Press CTRL-C for hangup
Open Gnokii's configuration file in a text editor under Fedora Linux. Change the values of the port parameter, model parameter, connection parameter and rfcomm parameter to /dev/rfcomm0, AT, serial and 1 respectively:
port
= /dev/rfcomm0
model = AT
connection = serial
rfcomm_channel
= 1
The other parameters remain unchanged:
#
irda_string = Nokia 6610i
initlength = default
use_locking =
yes
serial_baudrate = 19200
#serial_write_usleep =
10000
#handshake = software
#require_dcd = 1
#sm_retry =
1
#connect_script =
/absolute/path/to/gnokii/Docs/sample/cimd-connect
#disconnect_script
=
smsc_timeout = 10
[gnokiid]
bindir =
/usr/local/sbin/
[connect_script]
TELEPHONE =
12345678
[disconnect_script]
[logging]
debug = on
rlpdebug
= off
xdebug = off
10. Start using Gnokii or XGnokii.
Previous Page | Page 8 of 12 | Next Page |
- 1. How to Use a Linux PC to Send and Receive SMS Messages (Non-Developer's Perspective)
- 1.1. Requirements for Sending and Receiving SMS Messages from a Linux PC via a Mobile Phone
- 1.2. Using Gnokii to Send and Receive SMS Messages from a Linux PC
- 1.2.1. Introduction
- 1.2.2. Mobile Phone Models Supported by Gnokii
- 1.2.3. Installing Gnokii / XGnokii
- 1.2.4. Configuring Gnokii / XGnokii on Linux
- 1.2.5. Examples
- 1.2.6. Testing Gnokii on Linux
- 1.2.7. Sending SMS Text Messages with XGnokii on Linux
- 1.2.8. Receiving SMS Text Messages with XGnokii on Linux
- 1.2.9. Importing and Exporting Phone Book Entries with XGnokii on Linux