Advertisement
Guest User

b

a guest
Nov 16th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.19 KB | None | 0 0
  1. bool SimpleCentral_doGattWrite(uint8_t index)
  2. {
  3.     uint8_t charVals[4] = { 0x00, 0x55, 0xAA, 0xFF };
  4.                        //    0,   85,   170,  255
  5.     //int writes = 0;
  6.  
  7.     while(index < 4){
  8.  
  9.         status_t status;
  10.  
  11.         attWriteReq_t req;
  12.         req.pValue = GATT_bm_alloc(scConnHandle, ATT_WRITE_REQ, 1, NULL);
  13.  
  14.         if ( req.pValue != NULL )
  15.         {
  16.           uint8_t connIndex = SimpleCentral_getConnIndex(scConnHandle);
  17.  
  18.           // connIndex cannot be equal to or greater than MAX_NUM_BLE_CONNS
  19.           SIMPLECENTRAL_ASSERT(connIndex < MAX_NUM_BLE_CONNS);
  20.  
  21.           req.handle = connList[connIndex].charHandle;
  22.           req.len = 1;
  23.           charVal = charVals[index];
  24.           req.pValue[0] = charVal;
  25.           req.sig = 0;
  26.           req.cmd = 0;
  27.  
  28.           status = GATT_WriteCharValue(scConnHandle, &req, selfEntity);
  29.           if ( status != SUCCESS )
  30.           {
  31.             GATT_bm_free((gattMsg_t *)&req, ATT_WRITE_REQ);
  32.           }
  33.         }
  34.  
  35.         Display_printf(dispHandle, SC_ROW_CUR_CONN, 0, "Byte %d ",  index);
  36.  
  37.        // writes++;
  38.         index++;
  39.         Task_sleep(500 * (1000 / Clock_tickPeriod));
  40.     }
  41.  
  42.   return (true);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement