Exemple #1
0
 /*! Add packet size at the front of the packet
  */
 public static byte[] WrapPacket(ApolloPacketBinary packet)
 {
     byte[] data   = packet.array;
     byte[] output = new byte[data.Length + 4];
     data.CopyTo(output, 4);
     BitConverter.GetBytes(data.Length).CopyTo(output, 0);
     return(output);
 }
Exemple #2
0
        /*
         * public coor_axis_t LeftFingerUp;
         * public coor_axis_t LeftFingerForward;
         * public coor_axis_t LeftRightDirection;*/

        // Sends a packet to the TCP server
        private static void sendPacket(ApolloPacketBinary packet, bool destroyPacket = true)
        {
            _apolloTCP.Send(ApolloSDK.WrapPacket(packet));
            // Dispose of the packet (pointer) if requested
            if (destroyPacket)
            {
                ApolloSDK.apolloDisposePacket(packet);
            }
        }
Exemple #3
0
        // Called when a handshake packet is return from Apollo
        public static void handshakeHandler(IntPtr cbr, UInt64 session, IntPtr pckToReturn)
        {
            log("Received Handshake packet, Start ACK");
            ApolloPacketBinary ackPacket = (ApolloPacketBinary)Marshal.PtrToStructure(pckToReturn, typeof(ApolloPacketBinary));

            // DON'T destroy the packet, because it is owned by the SDK
            sendPacket(ackPacket, false);

            // if the state is not already handshaken or higher, set it up
            if (apolloState < ApolloState.APOLLO_2_GLOVE_SETUP)
            {
                // force retry of handshake
                //apolloState = ApolloState.APOLLO_1_HANDSHAKING;
                apolloState = ApolloState.APOLLO_2_GLOVE_SETUP;
            }
        }
Exemple #4
0
 public static extern void apolloProcessPacket(UInt64 session, ApolloPacketBinary packetBinary);
Exemple #5
0
 public static extern void apolloDisposePacket(ApolloPacketBinary donePacket);