The tunnel for handling communications to the robots

Hierarchy

Constructors

  • take the robot socket and creates an emitter to notify dependencies

    Parameters

    • socket: null | Socket

      socket of the incoming connections

    • onHandshake: ((packetContent: string) => void)

      handshake handler

        • (packetContent: string): void
        • Parameters

          • packetContent: string

          Returns void

    Returns BotTunnel

Properties

address: undefined | string
connected: boolean = false
dataBuffer: undefined | Buffer
emitter: EventEmitter
id: undefined | string
onHandshake: ((packetContent: string) => void)

Type declaration

    • (packetContent: string): void
    • handshake handler

      Parameters

      • packetContent: string

      Returns void

socket: null | Socket

socket of the incoming connections

Methods

  • Sets up the data buffer for it to be handled by the queue

    Parameters

    • data: Buffer

      data to be handled

    Returns void

  • handles the incoming data and check if it is valid

    emits result for further handling

    Returns

    • nothing if nothing happened and nothing if something happened

    Returns void

  • Parameters

    • mac: string

    Returns {
        macAddress: string;
        type: "CLIENT_HELLO";
    } | {
        config: [string, string][];
        protocol: number;
        type: "SERVER_HELLO";
    } | {
        type: "PING_SEND";
    } | {
        type: "PING_RESPONSE";
    } | {
        type: "QUERY_VAR";
        var_id: number;
        var_type: "float" | "int32" | "uint32";
    } | {
        type: "QUERY_RESPONSE";
        var_id: number;
        var_val: number;
    } | Object | {
        deltaHeadingRadians: number;
        type: "TURN_BY_ANGLE";
    } | {
        tileDistance: number;
        type: "DRIVE_TILES";
    } | {
        type: "ACTION_SUCCESS";
    } | {
        reason: string;
        type: "ACTION_FAIL";
    } | {
        left: number;
        right: number;
        type: "DRIVE_TANK";
    } | {
        type: "ESTOP";
    }

  • send packets to robot

    Parameters

    • packet: {
          macAddress: string;
          type: "CLIENT_HELLO";
      } | {
          config: [string, string][];
          protocol: number;
          type: "SERVER_HELLO";
      } | {
          type: "PING_SEND";
      } | {
          type: "PING_RESPONSE";
      } | {
          type: "QUERY_VAR";
          var_id: number;
          var_type: "float" | "int32" | "uint32";
      } | {
          type: "QUERY_RESPONSE";
          var_id: number;
          var_val: number;
      } | Object | {
          deltaHeadingRadians: number;
          type: "TURN_BY_ANGLE";
      } | {
          tileDistance: number;
          type: "DRIVE_TILES";
      } | {
          type: "ACTION_SUCCESS";
      } | {
          reason: string;
          type: "ACTION_FAIL";
      } | {
          left: number;
          right: number;
          type: "DRIVE_TANK";
      } | {
          type: "ESTOP";
      }

      packet to send

    Returns void

  • Wait for the socket to respond to the sent action

    Returns

    • if the action was completed or rejected

    Returns Promise<void>

Generated using TypeDoc