Shop OBEX P1 Docs P2 Docs Learn Events
Programmer needed to write AT Command based library — Parallax Forums

Programmer needed to write AT Command based library

computer guycomputer guy Posts: 1,113
edited 2012-07-22 16:19 in Propeller 1
Hello,

I recently purchased a bluetooth 4.0 LE (low energy) module from BlueRadios, to use in a project of mine.
I am able to write a "driver" in SPIN for this module however it will take me some time and I most likely will never be 100% happy that I have written efficient code.
My preference would be for the driver to be written in PASM for efficiency.

Is there anybody that would be interested in writing a basic driver for this module (advertise, accept connection, pair, send data).
The module being BT 4.0 LE means that it can be used to communicate with an iPhone 4S, which could be fun for the parallax community.

I am happy to pay the programmer $100 upon completion.

I will supply you with the documentation, but the interface is 4 pin UART (RX, TX, RTS, CTS) from VSS to VDD (0 - 3.3v).
And the commands are all custom AT style commands. e.g.
ATRXT,0,1000,3000,1<cr>

Comments

  • pedwardpedward Posts: 1,642
    edited 2012-07-18 12:55
    First, PASM isn't needed and would be a waste of resources. Since this is a UART interface, you would leverage FullDuplexSerial if you wanted high speed comms. The interface library would be SPIN calling FDS -- FDS is written in PASM for efficiency.

    You're not asking much of the Propeller to talk to this module, most of the work is done by the module and FDS. FDS will use a dedicated COG to talk to the module, but a SPIN object to interface will be fairly lightweight.
  • computer guycomputer guy Posts: 1,113
    edited 2012-07-21 22:34
    Thanks pedward,

    I have decided to push forward and try to program the object myself in SPIN using FDS to do the communication.
    I have printed out the relevant parts of the documentation and started to put post-it notes on the pages to make finding particular functions easier.

    I will share the object once I have finished, as I believe the possibilities are endless with the BT4.0 LE module, propeller and an iPhone.
  • computer guycomputer guy Posts: 1,113
    edited 2012-07-22 06:32
    Ok, I am already confused.

    I need to send commands, then receive the reply. i.e. OK/ERROR
    But I also need to listen for events (these are messages from the module NOT in response to commands, but from outside events i.e. a device connecting to it).

    How should I go about implementing this?

    So far I have something like this:
    PUB GetAppearance : val
        ser.tx(string("ATSAPP?"))
        ser.tx(CR)
        val := GetPacket
    
    PRI GetPacket : packet | ptr, char
      repeat until ser.rx == CRLF
      ptr~
      repeat until (char := ser.rx) == CRLF
        packet[ptr++] := char
    

    1. I'm not sure this will work (I have a vague recollection that SPIN functions can only return bytes or that local variables can only be bytes) Is this true?
    2. It doesn't allow for events

    Thanks :)
  • Mike GMike G Posts: 2,702
    edited 2012-07-22 09:11
    1. I'm not sure this will work (I have a vague recollection that SPIN functions can only return bytes or that local variables can only be bytes) Is this true?
    No, longs and pointer can be returned. A pointer might point to a data buffer.
    2. It doesn't allow for events
    Sure it does assuming the event is data arriving on the serial port. The RxCheck method can be used to poll the serial buffer for data.
    PUB RxCheck : rxByte
    {{
       Check if a byte is waiting in the receive buffer and return the byte if one is there,
       does NOT block (never waits).
    
       Parameters: none
       return:     If no byte, then return(-1).  If byte, then return(byte).
    
       example usage: serial.RxCheck
    
       expected outcome of example usage call: Return a byte if one is available, but dont wait
                                               for a byte to come in.
    }}
    

    Sounds to me like you have two modes. Listen mode (server) and send receive mode (client).
  • computer guycomputer guy Posts: 1,113
    edited 2012-07-22 15:54
    Mike G wrote: »
    Sure it does assuming the event is data arriving on the serial port. The RxCheck method can be used to poll the serial buffer for data.

    Sounds to me like you have two modes. Listen mode (server) and send receive mode (client).

    Not quite. I need both modes to work at the same time.

    I might send data using the "client" mode. But need to know that the device I'm talking too has disconnected by getting the disconnect event in "server" mode.

    My question is, how do I listen for events without having the listening code pull my command responses from the buffer and my command code pull events from the buffer?
  • Mike GMike G Posts: 2,702
    edited 2012-07-22 16:03
    My question is, how do I listen for events without having the listening code pull my command responses from the buffer and my command code pull events from the buffer?
    Well, you could create a flag. If you are sending a command that requires a response set the flag to stop the listener while completing the transaction. Turn the listener back on when you're done.

    Does the device set a pin when an event occurs?
  • computer guycomputer guy Posts: 1,113
    edited 2012-07-22 16:19
    How could I not think of that. Thanks Mike.
    Mike G wrote: »
    Does the device set a pin when an event occurs?
    Unfortunately not.

    One last question. As the listener will no doubt be in an endless repeat while loop, should I use a separate cog? If I didn't wouldn't it lock up the main cog once I started the listener?
Sign In or Register to comment.