×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Regular Contributor
    Join Date
    Oct 2007
    Location
    Malta
    Posts
    80

    RNotifier AppUI class for Bluetooth

    Hi, I have a few questions on how this class is operating.
    First of all in the SDK there is an example on using this particular class for Bluetooth device discovery.
    Code:
    TBTDeviceSelectionParams selectionFilter;
    TBTDeviceSelectionParamsPckg pckg(selectionFilter);
    TBTDeviceResponseParams result;
    TBTDeviceResponseParamsPckg resultPckg(result);
    The above parameters are declared. Now let's say i need the result of the device chosen stored as a private member of a class, rather than in the actual implementation, so I can access the device's data anytime within the GUI, and not within that scope.
    1) How and where do I initialize the TBTDeviceResponseParamsPckg variable?

    My other question regards getting the Bluetooth 48-bit address and display it to the user through a command menu. BDAddr() returns the address of the device. Now to read the address I use, GetReadable(),

    IMPORT_C void GetReadable(TDes &aDest) const;

    to "Extract the Bluetooth device address into a human-readable format".

    2) What suitable descriptor can be used to store this data. I tried all sorts of descriptors and haven't had luck. USER11, due to the large returned descriptor seems to be the most common problem here.

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,165

    Re: RNotifier AppUI class for Bluetooth

    1. you could maybe check this from teh example you mentioned.

    2. Try checking headers, they usually define the actual maximun size somewhere, anyway, for testing you could try TBuf<255>, it is most likely big enough.

  3. #3
    Regular Contributor
    Join Date
    Oct 2007
    Location
    Malta
    Posts
    80

    Re: RNotifier AppUI class for Bluetooth

    1) The following is the example,
    Code:
    // 1. Create a notifier
    RNotifier not;
    User::LeaveIfError(not.Connect());
    
    // 2. Start the device selection plug-in
    TBTDeviceSelectionParams selectionFilter;
    TUUID targetServiceClass(0x2345);
    selectionFilter.SetUUID(targetServiceClass);
    TBTDeviceSelectionParamsPckg pckg(selectionFilter);
    TBTDeviceResponseParams result;
    TBTDeviceResponseParamsPckg resultPckg(result);
    TRequestStatus status;
    not.StartNotifierAndGetResponse(status, KDeviceSelectionNotifierUid, pckg, resultPckg);
    User::After(2000000);
    
    // 3. Extract device name if it was returned
    User::WaitForRequest(status);
    TPtrC name;
    if (status.Int() == KErrNone)
        {
        if (resultPckg.IsValidDeviceName())
            {
         name.Set(resultPckg().DeviceName());
            }
        }
        
    // 4. Clean up
    not.CancelNotifier(KDeviceSelectionNotifierUid);
    not.Close();
    So for clarification could you maybe tell me the actual use of package buffers?
    Are they only being used because the not.StartNotifierAndGetResponse(status, KDeviceSelectionNotifierUid, pckg, resultPckg) function takes only a packaged buffer. If yes my next question would be how do I open a package buffer to reassign the value to the TBTDeviceResponseParams result parameter.

    2) Ok so I set, TBuf<255> iAddress;

    Code:
    	if (status.Int() == KErrNone)
    		{
    			if (resultPckg().IsValidBDAddr())		
    			{
    				iBTState = EBTDiscoveredDevice;
    				//iDevice = resultPckg().DeviceName();
    				resultPckg().BDAddr().GetReadable(iAddress);
    			}
    		}
    and get the error BTDevAddr 0

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,737

    Re: RNotifier AppUI class for Bluetooth

    What is iAddress?

  5. #5
    Regular Contributor
    Join Date
    Oct 2007
    Location
    Malta
    Posts
    80

    Re: RNotifier AppUI class for Bluetooth

    iAddress is declared in BtEngine.h(of course included in the corresponding cpp file) as
    TBuf<255> iAddress;

    So it's a large stack based descriptor. Convention wise, this should be simply declared as address or iAddress?

    Code:
    class CBTEngine : public CBase
    {
    public:
    	static CBTEngine* NewL(MBTObserve& aMBTObserve);
    	~CBTEngine();
    	TBTState BTState()
    		{
    			return iBTState;
    		}
    	void DiscoverDevicesL();
    	void DiscoverServicesL();
    	virtual void HandleBTEngineState();
    	TDesC& GetDeviceNameL();
    	TDesC& GetDeviceAddressL();
    private:
    	//TBuf<48> iDevice;
    	TPtrC tempPtr;
    	HBufC* iDevice;
    	TBuf<255> iAddress;
    	TBTState iBTState;
    	CBTEngine(MBTObserve& aMBTObserve);
    	void ConstructL();
    	MBTObserve& iMBTObserve;
    };
    EDIT: iAddress will therefore be the descriptor containing the human readable format of the Bluetooth Address' device being selected.
    Last edited by davmt; 2008-03-20 at 15:10.

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,737

    Re: RNotifier AppUI class for Bluetooth

    Sorry, I have not noticed that you have specified it in "2)".
    A strange thing is your filter: are you sure about that service 0x2345 actually exists on your devices?

  7. #7
    Regular Contributor
    Join Date
    Oct 2007
    Location
    Malta
    Posts
    80

    Re: RNotifier AppUI class for Bluetooth

    The filter ain't the problem, I commented it to make the selection parameters default. But with the filter(I took it from the example code) or without that filter my devices are being found in the notifier.

Similar Threads

  1. Java Application running on WTK but not on S60 SDK
    By roman.benz in forum Mobile Java Tools & SDKs
    Replies: 6
    Last Post: 2009-06-09, 14:38
  2. Help needed with +CPMS, +CNMI for Class 0,1,2 SMs
    By joe--joe in forum General Messaging
    Replies: 3
    Last Post: 2009-03-09, 14:55
  3. how to call the UI class methods in another view.
    By chandrasekharreddy in forum Symbian User Interface
    Replies: 1
    Last Post: 2008-02-18, 11:56
  4. Need one HTTP client example
    By vinayakak in forum Symbian Networking & Messaging (Closed)
    Replies: 15
    Last Post: 2008-01-06, 06:44
  5. access to my appui class
    By noussaENSI in forum Symbian
    Replies: 2
    Last Post: 2007-04-12, 10:46

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×