@@ -420,7 +420,7 @@ int HCIClass::leConnUpdate(uint16_t handle, uint16_t minInterval, uint16_t maxIn
420
420
return sendCommand (OGF_LE_CTL << 10 | OCF_LE_CONN_UPDATE, sizeof (leConnUpdateData), &leConnUpdateData);
421
421
}
422
422
423
- int HCIClass::sendAclPkt (uint16_t handle, uint8_t cid, uint8_t plen, void * data)
423
+ int HCIClass::sendAclPkt (uint16_t handle, uint8_t cid, uint8_t plen, const void * data)
424
424
{
425
425
while (_pendingPkt >= _maxPkt) {
426
426
poll ();
@@ -434,7 +434,7 @@ int HCIClass::sendAclPkt(uint16_t handle, uint8_t cid, uint8_t plen, void* data)
434
434
uint16_t cid;
435
435
} aclHdr = { HCI_ACLDATA_PKT, handle, uint8_t (plen + 4 ), plen, cid };
436
436
437
- uint8_t txBuffer[ sizeof (aclHdr) + plen] ;
437
+ uint8_t * txBuffer = ( uint8_t *) malloc ( sizeof (aclHdr) + plen) ;
438
438
memcpy (txBuffer, &aclHdr, sizeof (aclHdr));
439
439
memcpy (&txBuffer[sizeof (aclHdr)], data, plen);
440
440
@@ -444,7 +444,8 @@ int HCIClass::sendAclPkt(uint16_t handle, uint8_t cid, uint8_t plen, void* data)
444
444
445
445
_pendingPkt++;
446
446
HCITransport.write (txBuffer, sizeof (aclHdr) + plen);
447
-
447
+ free (txBuffer);
448
+
448
449
return 0 ;
449
450
}
450
451
@@ -468,15 +469,15 @@ void HCIClass::noDebug()
468
469
_debug = NULL ;
469
470
}
470
471
471
- int HCIClass::sendCommand (uint16_t opcode, uint8_t plen, void * parameters)
472
+ int HCIClass::sendCommand (uint16_t opcode, uint8_t plen, const void * parameters)
472
473
{
473
474
struct __attribute__ ((packed)) {
474
475
uint8_t pktType;
475
476
uint16_t opcode;
476
477
uint8_t plen;
477
478
} pktHdr = {HCI_COMMAND_PKT, opcode, plen};
478
479
479
- uint8_t txBuffer[ sizeof (pktHdr) + plen] ;
480
+ uint8_t * txBuffer = ( uint8_t *) malloc ( sizeof (pktHdr) + plen) ;
480
481
memcpy (txBuffer, &pktHdr, sizeof (pktHdr));
481
482
memcpy (&txBuffer[sizeof (pktHdr)], parameters, plen);
482
483
@@ -493,6 +494,8 @@ int HCIClass::sendCommand(uint16_t opcode, uint8_t plen, void* parameters)
493
494
poll ();
494
495
}
495
496
497
+ free (txBuffer);
498
+
496
499
return _cmdCompleteStatus;
497
500
}
498
501
0 commit comments