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.

Code for Peripheral as Client and Central as Server

I am modifying the SimpleBLECentral and SimpleBLEPeripheral code to make the peripheral the client and the central the server.  This is opposite how the boards in the eval kit are shipped.  I have the peripheral trying to send data, but I get a Write Error: 1 (copied the code exactly from Central for the simpleBLECentralProcessGATTMsg function).

I also copied all simpleProfile calls into the central code.  I am never reaching the simpleProfileChangeCB function that I copied though.  I'm wondering if there is something I missed getting the profile table setup correctly now that roles have changed.  Has anyone else done this successfully?

I can provide the code for these if that helps.

 

  • I am wondering if the discovery event code also needs to move to the peripheral.  It is unclear to me exactly what this code does since the functions are not really commented at all.  I'm guessing that might be my problem as the client (peripheral) never states that the simple service was found.

  • Hi Thad,

    This depends of course on exactly what write error you get. Do you see the data being sent over the air?

    You have to make sure you have GATT_PROP_WRITE in the properties of characteristics you want to write to. Or perhaps you are writing to the declaration handle instead of the value handle. Hard to say.

    Best regards,
    Aslak 

  • So I got this figured out and copied over the timer that kicks off discovery (START_DISCOVERY_EVT), the SimpleBLEXXXStartDiscovery function that starts discovering the client services and will return GATT MSGs which are handled by the simpleBLEDiscState state machine that is in the simpleBLEGATTDiscoveryEvent function.  Convoluted and undocumented as to the flow of this, but it just takes a day or two of digging in to get it.

    I'm now trying to get the second profile character handle and write to it since the code that TI provide only seems to store the handle for the SIMPLEPROFILE_CHAR1_UUID.  I am getting a write error: 3.   Do you know what these write errors tend to mean?

  • The handle I am getting for SIMPLEPROFILE_CHAR2 is 15.  My start handle is 10 and the handle for CHAR1 is 12.

  • For anyone reading this in the future, the Simple profile must change in multiple places (GetParameter, SetParameter, etc) to be able to write Parameters 2 and 3.  You must go through that entire file and find all places where read/write permission can be set, not just where the profile is built.