×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    15

    Connecting to Bluetooth SPP device

    Hello Guys

    I have a bluetooth module that has a serial port profile. I do know the 'MAC adress' of the device, would I be able to connect to it from python?

    1.) I did look at the BTConsole, it seems to use a Socket, and I see somewhere in the docs there is a RFCOM option as well, I am just confused on how to establish a connection. Any simpe script to establish a SPP connection and read incoming data?

    2.) For testing and debugging, I am conected to the device from the laptop using the BTConsole, I am not allowed to make any further connections to the SPP device, it says MAX connection error or something, cant the device connect to more than 1 bluetooth device at a time?

    3.) I do have a USB cable, is there a way to use Hyperterminal to enter the code or interact with the intepreter using the cable connection as opposed to the BTConsole method?

    Thanks for any help.

    Cheers
    Jay

  2. #2
    Super Contributor
    Join Date
    Dec 2004
    Posts
    643

    Re: Connecting to Bluetooth SPP device

    Originally posted by jameelh
    Hello Guys

    I have a bluetooth module that has a serial port profile. I do know the 'MAC adress' of the device, would I be able to connect to it from python?

    1.) I did look at the BTConsole, it seems to use a Socket, and I see somewhere in the docs there is a RFCOM option as well, I am just confused on how to establish a connection. Any simpe script to establish a SPP connection and read incoming data?

    2.) For testing and debugging, I am conected to the device from the laptop using the BTConsole, I am not allowed to make any further connections to the SPP device, it says MAX connection error or something, cant the device connect to more than 1 bluetooth device at a time?

    3.) I do have a USB cable, is there a way to use Hyperterminal to enter the code or interact with the intepreter using the cable connection as opposed to the BTConsole method?

    Thanks for any help.

    Cheers
    Jay
    See the Programming Guide for a simple example on how to connect to a device over Bluetooth. There's a simplebtconsole.py script included as an example.

    2. I actually don't know if connecting to several devices at the same time works, but what I do know is that with the current socket module you can't do BT discovery if a BT connection is open. Did the error occur on discovery or the actual connection attempt?

    3. No, the USB cable is not supported. If you have the money (or a flat-rate data plan) you could use the console over GPRS.

  3. #3
    Registered User
    Join Date
    Jul 2003
    Posts
    15

    Clarification on the SimpleBTConsole.py

    Hello

    Thanks for the response.

    Looking at the SimpleBTConsole.py, in the mail body of the code is:-


    print "Connecting to "+str(target)
    sock.connect(target)
    socketio=socket_stdio(sock)
    realio=(sys.stdout,sys.stdin,sys.stderr)
    (sys.stdout,sys.stdin,sys.stderr)=(socketio,socketio,socketio)

    sock.connect(target) -> Actually establishes the connection right?

    What does the next 2 lines do? It is assigning all of incoming data from the socket to standard I/O streams? How can I modify this to apend the incoming data to the screen?

    >3. No, the USB cable is not supported. If you have the money
    >(or a flat-rate data plan) you could use the console over GPRS.

    How is this possible? Write a console script to connect to a PC with static IP?

    Thanks again

    Jay

  4. #4
    Super Contributor
    Join Date
    Dec 2004
    Posts
    643

    Re: Clarification on the SimpleBTConsole.py

    Originally posted by jameelh
    Hello

    Thanks for the response.

    Looking at the SimpleBTConsole.py, in the mail body of the code is:-


    print "Connecting to "+str(target)
    sock.connect(target)
    socketio=socket_stdio(sock)
    realio=(sys.stdout,sys.stdin,sys.stderr)
    (sys.stdout,sys.stdin,sys.stderr)=(socketio,socketio,socketio)

    sock.connect(target) -> Actually establishes the connection right?

    What does the next 2 lines do? It is assigning all of incoming data from the socket to standard I/O streams?
    It connects stdin, stdout and stderr to the socket so those streams will use the socket for I/O.
    How can I modify this to apend the incoming data to the screen?
    Um... I don't understand what you mean?


    >3. No, the USB cable is not supported. If you have the money
    >(or a flat-rate data plan) you could use the console over GPRS.

    How is this possible? Write a console script to connect to a PC with static IP?
    Yes. Read the Programming Guide. There's code there that does exactly that.

  5. #5
    Registered User
    Join Date
    Jul 2003
    Posts
    15

    Re: Re: Clarification on the SimpleBTConsole.py

    [QUOTE]Originally posted by jplauril


    Um... I don't understand what you mean?


    [QUOTE]

    Well I mean to read the data from the BT Socket and append the string (?) into the current screen of the script. Is it like?:-

    data_in = socketio
    this.append(data_in)


    Thanks again.
    Jay

    PS: I am total newb to Python and I find the Documentaion supplied somewhat limited, so I should follow the actual full Python's Socket doecument for its method and properties?

  6. #6
    Super Contributor
    Join Date
    Dec 2004
    Posts
    643
    Yes, read the normal Python socket documentation. Any deviations from that which are not mentioned in PyS60 documentation should be reported as bugs.

Posting Permissions

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