@Override
protected boolean internalReceiveChanneledCommand(String itemName,
Command command, Channel sChannel, String commandAsString) {
ProtocolBindingProvider provider = findFirstMatchingBindingProvider(itemName);
if(command != null ){
String transformedMessage = transformResponse(provider.getProtocolCommand(itemName, command),commandAsString);
String tcpCommandName = preAmble + transformedMessage + postAmble ;
ByteBuffer outputBuffer = null;
try {
outputBuffer = ByteBuffer.allocate(tcpCommandName.getBytes(charset).length);
outputBuffer.put(tcpCommandName.getBytes(charset));
} catch (UnsupportedEncodingException e) {
logger.warn("Exception while attempting an unsupported encoding scheme");
}
// send the buffer in an asynchronous way
ByteBuffer result = null;
try {
result = writeBuffer(outputBuffer,sChannel,blocking,timeOut);
} catch (Exception e) {
logger.error("An exception occurred while writing a buffer to a channel: {}",e.getMessage());
}
if(result!=null && blocking) {
String resultString = "";
try {
resultString = new String(result.array(), charset).split("\0")[0];
} catch (UnsupportedEncodingException e) {
logger.warn("Exception while attempting an unsupported encoding scheme");
}
logger.info("Received {} from the remote end {}", resultString, sChannel.toString());
String transformedResponse = transformResponse(provider.getProtocolCommand(itemName, command), resultString);
// if the remote-end does not send a reply in response to the string we just sent, then the abstract superclass will update
// the openhab status of the item for us. If it does reply, then an additional update is done via parseBuffer.
// since this TCP binding does not know about the specific protocol, there might be two state updates (the command, and if
// the case, the reply from the remote-end)
if(updateWithResponse) {
List<Class<? extends State>> stateTypeList = provider.getAcceptedDataTypes(itemName,command);
State newState = createStateFromString(stateTypeList,transformedResponse);
if(newState != null) {
eventPublisher.postUpdate(itemName, newState);
} else {