1 Reply Latest reply on Aug 31, 2015 5:28 PM by MichaelF_56

    PUART functions in bleprofile.h documentation

      Hello everybody,


      I'm still working on a BLE to PUART communication and stumbled accross some interesting functions inside the bleprofile.h file.

      But the documentation is sketchy at best, so I'm hoping the community can provide some insight.


      Are there any functional differences between these two:

      void bleprofile_PUARTSetRxWaterlevel(UINT8 puart_rx_waterlevel);


      There seem to be several callback functions for receiving bytes over PUART. Which one should be used?

      I found those three:

      extern void (*puart_rxCb)(void *);
      void bleprofile_PUART_RxIntCb(void *ptr, UINT8 portPin);
      void bleprofile_regHandleUARTCb(BLEPROFILE_DOUBLE_PARAM_CB cb);




      At the moment, I'm using puart_rxCb to point to my handler function. This does work, my handler has a signature of void (void *unused).

      But I'm curious what use bleprofile_PUART_RxIntCb has and of course, what data is put into BLEPROFILE_DOUBLE_PARAM_CB's function parameters - and what UINT8 it should return.


      For transferring received PUART data into my data structures, I'm relying on this loop:

      while (puart_rxFifoNotEmpty() && puart_read(&readByte) && (rxCount < BT_UART_BUFFERSIZE))
           rxBuffer[rxWritePointer++] = readByte;
           if (rxWritePointer >= BT_UART_BUFFERSIZE)
                rxWritePointer = 0;


      This works perfectly fine, but I found these two functions:

      void bleprofile_ReadUART(char *data); //data needs to be at least READ_UART_LEN long (15 bytes)
      int bleprofile_PUARTRx(char *data, UINT8 len);


      What is the returned int of bleprofile_PUARTRx? If it would be the transferred bytes, I could use this instead. What happens, if len is bigger than the number of received bytes? Will it just abort or put 0x00 into the data array? Same goes for bleprofile_ReadUART.


      Writing is accomplished with this loop:

      for (i = 0; i < length; i++)


      Could I use this function instead:

      int bleprofile_PUARTTx(char *data, UINT8 len);

      What's the return value?


      I updated to SDK 2.2.1, but this didn't change much. The documentation is still very much lacking.


      Thanks for your replies!


      Best regards

      Hannes Baumgart

        • 1. Re: PUART functions in bleprofile.h documentation



          Regarding which callback function to use as a handler for received bytes, the example in the WICED™ Smart Hardware Interfaces document uses puart_bleRxCb to setup the app's Rx callback function. The example code provided on pages 16-18 of this document also demonstrates how to setup the watermarks and corresponding interrupt structure on the PUART.


          In addition, if you go here: WICED Smart Forums


          Then click on the "Peripheral UART" category shown there to the left of the page, you will find alot of excellent threads on this subject as alot of users struggle with the PUART based on the limited documentation we provide.


          The thread UART Routines is probably one of the most comprehensive ones on watermarks, but of course it's looking at the PUART more from the Tx perspective.


          Let us know if this helps.