This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2640R2F: Adding ADC service to SPP

Part Number: CC2640R2F
Other Parts Discussed in Thread: CC2650,

I have created a bridge using the Serial Port Profile with a cc2640R2 as the Client and a cc2650 as the server .  I want to send ADC data from the SPP Client to the SPP-server to display via the UART. Following the SimpleLink Academy, I have successfully added an ADC service to a "Simple Peripheral" but have no luck doing the same on the Serial Port Profile. Are there any examples of integrating / sending ADC data using SPP (or SSS) Client/Server?
Thanks

  • Part Number: CC2640R2F

    Tool/software: Code Composer Studio

    I would like to send ADC data collected at 200Hz over SPP. I do not need the Uart RxBuffer from the data sending side and though I can insert ADC data to send over BLE. The receiving will use the UART to display the data.  Has anyone tried using the UART transport layer of the SDI-TL for other data. I can send a single byte with each interrupt, but trying to integrate the on-board ADC driver is a challenge.  I do not need the SPI, since it is an internal peripheral. Any guidance would be greatly appreciated.

  • HI Rcdew,

    Could you elaborate on your higher level design idea? What is the purpose of the "ADC Service" in your application, it sounds like you are planing to use the "SPP Service" to move the data between the devices?

    The SPP example is designed around it being a "UART bridge" and it is not super trivial to break up one side and exchange this for another data source. If the goal is to simply move ADC data from the CC2650 down to the CC2640R2, I would suggest you do add a "ADC Service" on top of a simple peripheral project (not the SPP one) for the CC2650 and make the CC2640R2 a central.

    There is some different takes on this, but I would recommend you look closer at the new "Simple Serial Socket" example that is available for the CC2640R2:

    github.com/.../simplelink_cc2640r2_sdk-2.20

    This example is more of a generic data source/sink implementation and it is easier to change the input data from being for example UART to being ADC data. Unfortunately, there is no port of this for the CC2650 so you would have to do the server side port yourself.
  • Hi M-W, Thank you for your reply. My goal is to collect ADC data using the cc2640R2 and send to a PC serial port via Bluetooth.  I cannot jump into the resident PC Bluetooth so another CC26xx as the BT-PC interface seemed like a good idea.  I chose the CC2650 as the interface since I already had one.  I agree it is not trivial using the SPP service to send data other than UART.  Do you see any issue trying your first suggestion the other way; add an ADC service to simple peripheral project for the cc2640r2(ADC side) and run simple central on the cc2650(PC side) onto a UART?

    Thanks

  • Hi rcdew,

    " ... add an ADC service to simple peripheral project for the cc2640r2(ADC side) and run simple central on the cc2650(PC side) onto a UART?"

    I think this might be the easier approach, if you can setup the data connection using a custom service tailored for the use case and get the data over to the central side, sending it over UART should be rather trivial. As for the UART, you do not need to use the SDI abstraction, simply using the UART driver is more then enough in the scenario you describe.

    When implementing the UART, I would suggest you take some inspiration from the "Simple Serial Socket" examples. To be more precise, I suggest you go with a callback based implementation rather then a blocking one.
  • Hi M-K,
    I have added the ADC service to the Simple Peripheral running on the cc2640r2 (sdk_2_30_00_38). I can see the new service on the BLE app of my android as well as the ADC data update on button push on the 2640r2. However, the Simple Central does seem to see it at all where I try to capture anADC message in the GATT server under "SimpleBLECentral_processGATTMsg(). should I see something here, even if there is no defined UUID or Characteristic on Simple_Central.c for the ADC service? the two units do connect and I can communicate as dictated by simple_central example. I went through the custom profile example, but it is not clear how a BLE receives data and what to look for. I am trying to understand how to tell the simple_central what to look for. The simple central I am using is from ble_sdk_2_02_01_18.
  • You need to do a service discovery first before you can read/write/receive notification on simple_central.

    Since you know what UUID you are using, the you can just change the code in the following function

    static void SimpleCentral_processGATTDiscEvent(gattMsgEvent_t *pMsg)
    {
      if (discState == BLE_DISC_STATE_MTU)
      {
        // MTU size response received, discover simple service
        if (pMsg->method == ATT_EXCHANGE_MTU_RSP)
        {
          uint8_t uuid[ATT_BT_UUID_SIZE] = { LO_UINT16(SIMPLEPROFILE_SERV_UUID),
                                             HI_UINT16(SIMPLEPROFILE_SERV_UUID) };
    
          // Just in case we're using the default MTU size (23 octets)
          Display_print1(dispHandle, 4, 0, "MTU Size: %d", ATT_MTU_SIZE);
    
          discState = BLE_DISC_STATE_SVC;
    
          // Discovery simple service
          VOID GATT_DiscPrimaryServiceByUUID(connHandle, uuid, ATT_BT_UUID_SIZE,
                                             selfEntity);
        }
      }

    Replace the SIMPLEPROFILE_SERV_UUID with your custom UUID, then you should be able to access the characteristic

  • I have tried the above changes but nothing happens.  With no changes to simple central, commsbetween simple periph on cc2640r2 and _central on cc2650 look good. I can see adc service on my phone as follows:

    . . .

    CUSTOM SERVICE

    F000AA00-451-4000-B000-00000000

    PRIMARY SERVICE

    --------------------------------------------------

    CUSTOM CHARACTERISTIC 

    UUID: F000AA01-0451-4000-00000000

    Properties: READ

    Value:

    Hex:0x50b00000 (ADC Value)

    I have added to Simple_Central.c: #define MYDATA_SERV_UUID    0xAA00 & #define MYDATA_DATA_UUID    0xAA01.

    If there is another way to send adc data from a ble server to a ble client and display onto PC your guidance is greatly appreciated.  This current approach is not very trivial. I have also hooked two cc2640r2 launchpads successfully with simple serial Socket server and simple serial client but now the task of adding adc to the server is worrisome. any thoughts would be great.

     

  • Hi rcdew,

    There is multiple steps related to "using a service" from the point of a BLE central. You can trace these steps by looking at the simple_central example to see how it interfaces with the "simple service" that is the examples default.

    In general, what you need to do is to:
    1) Perform the service discovery as suggested by Christin
    2) Handle the possible responds, store the handles to the characteristics you are interested in

    When you have had a successful discovery and got the handles you are looking for, you can write/read that characteristic.

    If you want, you could try to port the "Simple service discovery" feature available in the "Simple Serial Socket Client" example. It "helps" you to perform discovery of a predefined service with a set of characteristics. You can look into how this is used in the "Simple Serial Socket Client" example (look at SimpleSerialSocketClient_processGATTDiscEvent).

    An alternative, if you really don't want to dive deeper into how to develop custom BLE applications, is if you can run your example using two CC2640R2 launchapds instead of a CC2650. Then you could simply leverage the "Simple Serial Socket" example and treat the link a generic data stream (not including any services of your own).
  • With your alternate suggestion, I replaced the CC2650 with another CC2640R2 and employed the "Simple Serial Socket" example. As you suggested, the code is straight forward and can be used as a generic data stream. I am now successfully using the ADC on the server side and capturing on the Client side via Uart. Many Thanks!