×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    25

    Exclamation Print device name Bluetooth

    Hi guys,
    I need help.

    In header file MyClass.h:

    ...
    static void ReadString(TDes& txt);

    private:
    TPtrC deviceName;
    ...


    In class file MyClass.cpp:

    ..
    rHost.GetByAddress(iAddr, iEntry, iStatus);
    User::WaitForRequest(iStatus);

    deviceName.Set(iEntry().iName);
    ...

    void CMyClass::ReadString(TDes& aText)
    {
    aText.Copy(deviceName);
    }


    When I build my project, I get this error:

    Invalid use of member 'CMyClass::deviceName' in static member function.

    Why?

  2. #2
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,336

    Re: Print device name Bluetooth

    Quote Originally Posted by superiore81 View Post
    Hi guys,
    I need help.

    ...
    static void ReadString(TDes& txt);

    private:
    TPtrC deviceName;
    ...
    Is there any special requirement on making it static? Note that you cannot access non-static member variables inside static member functions. You can remove static-ness from "ReadString" or declare "deviceName" as static.

    By removing static-ness, I mean following:
    Code:
    void ReadString(TDes& txt);
    Nokia Developer Wiki Moderation team

  3. #3
    Registered User
    Join Date
    Oct 2008
    Posts
    25

    Re: Print device name Bluetooth

    Thanks for your attention

    I removed static, and the variable is now public.

    When you launch the device (Nokia n95) gives me error KERN-EXEC3

    I used this object to call ReadString function of MyClass from external class:

    TBuf <100> hjelpper;
    CMyClass bc;
    bc.ReadStringa(hjelpper);
    Last edited by superiore81; 2009-03-13 at 14:40.

  4. #4
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,336

    Re: Print device name Bluetooth

    Quote Originally Posted by superiore81 View Post

    When you launch the device (Nokia n95) gives me error KERN-EXEC3

    I used this object to call ReadString function of MyClass from external class:

    TBuf <100> hjelpper;
    CMyClass bc;
    bc.ReadStringa(hjelpper);
    KERN-EXEC 3 panic arises when you try to dereference a NULL pointer. Read more about this panic in the SDK help.

    You need to instantiate CMyClass something like as follows:
    Code:
    TBuf <100> hjelpper;
    CMyClass bc = new (ELeave) CMyClass();
    bc.ReadStringa(hjelpper);
    ...
    ...
    delete bc; // at some point when you don't need it
    Nokia Developer Wiki Moderation team

Similar Threads

  1. Replies: 1
    Last Post: 2008-03-20, 17:31
  2. Bluetooth serviceDiscover problem Device Not Reachable
    By kashifqazi in forum Bluetooth Technology
    Replies: 1
    Last Post: 2006-10-13, 12:31
  3. Bluetooth device discovery
    By yiyzhou in forum Bluetooth Technology
    Replies: 5
    Last Post: 2006-10-06, 06:23
  4. CoD of a Discovered Bluetooth Device in 6680
    By mniemine in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2006-04-27, 14:36
  5. Connecting to bluetooth device
    By roelb in forum Bluetooth Technology
    Replies: 11
    Last Post: 2004-01-09, 12:18

Posting Permissions

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