Checking if Bluetooth is ON or OFF (Here is the Ans)

Login to reply to this topic.
Thu, 2004-11-04 02:42
Joined: 2003-07-17
Forum posts: 28
Hi,

Bluetooth can be turned on in series60 devices using the notifier.
See my previous posting.. But however this does not work in all symbian devices as it is an undocumented api.

The code below atleast will find out if the bluetooth is ON or OFF.  By this way the code can notify the user to turn on the bluetooth manualy.

This code works in UIQ (p900/p800) as well as in Nokia 9500.

TBool GetBluetoothOn()  // BTONOFF
{
   // Create and initialise an RHostResolver
   RHostResolver hr;
   TInt res = false;
   TBool ret;
   
   RSocketServ socketServer;
   User::LeaveIfError(socketServer.Connect());        
   CleanupClosePushL(socketServer);
   
   res =  hr.Open(socketServer, KBTAddrFamily, BTLinkManager);
   
   if (KErrNone != res) {
      // if not success, this means bluetooth is not on
      ret = EFalse;
   }
   
   else
   {
      ret = ETrue; // Bluetooth is already ON
      hr.Close();
   }
   
   CleanupStack::PopAndDestroy(1);  
   
   return ret;
}


Regards

murali
(WideRay Corp.)

Thu, 2004-11-04 02:44
Joined: 2003-07-17
Forum posts: 28
Checking if Bluetooth is ON or OFF (Here is the Ans)
See previous posting "Turn On Bluetooth"
Thu, 2004-11-04 06:03
Joined: 2004-05-20
Forum posts: 308
Checking if Bluetooth is ON or OFF (Here is the Ans)
Hi Murali,
My Other queries are ...

1. How to check for missed calls, i.e. if there is a missed call , i want to show the hooked receiver on the top of the screen as it happens usually.

2. How to check whether keypad is locked or not .Similarly in this case i want to show the key on top of the screen as it usually happens .

3. Is there an API to find out which operator network the device is connected to (a string with the name of the network) ?

Thanks

Amit

Thu, 2004-12-16 16:25
Joined: 2004-09-10
Forum posts: 12
Checking if Bluetooth is ON or OFF (Here is the Ans)
To check\enable\disable keypad lock use RAknKeyLock. It's a RNotifier inherited class. So:

RAknKeyLock aKeyLock;
aKeyLock.Connect();         //init

aKeyLock.IsKeyLockEnabled();   //return TBool to check if enabled

aKeyLock.EnableKeyLock() or aKeyLock.EnableWithoutNote(); //enables keypad lock

aKeyLock.DisableKeyLock() or aKeyLock.DisableWithoutNote(); //disables keypad lock

aKeyLock.Close();  //must close the notifier

good luck Wink

Vigen

Vigen

Mon, 2004-12-27 14:50
Joined: 2004-05-20
Forum posts: 308
Checking if Bluetooth is ON or OFF (Here is the Ans)
Hi Vigen ,

I cannot understand this RNotifier framework ..
can u just give me an overview of itand what all i can do with it.

Thanks

Amit

Sat, 2005-06-18 13:38
NewLC AdministratorSymbian AccreditedForum Nokia Champion
Joined: 2003-01-14
Forum posts: 1886
Re: Checking if Bluetooth is ON or OFF (Here is the Ans)
On Series 60 you can check the first byte of c:\\system\\data\\btstate.dat
to get the BT state

Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant

Fri, 2005-06-24 11:19
chishti_hameed (not verified)
Forum posts: 2019
Re: Checking if Bluetooth is ON or OFF (Here is the Ans)
Quote from: eric
On Series 60 you can check the first byte of c:\\system\\data\\btstate.dat
to get the BT state

possible for you indetail?
Tue, 2005-08-09 11:08
Joined: 2005-02-11
Forum posts: 214
Re: Checking if Bluetooth is ON or OFF (Here is the Ans)
btstat seems to be working very erraticaly. Sometimes the first byte changes and sometimes not.
For getting the BT settings this code works OK:
Code:

                RSharedDataClient sd;
sd.Connect(0);
sd.Assign( TUid::Uid( 0x10005952 ) );
sd.GetInt( _L("Visibility"), aVisibility );
sd.GetInt( _L("PowerMode"), aPower );

but unfortunately the settings don't work. The BT Manager in phone shows the new settings correctly, but actualy the bluetooth still uses old values.

"I only know that I know nothing." (Socrates)

Thu, 2005-08-11 07:48
Joined: 2005-08-01
Forum posts: 44
Re: Checking if Bluetooth is ON or OFF (Here is the Ans)
Hi all,

Does anyone know how to turn on bluetooth without getting a note? i'm using RNotifier and it gave me a note to the user whether want to turn it on or not, well...i want to get rid of this.

and how to turn off bluetooth programmatically?

need help.....

Thanx in advance,

irma
Thu, 2005-08-11 13:43
Joined: 2005-02-11
Forum posts: 214
Re: Checking if Bluetooth is ON or OFF (Here is the Ans)
Check out this website:
http://www.cs.helsinki.fi/u/mraento/symbian/reverse.html
The solution works for all Symbian 60 and 80 systems I know

"I only know that I know nothing." (Socrates)

Sat, 2005-08-13 16:52
Joined: 2005-08-01
Forum posts: 44
Re: Checking if Bluetooth is ON or OFF (Here is the Ans)
thanx for the reply ^_^
Mon, 2005-08-15 09:11
Joined: 2005-08-01
Forum posts: 44
Re: Checking if Bluetooth is ON or OFF (Here is the Ans)
Riho, I've tried your solution...I've created the bteng.h using the pearl source code that you've gave me before (from the link)

Is it only ....

in the header file

#include <bteng.h>
class CBTMCMSettings;
class CMyBlueToothContainer : public CCoeControl, MCoeControlObserver
    {
....
    private: //data
       

      CBTMCMSettings* iBT;
    };


in the .cpp
===================
#include <bteng.h>

void CMyBlueToothContainer::EnableBlueTooth()
    {
  iBT->SetPowerStateL(ETrue, EFalse); 
  }

void CMyBlueToothContainer::DisableBlueTooth()
    {
iBT->SetPowerStateL(EFalse, EFalse);
    }
=======================


Is it only like this? without active object or anything else?
cause...I've tried it and when I want to enable/disable bluetooth....it's "app closed" and then the bluetooth can't be detected by other device until I restart the phone

I tried it on Nokia 6600

Thanx in advance

Irma

Mon, 2005-08-15 09:25
Joined: 2005-02-11
Forum posts: 214
Re: Checking if Bluetooth is ON or OFF (Here is the Ans)
You must create a pointer first. These are not static functions.

Code:
CBTMCMSettings * btset=CBTMCMSettings::NewLC(NULL);
btset->SetPowerStateL(ETrue,EFalse);
CleanupStack::PopAndDestroy();

"I only know that I know nothing." (Socrates)

Thu, 2005-09-08 22:13
Joined: 2005-09-08
Forum posts: 1
Re: Checking if Bluetooth is ON or OFF (Here is the Ans)
How about UIQ 2.1???

How to turn on Bluetooth on UIQ?

In UIQ there is no BTEng.dll and there's no btnotif.h.

Anyone has the solution?
Wed, 2006-03-01 10:55
Joined: 2005-02-01
Forum posts: 36
Re: Checking if Bluetooth is ON or OFF (Here is the Ans)
I have no Visual C++ 6.0

I Tried the dumpbin from microsoft SDK, but it is obisiously  not doing what itis supposed to.

Can someone email me the headers created from that lib?

My email jkekoni@utbl.net

What the SDK version does:
Code:


Microsoft (R) COFF/PE Dumper Version 7.10.2240.8
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file c:\Symbian\8.0a\S60_2nd_FP2\epoc32\release\wins\udeb\BTENG.DLL

PE signature found

File Type: DLL

FILE HEADER VALUES
             14C machine (x86)
               7 number of sections
        4176D342 time date stamp Thu Oct 21 00:06:10 2004
               0 file pointer to symbol table
               0 number of symbols
              E0 size of optional header
            210E characteristics
                   Executable
                   Line numbers stripped
                   Symbols stripped
                   32 bit word machine
                   DLL

OPTIONAL HEADER VALUES
             10B magic # (PE32)
            6.00 linker version
            B000 size of code
            C000 size of initialized data
               0 size of uninitialized data
            A702 entry point (1000A702)
            1000 base of code
            C000 base of data
        10000000 image base (10000000 to 10017FFF)
            1000 section alignment
            1000 file alignment
            4.00 operating system version
            0.00 image version
            4.00 subsystem version
               0 Win32 version
           18000 size of image
            1000 size of headers
               0 checksum
               2 subsystem (Windows GUI)
               0 DLL characteristics
          100000 size of stack reserve
            1000 size of stack commit
          100000 size of heap reserve
            1000 size of heap commit
               0 loader flags
              10 number of directories
           11460 [     287] RVA [size] of Export Directory
           13000 [     140] RVA [size] of Import Directory
               0 [       0] RVA [size] of Resource Directory
               0 [       0] RVA [size] of Exception Directory
               0 [       0] RVA [size] of Certificates Directory
           17000 [     4F8] RVA [size] of Base Relocation Directory
            C000 [      1C] RVA [size] of Debug Directory
               0 [       0] RVA [size] of Architecture Directory
               0 [       0] RVA [size] of Global Pointer Directory
               0 [       0] RVA [size] of Thread Storage Directory
               0 [       0] RVA [size] of Load Configuration Directory
               0 [       0] RVA [size] of Bound Import Directory
           13804 [     6C4] RVA [size] of Import Address Table Directory
               0 [       0] RVA [size] of Delay Import Directory
               0 [       0] RVA [size] of COM Descriptor Directory
               0 [       0] RVA [size] of Reserved Directory


SECTION HEADER #1
   .text name
    AC8C virtual size
    1000 virtual address (10001000 to 1000BC8B)
    B000 size of raw data
    1000 file pointer to raw data (00001000 to 0000BFFF)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
60000020 flags
         Code
         Execute Read

RAW DATA #1
  10001000: CC CC CC CC CC E9 B6 38 00 00 E9 69 54 00 00 E9  ÌÌÌÌÌé¶8..éiT..é
  10001010: F1 21 00 00 E9 07 3D 00 00 E9 0F 4E 00 00 E9 6A  ñ!..é.=..é.N..éj
  10001020: 0E 00 00 E9 08 3B 00 00 E9 53 63 00 00 E9 70 31  ...é.;..éSc..ép1
  10001030: 00 00 E9 2E 24 00 00 E9 6B 94 00 00 E9 8F 61 00  ..é.$..ék...é.a.
  10001040: 00 E9 05 0F 00 00 E9 45 39 00 00 E9 A0 17 00 00  .é....éE9..é ...
  10001050: E9 27 0C 00 00 E9 89 7E 00 00 E9 21 5F 00 00 E9  é'...é.~..é!_..é

...
Wed, 2006-03-08 12:42
Joined: 2005-02-01
Forum posts: 36
Re: Checking if Bluetooth is ON or OFF (Here is the Ans)
Here are short instructions that are supposed to readable without quesing anything and without having old version Visual C++ dumpbin.exe.

bteng.h
Code:
#ifndef BT_ENG_HACK_H
#define BT_ENG_HACK_H
// link against BTENG.LIB copied from SDK 1.2

// these are headers that are just not included
// in the SDK, so I had to reverse engineer them
//C:\Symbian\tilion\group>"c:\Program Files\Borland\CBuilder6\Bin\expdump.exe"
//   C:\Symbian\Series60_1_2_B\epoc32\release\winsb\udeb\BTENG.LIB
class MBTMCMSettingsCB
{
};
class CBTMCMSettings;
class CBTMCMSettings
{
public:

    static CBTMCMSettings* NewLC(MBTMCMSettingsCB *x);
    static CBTMCMSettings* NewL(MBTMCMSettingsCB  *x);
   
    void SetPowerStateL(TBool a, TBool b);
    void GetPowerStateL(TBool &a);
    TInt GetConnectionStatus(int &a);
};
#endif

Then you need to install SDK 1.2.

Then you need to copy bteng.lib file from:
C:\Symbian\Series60_1_2_B\epoc32\relese\armi\udeb
to:
C:\Symbian\7.0s\Series60_v21\Epoc32\release\armi\udeb
and

C:\Symbian\Series60_1_2_B\epoc32\relese\armi\urel
to:
C:\Symbian\7.0s\Series60_v21\Epoc32\release\armi\urel
(and same to thumb).

You need to link againts
bteng.lib in mmp file.

And the following code will turn on BT.
The compiled code works with 6630.
Code:
    // turn on Bluetooth in case it was off
    settings= CBTMCMSettings::NewL( (MBTMCMSettingsCB*)NULL );
             
    settings->SetPowerStateL(ETrue,EFalse ); // on, off is (EFalse,EFalse)

I have checked this S60V2FP1 SDK with Borland tools and tested on N6630.

I have not cheked this with emulator, but no-one has the BT/internet working with the emulator anyway.
  • Login to reply to this topic.