Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Revision as of 23:19, 18 December 2011 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Como recuperar o endereço Bluetooth local

From Wiki
Jump to: navigation, search
Article Metadata

Platform Security
Capabilities: LocalServices

Artigo
Tradução:
Por ivocalado
Última alteração feita por hamishwillee em 18 Dec 2011

Normalmente o endereço bluetooth de um dispositivo pode ser recuperado digitando o seguinte código no teclado: *#2820# (*#BTA0#) O seguinte trecho de código mostra como recuperar o endereço do dispositivo bluetooth local via programação (Symbian 3rd ed.).

Código exemplo

Cabeçalhos:

#include <bttypes.h>
#include <bt_subscribe.h>

Biblioteca:

bluetooth.lib

Capabilities:

LocalServices

Os valores dos seguintes tipos Int', Uid e Uint são providos em bt_subscribe.h:

const TInt KUidBluetoothPubSubKeyBase = 0x10203637;
const TUid KPropertyUidBluetoothCategory = {KUidSystemCategoryValue};
const TUint KPropertyKeyBluetoothGetLocalDeviceAddress =
(KUidBluetoothPubSubKeyBase + 0);

Os valores dos seguitnes Int32 e Uid são providos em e32_property.h (incluido em bt_subscribe.h):

static const TInt32 KUidSystemCategoryValue=0x101f75b6;
static const TUid KUidSystemCategory={KUidSystemCategoryValue};


O seguinte código recupera o endereço Bluetooth único no formato hexadecimal:

TBuf<20> aBTAddr;
TPckgBuf<TBTDevAddr> aDevAddrPckg;
RProperty::Get(KUidSystemCategory,
KPropertyKeyBluetoothGetLocalDeviceAddress, aDevAddrPckg);
aDevAddrPckg().GetReadable(aBTAddr, KNullDesC, _L(":"), KNullDesC);
aBTAddr.UpperCase();

Nota: O endereço Bluetooth será armazenado na variável "aBTAddr" e contem exatamente 17 caracteres no formato 00:00:00:00:00:00 (i.e. incluindo 5 ":").

This page was last modified on 18 December 2011, at 23:19.
222 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×