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.

CC2640 write to phone

Other Parts Discussed in Thread: BLE-STACK, CC2640R2F, CC2640, SIMPLELINK-CC2640R2-SDK
I am trying to do a GATT write character value from the device to an iPhone.
A few things behind our project:
The 2640 acts as a peripheral based off of the simple_peripheral_app example.
I know the handle of the value I am writing to. I used Nordic's MasterControlPannel to write to that handle, and it worked.
Here is the code I am using to write a value from the device to the phone:
            attWriteReq_t req;
            GAPRole_GetParameter(GAPROLE_CONNHANDLE, &bleconnHandle);
            req.pValue = GATT_bm_alloc(bleconnHandle, ATT_WRITE_REQ, 1, NULL);
            if ( req.pValue != NULL )
            {
              req.handle = 0x0068;
              req.len = 1;
              req.pValue[0] = 0x02;
              req.sig = 0;
              req.cmd = 1;
              status = GATT_WriteCharValue(bleconnHandle, &req, selfEntity);
              if ( status != SUCCESS )
              {
                GATT_bm_free((gattMsg_t *)&req, ATT_WRITE_REQ);
              }
            }
I am getting the status and not SUCCESS. Is there anything I might be doing wrong, or something I haven’t initialized in order to do the GATT write?
  • Hello J,

    GATT_WriteCharValue is an API/procedure for GATT Clients; Simple_Peripheral is a GATT server thus this procedure is not allowed. If you want to send data from the GATT Server to the Client, you need to use Indications or Notifications. See Simple Profile Characteristic 4 - or - refer to SimpleLink Academy BLE training modules that demonstrate the Button Service on Project Zero

    Best wishes

  • Hi,

    Coming back to this, if you need to invoke GATT Client operations, the GATT Client needs to be initialized in your application by calling GATT_InitClient() and removing GATT_NO_CLIENT from the stack project's predefined symbols. The default simple_peripheral does not instantiate a GATT Client instance by default but this is included in the time_app sample application in BLE-Stack v2.2.1.

    Note that you can also support simultaneous peripheral and central connections with the multi-role sample application. The CC2640/CC2640R2F does not implement "role switch" as it can support the more advanced multirole configuration. For CC2640, multirole is provided in GitHub but it is included in the newer SIMPLELINK-CC2640R2-SDK.

    Please let us know if you have additional questions.

    Best wishes