Symbian3/SDK/Source/GUID-783D0B50-0E8A-5199-A07E-749D4A71E671.dita
changeset 0 89d6a7a84779
child 13 48780e181b38
equal deleted inserted replaced
-1:000000000000 0:89d6a7a84779
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE concept
       
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
       
    12 <concept xml:lang="en" id="GUID-783D0B50-0E8A-5199-A07E-749D4A71E671"><title>Processing an Extended Inquiry Response</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>This tutorial shows you how to retrieve and process the data from a Bluetooth Extended Inquiry Response (EIR). </p> <section><title>Introduction</title> <p>This tutorial shows you how to retrieve the EIR data and how to access the various types of data within it. </p> <p><b>Basic Procedure</b> </p> <p>The high level steps to access the EIR are shown here: </p> <ol id="GUID-27E2F081-EE4A-516D-8D04-29D1A4601045"><li id="GUID-2F5F1046-3335-53CA-AD6D-01D1981348B5"><p>Create the <codeph>EIR</codeph> object and during construction fill it with the data from the Extended Inquiry Response </p> </li> <li id="GUID-541D9DF2-816B-5057-B116-8A587F7A2146"><p>Use access functions to retrieve the different types of data. </p> </li> </ol> </section> <section><title>Environment</title> <p>This tutorial assumes that you have your device correctly configured, active and with Bluetooth enabled and the Bluetooth Stack initialised. <codeph>iResult</codeph> is in scope and contains a <xref href="GUID-C625E339-6726-3FB9-8F8A-F4DB0CAC15FF.dita"><apiname>TNameEntry</apiname></xref> object as the result of a successful Inquiry request. See <xref href="GUID-58F65411-CF08-5F46-8222-3FDB9E571FCC.dita">Inquiring About Remote Devices</xref>. </p> <p> <b>Note:</b> When the Inquiry Request is made, set the <codeph>aDoEIR</codeph> flag to specify that Extended Inquire Response data is required. The Bluetooth Stack will set the <codeph>aDoEIR</codeph> flag if an older version of the API (non-EIR) is used. </p> </section> <section><title>Tutorial</title> <p><b>Create an object to hold the Extended Inquiry Response data </b> </p> <ul><li id="GUID-0837BC7D-58A1-5E84-B64F-D2705DA2A844"><codeblock id="GUID-945D5812-6C22-595F-BE1F-F384C72121E1" xml:space="preserve">TBluetoothNameRecordWrapper eir(iResult());</codeblock> </li> </ul> <p><b> Use access functions to retrieve the various kinds of data</b> </p> <ol id="GUID-2733C57E-2A4B-58CD-9340-A0DA609F5705"><li id="GUID-0CA4F35B-23D4-570C-BAAC-520B5CEA62D2"><p>Get the Bluetooth device local name </p> <p> <b>Note:</b> The device local name may be truncated if it is too long to fit in the EIR data packet. If the name is not truncated then the <codeph>isNameComplete</codeph> flag will be set to <codeph>TRUE</codeph>. </p> <codeblock id="GUID-5F03D407-41FD-53AB-8DA7-B5F465719CFD" xml:space="preserve">
       
    13 TBool isNameComplete;
       
    14 TInt error = KErrNone;
       
    15 TInt length = 0;
       
    16             
       
    17 // Get name
       
    18 // This length could be used to create the TBuf to be passed into GetDeviceName()
       
    19 length = eir.GetDeviceNameLength();
       
    20 TBuf&lt;255&gt; name;
       
    21 if(length &gt;= 0)
       
    22  {
       
    23  // name will contain a Unicode encoded 16-bit string
       
    24     error = eir.GetDeviceName(name, isNameComplete);
       
    25     }
       
    26  else
       
    27     {
       
    28         error = length;
       
    29     }
       
    30 if(error == KErrNone)
       
    31 // we have name here
       
    32     {
       
    33     if(isNameComplete == EFalse)
       
    34         {
       
    35         iHROutputConsole-&gt;Printf(_L("%d Bytes [Partial] Name: "), length);
       
    36         }
       
    37     else
       
    38         {
       
    39         iHROutputConsole-&gt;Printf(_L("%d Bytes [Complete] Name: "), length);
       
    40         }
       
    41         iHROutputConsole-&gt;Printf(_L("%S \n"),&amp;name);
       
    42     }
       
    43 </codeblock> </li> <li id="GUID-323875EC-7012-537A-935A-74A91DE0F8D7"><p>Get the Transmission Power level </p> <codeblock id="GUID-870F61A6-F827-5B6D-BD4D-A8BB9EFAB0C6" xml:space="preserve">// Get TxPowerLevel
       
    44 TInt8 txPowerLevel;
       
    45 error = eir.GetTxPowerLevel(txPowerLevel);
       
    46 if(error == KErrNone)
       
    47     // TxPowerLevel present
       
    48     {
       
    49     iHROutputConsole-&gt;Printf(_L("TxPowerLevel: %ddBm\n"), txPowerLevel);
       
    50     }</codeblock> </li> <li id="GUID-2C67FE67-0652-5840-BA1F-04891A95CAB6"><p>Get the Service Class UUIDs. </p> <p> </p> <codeblock id="GUID-132B642E-EC0A-54D5-B0F6-4F4218578EB5" xml:space="preserve">// Get UUIDs
       
    51 RExtendedInquiryResponseUUIDContainer uuidContainer;
       
    52 error = eir.GetServiceClassUuids(uuidContainer);
       
    53 if(error &gt;= KErrNone)
       
    54     {
       
    55     RArray&lt;TUUID&gt; uuids;
       
    56     TInt uuidCount = uuidContainer.UUIDs().Count();
       
    57     if(uuidCount &gt; 0)
       
    58      {
       
    59         iHROutputConsole-&gt;Printf(_L("*** UUID Count: %d\n"), uuidCount);
       
    60         TInt i;
       
    61         for(i=0;i&lt;uuidCount;i++)
       
    62             {
       
    63             TInt j;
       
    64             TPtrC8 uuid(uuidContainer.UUIDs()[i].ShortestForm());
       
    65             // Treat it as a big endian
       
    66             for(j=0;j&lt;uuid.Length();j++)
       
    67                 {
       
    68                 iHROutputConsole-&gt;Printf(_L("%02X"), uuid[j]);
       
    69                 }
       
    70                 
       
    71             iHROutputConsole-&gt;Printf(_L(" \n"));
       
    72             }
       
    73         }
       
    74     }</codeblock> </li> <li id="GUID-C694FBFB-496F-5936-B542-BDB3CD0C063B"><p>Get Manufacturer Specific data. </p> <p> <b>Note:</b> This data is entirely defined by the individual Manufacturer. </p> <codeblock id="GUID-A53768A5-9644-5D56-84BC-EAA4580E8280" xml:space="preserve">// Get Manufacturer Specific Data
       
    75 length = eir.GetVendorSpecificDataLength();
       
    76 TBuf8&lt;255&gt; msd;
       
    77 if(length &gt; 0)
       
    78     {
       
    79     error = eir.GetVendorSpecificData(msd);
       
    80     }
       
    81 else
       
    82     {
       
    83     error = length;
       
    84  }
       
    85 if(error == KErrNone)
       
    86 // we have Manufacturer Specific Data here
       
    87     {
       
    88     // This conversion is for display reason, in a real world this may not be necessary as 
       
    89     // Manufacturer specific data can be just raw 8-bit data, however GetDeviceName() is
       
    90     // different as it always return Unicode encoded 16-bit string
       
    91     error = CnvUtfConverter::ConvertToUnicodeFromUtf8(name, msd);
       
    92     if(error &gt;= KErrNone &amp;&amp; length &gt; 0)
       
    93         {
       
    94         iHROutputConsole-&gt;Printf(_L("%d Bytes Manufacturer Specific Data: %S\n"), length, &amp;name);
       
    95         }
       
    96     }
       
    97 }</codeblock> </li> </ol> </section> </conbody><related-links><link href="GUID-F2A793F1-A5B5-526B-B147-771D440B13A2.dita"><linktext>Bluetooth Extended Inquiry
       
    98              Response</linktext> </link> <link><linktext/></link></related-links></concept>