| Access Server: User's and Developer's Guide | ||
|---|---|---|
| <<< Previous | Next >>> | |
The Bluetooth service in Access Server is controlled via a TCP socket interface, called iWRAP. The first iWRAP server is listening on port 10101. In case of Access Server 2293, the second iWRAP server is listening on port 10102, and the third one is listening on port 10103. All commands to the iWRAP server and replies from the server are plain ASCII strings ending in CR+LF ("\r\n"). Commands and replies are not case sensitive.
When connecting to iWRAP, you must first wait for the READY. prompt. Do not send any commands prior to this.
By default the connection to iWRAP is protected by a password. The default password is buffy. The password can be disabled or changed. For more information, see SET command. If the password is enabled, it must be sent first, immediately following the READY. prompt. Otherwise all commands will fail with an error code.
Some replies are broadcasted to all clients by the iWRAP server. If you see something that you have not requested or the reply is not intended to you, simply ignore the reply.
In the following examples, bold lines are commands sent by the client to the iWRAP server and normal lines are replies received from the iWRAP server by the client.
Bluetooth address (bdaddr) consists of six hex digits separated by a colon. For example, "00:07:80:80:bf:01". With commands requiring a Bluetooth address, you can also use the Bluetooth friendly name instead.
Bluetooth RFCOMM channels are numbered from 1 to 30. In Access Server, Serial Port Profile is assigned to channel number two, Object Push Profile and File Transfer Profile to channel number three, and LAN Access Profile is on channel number four. The other channels are free for user applications.
Link Identifier (link_id) is a number from 0 to 99. It is used to identify established Bluetooth connections.
Normally, the iWRAP servers are started automatically upon power-up. You can restart them manually (for example, to apply changes made to the iWRAP settings with the setup application without rebooting the system). To restart the servers manually, execute the startup script with option restart:
[root@wrap /] service bluetooth restart |
When the iWRAP servers start up, they use settings configured with the setup application. You can put additional iWRAP commands to /etc/bluetooth.conf file. Commands in that file are processed as the last task every time the iWRAP server is started.
There are two approaches when writing a iWRAP server program (a program accepting incoming calls) for Access Server, both having different pros and cons:
Forklistener
iWRAP Client
Note: When writing a client program (that is, a program making an outgoing call), you have to use iWRAP.
This is a standard program reading data from standard input and writing output to standard output. See the SDK directory examples/forkserver/ for an example of this kind of program.
Pros:
Easy to write.
Very robust for simple services.
You do not have to understand Bluetooth or iWRAP.
Cons:
Your program is started and stopped for every incoming connection.
If there are multiple connections, it is not possible to communicate to an external program through one socket.
You cannot use stdout for debugging; you must use syslog or a log file.
iWRAP's advanced features are not available: powermodes, MSC, SDP, inquiry, ...
To setup a forklistener, see the SET command.
iWRAP client is a program communicating with the iWRAP server through control and data sockets. See the SDK directory examples/btserver/ for an example of this kind of program.
Pros:
The cons with forklistener do not apply.
Cons:
More complex than forklistener.
You must have basic knowledge about Bluetooth and iWRAP.
If you have multiple iWRAP clients (which is usually the case), some kind of IPC is usually needed. For example, if client #1 uses CALL command, client #2 may not do the same before client #1 receives RINGING reply. The easiest way to do this is to use LOCK command.
You can send iWRAP commands from the command line by using the btcli application.
Usage:
btcli [options] command |
To see the command options, enter the btcli --help command.
The specified command is sent to iWRAP server (the first server at port 10101 by default) and all replies are echoed to the standard output. The application waits and prints the replies for a certain amount of time (6 seconds by default) and exits.
This section describes the commands used for Bluetooth service discovery and local SDP record manipulation. The commands and their replies use SDP UUID and attribute values, which are listed in the Bluetooth Assigned Numbers documentation. In the commands below, the most useful UUID and attribute values can, however, be replaced with keywords listed in Table 7-5. The same keywords are used in the command replies instead of numeric values, if the parameter SET BLUETOOTH READABLE is set to 1.
Table 7-5. Supported Keywords for Replacing SDP UUIDs or Attributes
| Keyword(s) | Hex Value |
|---|---|
| SDP | 0001 |
| RFCOMM | 0003 |
| OBEX | 0008 |
| BNEP | 000F |
| L2CAP | 0100 |
| PUBLICBROWSEGROUP, BROWSE, ROOT | 1002 |
| SERIALPORT, SPP | 1101 |
| LANACCESS, LAN | 1102 |
| DIALUPNETWORKING, DUN | 1103 |
| OBEXOBJECTPUSH, OBJP, OPP | 1105 |
| OBEXFILETRANSFER, FTP | 1106 |
| PAN-PANU, PANU | 1115 |
| PAN-NAP, NAP | 1116 |
| PAN-GN, GN | 1117 |
| PNPINFORMATION, DI | 1200 |
| SERVICECLASSIDLIST, SERVICECLASS, CLASS | 0001 |
| PROTOCOLDESCRIPTORLIST, DESCLIST, DESC | 0004 |
| SERVICEAVAILABILITY | 0008 |
| SERVICENAME, NAME | 0100 |
| SERVICEDESCRIPTION, DESCRIPTION | 0101 |
| SECURITYDESCRIPTION | 030A |
| NETACCESSTYPE | 030B |
| MAXNETACCESSRATE | 030C |
Outgoing RFCOMM Call:
READY.
CALL 00:07:80:80:bf:01 1 RFCOMM
CALL 2
RINGING 2
CONNECT 2 RFCOMM 1042
STATUS 2 MSC 8d
<Client opens socket connection to port 1042 and transfers data>
CLOSE 2
NO CARRIER 2 ERROR 000
|
Incoming RFCOMM Call:
READY.
RING 2 00:07:80:80:bf:01 1 RFCOMM 1042
STATUS 2 MSC 8d
<Client opens socket connection to port 1042 and transfers data>
NO CARRIER 2 ERROR 000
|
Some commands may reply with an error code. The human-readable name of the error is displayed, if the SET BLUETOOTH READABLE setting has value 1. Error code 8 indicates that the iWRAP server is busy executing a number of commands; there can be several client applications using the stack. Just wait a few seconds and try again. Other error codes indicate unexpected, but often only temporary, communication problems.
You can analyze the error from the numeric code. Values bigger than or equal to 900 are iWRAP errors, described in Table 7-7.
Table 7-7. iWRAP Errors
| Code | Textual Form | Reason |
|---|---|---|
| 900 | SERVICE_NOT_FOUND | Tried to CALL a device whose SDP records do not include the requested service. |
| 901 | ALREADY_CONNECTED | Tried to CALL a device and a service channel that is already connected. |
| 902 | OUT_OF_HANDLES | Tried to CALL, but there are too many open connections. |
| 903 | INVALID_ADDRESS_<addr> | Tried to CALL a device with a friendly name that could not be found with the inquiry. |
| 904 | REJECTED | An incoming call was rejected by the iWRAP server. |
| 905 | BUSY | Tried to issue SDPATTR, but another SDP request was in progress. |
| 906 | BUSY | Tried to issue SDPQUERY, but another SDP request was in progress. |
| 907 | NOT_CONNECTED | Tried to CLOSE a connection handle that is not active. |
| 908 | BUSY | Tried to issue SDPSEARCH, but another SDP request was in progress. |
| 909 | INVALID_ADDRESS | Tried to NAME a device with a friendly name that cannot be found with the inquiry. |
| 90a | BUSY | Tried to issue NAME, but another NAME was in progress. |
Other error codes can be analyzed as follows. For example, NO CARRIER ERROR 465: The number 465 is hexadecimal, the sum of 0x400 and 0x65, where 0x400 is a mask, which means that this is an RFCOMM level error. 0x65 (decimal 101) means that the RFCOMM error was a connection timeout.
The error codes for each mask are listed in the following tables.
Table 7-9. HCI Error Codes
| HCI Error | Code |
|---|---|
| HCI_SUCCESS | 0 |
| HCI_ERR_UNKNOWN_COMMAND | 1 |
| HCI_ERR_NOCONNECTION | 2 |
| HCI_ERR_HARDWARE_FAIL | 3 |
| HCI_ERR_PAGE_TIMEOUT | 4 |
| HCI_ERR_AUTHENTICATION_FAILED | 5 |
| HCI_ERR_KEY_MISSING | 6 |
| HCI_ERR_MEMORY_FULL | 7 |
| HCI_ERR_CONNECTION_TIMEOUT | 8 |
| HCI_ERR_MAX_NUM_CONNECTIONS | 9 |
| HCI_ERR_MAX_NUM_SCO_CONNECTIONS | 10 |
| HCI_ERR_ACL_CONN_ALREADY_EXISTS | 11 |
| HCI_ERR_COMMAND_DISALLOWED | 12 |
| HCI_ERR_HOST_REJECTED_0D | 13 |
| HCI_ERR_HOST_REJECTED_0E | 14 |
| HCI_ERR_HOST_REJECTED_0F | 15 |
| HCI_ERR_HOST_TIMEOUT | 16 |
| HCI_ERR_UNSUPPORTED_PARAM_VALUE | 17 |
| HCI_ERR_INVALID_HCI_PARAMETER_VALUE | 18 |
| HCI_ERR_OTHER_END_TERMINATE_13 | 19 |
| HCI_ERR_OTHER_END_TERMINATE_14 | 20 |
| HCI_ERR_OTHER_END_TERMINATE_15 | 21 |
| HCI_ERR_CONNECTION_TERMINATE_LOCALLY | 22 |
| HCI_ERR_REPEATED_ATTEMPTS | 23 |
| HCI_ERR_PARING_NOT_ALLOWED | 24 |
| HCI_ERR_UNKNOWN_LMP_PDU | 25 |
| HCI_ERR_UNSUPPORTED_REMOTE_FEATURE | 26 |
| HCI_ERR_SCO_OFFSET_REJECTED | 27 |
| HCI_ERR_SCO_INTERVAL_REJECTED | 28 |
| HCI_ERR_SCO_AIR_MODE_REJECTED | 29 |
| HCI_ERR_INVALID_LMP_PARAMETERS | 30 |
| HCI_ERR_UNSPECIFIED_ERROR | 31 |
| HCI_ERR_UNSUPPORTED_LMP_PARAMETER_VAL | 32 |
| HCI_ERR_ROLE_CHANGE_NOT_ALLOWED | 33 |
| HCI_ERR_LMP_RESPONSE_TIMEOUT | 34 |
| HCI_ERR_LMP_ERROR_TRANSACTION_COLLISION | 35 |
| HCI_ERR_LMP_PDU_NOT_ALLOWED | 36 |
| HCI_ERR_ENCRYPTION_MODE_NOT_ACCEPTABLE | 37 |
| HCI_ERR_UNIT_KEY_USED | 38 |
| HCI_ERR_QOS_NOT_SUPPORTED | 39 |
| HCI_ERR_INSTANT_PASSED | 40 |
| HCI_ERR_PAIRING_WITH_UNIT_KEY_NOT_SUPP | 41 |
| HCI_ERR_ILLEGAL_HANDLE | 100 |
| HCI_ERR_TIMEOUT | 101 |
| HCI_ERR_OUTOFSYNC | 102 |
| HCI_ERR_NO_DESCRIPTOR | 103 |
Table 7-10. L2CAP Error Codes
| L2CAP Error | Code |
|---|---|
| L2CAP_NO_CAUSE | 0 |
| L2CAP_ERR_PENDING | 1 |
| L2CAP_ERR_REFUS_INV_PSM | 2 |
| L2CAP_ERR_REFUS_SEC_BLOCK | 3 |
| L2CAP_ERR_REFUS_NO_RESOURCE | 4 |
| L2CAP_ERR_TIMEOUT_EXTERNAL | 0xee |
Table 7-11. SDP Error Codes
| SDP Error | Code |
|---|---|
| SDP_ERR_RESERVED | 0 |
| SDP_ERR_UNSUPPORTED_SDP_VERSION | 1 |
| SDP_INVALID_SERVICE_RECORD_HANDLE | 2 |
| SDP_INVALID_REQUEST_SYNTAX | 3 |
| SDP_INVALID_PDU_SIZE | 4 |
| SDP_INVALID_CONTINUATION_STATE | 5 |
| SDP_INSUFFICIENT_RESOURCES | 6 |
| SDP_ERR_UNHANDLED_CODE | 100 |
| SDP_ERR_TIMEOUT | 101 |
| SDP_ERR_NOTFOUND | 102 |
| SDP_INVALID_RESPONSE_SYNTAX | 103 |
| SDP_NOT_FOUND (not really an error) | 200 |
Table 7-12. RFCOMM Error Codes
| RFCOMM Error | Code |
|---|---|
| RFCOMM_SUCCESS | 0 |
| RFCOMM_ERR_NORESOURCES | 1 |
| RFCOMM_ERR_ILL_PARAMETER | 2 |
| RFCOMM_ERR_REJECTED (Connection setup was rejected by remote side) | 100 |
| RFCOMM_ERR_TIMEOUT (Connection timed out) | 101 |
| RFCOMM_ERR_NSC (Non supported command received) | 102 |
| RFCOMM_ERR_ILLPARAMETER | 103 |
If the problems persist after restarting the communication parties, please contact Bluegiga Technologies as instructed in Section 1.2.
| <<< Previous | Home | Next >>> |
| Software Development Kit | I/O API |