handleZwSendData method

void handleZwSendData(
  1. List<int> data
)

FUNC_ID_ZW_SEND_DATA

Implementation

void handleZwSendData(List<int> data) {
  /*
  send data message:
  data[0] - 0x01 SOF
  data[1] - message length excluding SOF and checksum
  data[2] - 0x00 request or 0x01 response
  data[3] - function id 0x13 FUNC_ID_ZW_SEND_DATA
  data[4] - source node
  data[5] - command length
  data[6] - command class
  data[*] - command data
  data[n-1] - transmit options (0x02 low power) <-- is this optional?
  data[n] - checksum
  */
  if (data.length < 7) {
    logger.warning('invalid send data received: $data');
    return;
  }
  var nodeId = data[4];
  var node = existingNodeWithId(nodeId) ?? createUnknownNode(nodeId);
  if (data.length == 7) {
    if (data[5] /* command length */ == 0) {
      //  0x01, // SOF
      //  0x05, // length 5 excluding SOF and checksum
      //  0x00, // request
      //  0x13, // FUNC_ID_ZW_SEND_DATA
      //  0x25, // source node 37
      //  0x00, // command length 0
      //  0xCC, // checksum
      logger.fine('ping controller from node # ${data[4]}');
      node.handleNoOp(data);
      return;
    }
    logger.warning('invalid send data received: $data');
    return;
  }
  if (data.length < 10) {
    if (data[5] /* command length */ == 0 &&
        data[6] == COMMAND_CLASS_NO_OPERATION) {
      //  0x01, // SOF
      //  0x07, // length 7 excluding SOF and checksum
      //  0x00, // request
      //  0x13, // FUNC_ID_ZW_SEND_DATA
      //  0x25, // source node 37
      //  0x00, // command length 0
      //  0x00, // COMMAND_CLASS_NO_OPERATION
      //  0x04, // transmit options: auto route (may not be included)
      //  0xCA, // checksum
      logger.fine('ping controller no-op from node # ${data[4]}');
      node.handleNoOp(data);
      return;
    }
    logger.warning('invalid send data received: $data');
    return;
  }
  node.dispatchSendData(data);
}