src/VirtualShield.cpp
/// <summary>
/// Event callback for when a full string is received.
/// </summary>
/// <param name="buffer">The buffer.</param>
/// <param name="length">The length.</param>
/// <param name="shieldEvent">The shield event.</param>

Event callback for when a full string is received.
Event callback for when a full string is received .
int VirtualShield::onStringReceived(char* buffer, size_t length, ShieldEvent* shieldEvent) {
	if (length >= maxJsonReadBuffer) { return SERIAL_ERROR; }
	char *json = static_cast<char*>(alloca(length + 1));
	if (!json) { return SERIAL_ERROR; }
    strncpy(json, buffer, length);
    json[length] = '\0';
    onJsonStringReceived(json, shieldEvent);
	return SERIAL_SUCCESS;
}
int VirtualShield :: onStringReceived ( char * buffer , size_t length , ShieldEvent * shieldEvent ) { if ( length >= maxJsonReadBuffer ) { return SERIAL_ERROR ; } char * json = static_cast < char * > ( alloca ( length + 1 ) ) ; if ( ! json ) { return SERIAL_ERROR ; } strncpy ( json , buffer , length ) ; json [ length ] = ' \0 ' ; onJsonStringReceived ( json , shieldEvent ) ; return SERIAL_SUCCESS ; }
<summary>
Event callback for when a full string is received.
<summary > Event callback for when a full string is received .