MCPcopy Create free account
hub / github.com/benkuper/Chataigne / sendBytes

Method sendBytes

Source/Module/modules/common/streaming/StreamingModule.cpp:470–505  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

468}
469
470void StreamingModule::sendBytes(Array<uint8> bytes, var params)
471{
472 if (!enabled->boolValue()) return;
473 if (!isReadyToSend())
474 {
475 if (logOutgoingData->boolValue()) NLOGWARNING(niceName, "Can't send data, output is not connected.");
476 return;
477 }
478
479 if (streamingType->getValueDataAsEnum<StreamingType>() == COBS)
480 {
481 if (bytes.size() > 255)
482 {
483 NLOGWARNING(niceName, "Packet length cannot be more than 255 bytes with COBS encoding");
484 return;
485 }
486
487 int numBytes = bytes.size();
488 uint8_t data[255];
489 cobs_encode(bytes.getRawDataPointer(), numBytes, data);
490 bytes.clear();
491
492 for (int i = 0; i < numBytes + 1; ++i) bytes.add(data[i]);
493 bytes.add(0);
494 }
495
496 sendBytesInternal(bytes, params);
497 outActivityTrigger->trigger();
498
499 if (logOutgoingData->boolValue())
500 {
501 String s = "Sending " + String(bytes.size()) + " bytes :";
502 for (auto& b : bytes) s += "\n0x" + String::toHexString(b);
503 NLOG(niceName, s);
504 }
505}
506
507void StreamingModule::showMenuAndCreateValue(ControllableContainer* container)
508{

Callers 8

sendBytesToFromScriptMethod · 0.80
processDataBytesMethod · 0.80
sendBytesFromScriptMethod · 0.80
sendBytesToFromScriptMethod · 0.80
triggerInternalMethod · 0.80
triggerInternalMethod · 0.80
triggerInternalMethod · 0.80

Calls 4

triggerMethod · 0.80
sizeMethod · 0.45
clearMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected