1 Reply Latest reply on Nov 30, 2015 3:37 AM by JoMe_264151

    Reading an Attribute on PRoC4

    userc_40686

      Hi everyone,

         

      I'm pretty new to the whole Bluetooth topic and even to programming any ARM processor, so please excuse if the following questions sound a bit "simple" :-). I searched through the forums and wasn't able to solve the following problem:

         

      I simply want to read out an attribute, that I've created in the BLE component in PSoC Creator (it's called BTCommand and has length 12).

         

      So here's my code:

         

       

         

      CYBLE_GATT_HANDLE_VALUE_PAIR_T val_handle;
      CYBLE_GATT_DB_ATTR_HANDLE_T data_handle;
      CYBLE_GATT_ERR_CODE_T error;
                   
      data_handle = BTCommand_HANDLE;
      uint8 data_length = 12;
      uint8 val[data_length];
      val_handle.attrHandle = data_handle;
      val_handle.value.val = val;

         

      val_handle.value.len = data_length;
                  
      error = CyBle_GattsReadAttributeValue(&val_handle, &cyBle_connHandle, CYBLE_GATT_DB_LOCALLY_INITIATED);

         

       

         

      So, the first time i execute the code, it seems to work and in the variable called val, i can afterwards see the content of the attribute (that i've created). So I guess it basically works.

         

      The problem is that right after the execution, the processor get's into a unknown state (or something similar) and actually ends up in the "CySysSleep" routing (and never get's out again). I seems strange to me, since i don't send the module into sleep mode...

         

      The "error" value is "CYBLE_GATT_ERR_NONE" after first execution, so this seems to be correct.

         

      Maybe someone knows how exactly to read out a simple attribute and knows what i'm doing wrong. Would appreciate the help...

         

      Gregor