New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

Start a Discussion

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

Bluetooth programming question

Post Reply New Thread Subscribe

Thread Tools

Member Since: Dec 15, 2011
Posts: 1
aelinden is on a distinguished road

aelinden is offline
I don't know if this really is a Mac specific question but since that's the system I'm programming in I'll ask anyway :-)

I'm writing a program that connects to a mobile phone (For now just Sony Ericsson dumbphones) through Bluetooth (Connects through a RFCOMM channel) and then sends AT-commands to control this phone. The purpose of this program is that people with disabilities that might have trouble working a mobile can use this program to perform calls, receive calls and modify a contact list.

The user interface is written in wxWidgets since it's supposed to be as cross platform as possible, and the phone manager is written in Objective-C++.

My problem now is that when a user calls a number and the number is busy, I'm not getting a BUSY reply back from the phone as the Sony Ericsson developer guide says should happen. Other messages from the phone gets received, like RING when an incoming call happens, or +CLIP when returning the number of the caller.

Here is the function responsible for reading incoming data:

-(void) rfcommChannelData:(IOBluetoothRFCOMMChannel *)rfcommChannel data:(void *)dataPtr length:(size_t)length {
     * Fetch data
    char buf[256];
    strncpy(buf, (char*)dataPtr, length);
    buf[length] = '\0';
    std::string cppbuf(buf);
    cppbuf = cppbuf.substr(2, length-2);
     * Incoming call
    if(cppbuf.substr(0,4).compare("RING") == 0) {
        NSLog(@"Incoming call!");
        // Fetch incoming number
        char ATCommand[40];
        strcpy(ATCommand, "AT+CLIP=1\r\n");
        [self sendrfcommData:ATCommand];
         * Number request reply
    } else if(cppbuf.substr(0,7).compare("+CLIP: ") == 0) {
         * Incoming reply has syntax "+CLIP: "<number>",...
         * To find the number, we first look up index for space
         * and increment that value by 2. We then look up index for the
         * first comma, and decrease that value by 1.
         * The number is now the substring starting at startindex
         * with length (endIndex - startIndex).
        int startIndex = cppbuf.find(" ");
        int endIndex = cppbuf.find(",");
        if(!call_window_shown) {
            call_window_shown = TRUE;
            incoming_call_func(incoming_call_object, cppbuf.substr(startIndex, endIndex-startIndex));
         * User hung up
    } else if(cppbuf.substr(0,5).compare("+CHUP") == 0) {
        NSLog(@"Hanging up");
        call_window_shown = FALSE;
         * Busy reply
    } else if(cppbuf.substr(0,4).compare("BUSY") == 0) { 
        call_window_shown = FALSE;
         * Aborted call
    } else if(cppbuf.substr(0,10).compare("NO CARRIER") == 0) {
        NSLog(@"No carrier!");
        call_window_shown = FALSE;
    } else
        std::cout << "Unhandled incoming data: " << cppbuf << std::endl;

As I mentioned, the RING (From phone), +CLIP (From phone), and +CHUP (From user interface) messages all gets read correctly, but when the called number is busy no BUSY reply is ever sent. I've tried printing the incoming data before any of the if-statements but BUSY is never received.

If anyone can see something wrong with this code or have any ideas, please let me know. I've been scratching my head for days trying to figure out why this issue exists.
QUOTE Thanks

Post Reply New Thread Subscribe

« Make Terminal command | Creating a script (like a windows batch file) »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Starter
Last Post
A question about the Bluetooth Wireless technology Truthfinder Apple Notebooks 1 10-31-2011 12:58 PM
MacBook Pro loses total bluetooth connectivity Doug b Internet, Networking, and Wireless 0 06-12-2009 02:46 PM
bluetooth board and mouse question r1dgline Other Hardware and Peripherals 2 02-27-2008 12:01 AM
Realbasic Programming Question shelflife19 OS X - Development and Darwin 12 11-28-2007 03:26 AM
bluetooth Mic question Conehead778 Switcher Hangout 3 06-14-2006 10:59 AM

All times are GMT -4. The time now is 08:41 AM.

Powered by vBulletin
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.

Welcome to

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!

(4 digit year)

Already a member?