@@ -420,7 +420,7 @@ int HCIClass::leConnUpdate(uint16_t handle, uint16_t minInterval, uint16_t maxIn
420420 return sendCommand (OGF_LE_CTL << 10 | OCF_LE_CONN_UPDATE, sizeof (leConnUpdateData), &leConnUpdateData);
421421}
422422
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)
424424{
425425 while (_pendingPkt >= _maxPkt) {
426426 poll ();
@@ -434,7 +434,7 @@ int HCIClass::sendAclPkt(uint16_t handle, uint8_t cid, uint8_t plen, void* data)
434434 uint16_t cid;
435435 } aclHdr = { HCI_ACLDATA_PKT, handle, uint8_t (plen + 4 ), plen, cid };
436436
437- uint8_t txBuffer[ sizeof (aclHdr) + plen] ;
437+ uint8_t * txBuffer = ( uint8_t *) malloc ( sizeof (aclHdr) + plen) ;
438438 memcpy (txBuffer, &aclHdr, sizeof (aclHdr));
439439 memcpy (&txBuffer[sizeof (aclHdr)], data, plen);
440440
@@ -444,7 +444,8 @@ int HCIClass::sendAclPkt(uint16_t handle, uint8_t cid, uint8_t plen, void* data)
444444
445445 _pendingPkt++;
446446 HCITransport.write (txBuffer, sizeof (aclHdr) + plen);
447-
447+ free (txBuffer);
448+
448449 return 0 ;
449450}
450451
@@ -468,15 +469,15 @@ void HCIClass::noDebug()
468469 _debug = NULL ;
469470}
470471
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)
472473{
473474 struct __attribute__ ((packed)) {
474475 uint8_t pktType;
475476 uint16_t opcode;
476477 uint8_t plen;
477478 } pktHdr = {HCI_COMMAND_PKT, opcode, plen};
478479
479- uint8_t txBuffer[ sizeof (pktHdr) + plen] ;
480+ uint8_t * txBuffer = ( uint8_t *) malloc ( sizeof (pktHdr) + plen) ;
480481 memcpy (txBuffer, &pktHdr, sizeof (pktHdr));
481482 memcpy (&txBuffer[sizeof (pktHdr)], parameters, plen);
482483
@@ -493,6 +494,8 @@ int HCIClass::sendCommand(uint16_t opcode, uint8_t plen, void* parameters)
493494 poll ();
494495 }
495496
497+ free (txBuffer);
498+
496499 return _cmdCompleteStatus;
497500}
498501
0 commit comments