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.

SimpleBlePeripheral, read and write value via UART

Other Parts Discussed in Thread: CC2541

Hello.

I use the simple ble peripheral project with serial interface. I don't know how can i read/write value from uart.

I parse my rx buffer, and in my case :

    case APP_CMD_WRITE:
      
      pReq.handle = 0x25;
      pReq.offset = 0;
      if (GATT_ReadLongCharValue( 0xFFFE, &pReq, serialInterface_TaskID ) //i wanted use this for provoc a read cb... 


But, don't work. I guess i am blind and the answer is easy, but i don't know what function to call for Read / Write a specific characteristic.

Thank's and best regards,

Steeve

  • Hi Steeve,

    Are you trying to read the Char value "over the air" from a server (i.e., you are implementing a GATT Client) or are you trying to obtain the value from your (server) application in response to a external Client that wrote the value? Did you use the CC Debugger to see what you are receiving from UART?

    Best wishes
  • Hi Jeff,

    Read / write over the air it's ok.
    I want implement a function (parsing uart like 77 (serial id) 02(APP_CMD_READ) A0(like a UUID) 05(len to return)).
    And in the case A0, i think i have to call xxxxService_getParameter and specified the number of characteristic, and my len.

    In other words, i want to send from my server (external MCU) :
    a function who said "tell me the value of characteristic AA A1" and the cc2541 answer back from UART the value, example : "00 01".

    Thanks
  • Hi Steeve,

    Sure, thanks for clarifying. Yes, you would use the getParameter method to read the current value and not use any GATT_xxx APIs (although loopback handle would work). What is your issue? Are you able to parse the UART cmd correctly?

    Best wishes
  • Hello JXS.

    Thank you.

    getParameter call read_cb function ?

    Because in my read_cb function/write_cb function of each service, i send the value from UART.

    Example, when on my Android Phone, i write on characteristic A0, the value 00 05 48, my external mcu receive :

    A0 00 05 48

    I have understand this : read/write  call read_cb / write_cb. Both call get / set parameter.

    My question is : if i just call get paramater. How the answer is said by default ? UART ? Else, where i have to implement get paramater call back ?

    Thanks and best regards

  •  Seems working ! I put my code here for people who need


    case APP_CMD_READ: switch (rxSerialPkt.data[0]){ case 0xAA : //ID CHARACTERISTIC uint8 param = rxSerialPkt.data[1]; uint8 len = rxSerialPkt.data[2]; // Need to know how much to return uint8 data[20]; stat = yourService_GetParameter(param, (void *)data); if (stat == SUCCESS) HalUARTWrite(NPI_UART_PORT, (uint8*)data, len); else stat = INVALIDPARAMETER; break; } break;

    Thank' you JXS

  • Hi Steeve,

    Glad to hear it's working!

    Best wishes