* free() ... forgot there is no GC
This commit is contained in:
parent
789d0ae29d
commit
cfae7d6ba8
@ -609,20 +609,26 @@ ResponseTypes Sodaq_nbIOT::_socketReceiveParser(ResponseTypes &response, const c
|
|||||||
// <socket>,<ip_addr>,<port>,<length>,<data>,<remaining_length>
|
// <socket>,<ip_addr>,<port>,<length>,<data>,<remaining_length>
|
||||||
SerialUSB.println(__FILE__": _socketReceiveParser() buffer:");
|
SerialUSB.println(__FILE__": _socketReceiveParser() buffer:");
|
||||||
SerialUSB.println(buffer);
|
SerialUSB.println(buffer);
|
||||||
// create a result buffer for the HEX string input
|
/**
|
||||||
|
* create a result buffer for the HEX string input
|
||||||
|
* 250 is SODAQ_AT_DEVICE_DEFAULT_INPUT_BUFFER_SIZE defined in Sodaq_AT_Device.h
|
||||||
|
* should probably refactor some more and move it to Sodaq_AT_Device.h
|
||||||
|
* we probably only need half of this (+1)
|
||||||
|
*/
|
||||||
auto * resultBuffer = static_cast<char*>(malloc(250));
|
auto * resultBuffer = static_cast<char*>(malloc(250));
|
||||||
memset(resultBuffer,0,250);
|
memset(resultBuffer, 0, 250);
|
||||||
if (sscanf(buffer, "%d,%[^,],%d,%d,%[^,],%d", &tmp_sock, tmp_ip, &tmp_port, &tpm_length, resultBuffer, &tpm_length_rem) == 6) {
|
if (sscanf(buffer, "%d,%[^,],%d,%d,%[^,],%d", &tmp_sock, tmp_ip, &tmp_port, &tpm_length, resultBuffer, &tpm_length_rem) == 6) {
|
||||||
SerialUSB.println(__FILE__": _socketReceiveParser() OK");
|
SerialUSB.println(__FILE__": _socketReceiveParser() OK");
|
||||||
int i;
|
int i;
|
||||||
for(i=0; i < tpm_length;i++) {
|
for(i=0; i < tpm_length;i++) {
|
||||||
parsedBuffer[i] = HEX_PAIR_TO_BYTE(resultBuffer[i*2], resultBuffer[i*2+1]);
|
parsedBuffer[i] = HEX_PAIR_TO_BYTE(resultBuffer[i*2], resultBuffer[i*2+1]);
|
||||||
}
|
}
|
||||||
// parsedBuffer[i*2] = 0;
|
free(resultBuffer);
|
||||||
return ResponseEmpty;
|
return ResponseEmpty;
|
||||||
}
|
}
|
||||||
|
|
||||||
SerialUSB.println(__FILE__": _socketReceiveParser() ERR");
|
SerialUSB.println(__FILE__": _socketReceiveParser() ERR");
|
||||||
|
free(resultBuffer);
|
||||||
return ResponseError;
|
return ResponseError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user