static void notifyCallback(
BLERemoteCharacteristic* pBLERemoteCharacteristic,
uint8_t* pData,
size_t length,
bool isNotify)
{
Serial.print("data length: ");
Serial.println(length);
Serial.print("data: ");
Serial.println(*pData,HEX);
}
pData is received in the uint8_t* type. but I want to print it out in hex form. So I wrote Serial.println(*pData,HEX); How should I fix this?
You could access the array elements of pData. The amount of values is given in length.
static void notifyCallback(
BLERemoteCharacteristic* pBLERemoteCharacteristic,
uint8_t* pData,
size_t length,
bool isNotify )
{
Serial.print( "data length: " );
Serial.println( length );
for ( int i = 0; i < length; i++ )
{
Serial.print( "data: " );
Serial.println( pData[i], HEX );
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.