Ejemplo n.º 1
0
    static void Main()
    {
        IPConnection           ipcon = new IPConnection();                     // Create IP connection
        BrickletRemoteSwitchV2 rs    = new BrickletRemoteSwitchV2(UID, ipcon); // Create device object

        ipcon.Connect(HOST, PORT);                                             // Connect to brickd
        // Don't use device before ipcon is connected

        // Configure to receive from remote type A with minimum repeats set to 1 and enable callback
        rs.SetRemoteConfiguration(BrickletRemoteSwitchV2.REMOTE_TYPE_A, 1, true);

        // Register remote status a callback to function RemoteStatusACB
        rs.RemoteStatusACallback += RemoteStatusACB;

        Console.WriteLine("Press enter to exit");
        Console.ReadLine();
        ipcon.Disconnect();
    }
Ejemplo n.º 2
0
    private static string UID  = "XYZ";    // Change XYZ to the UID of your Remote Switch Bricklet 2.0

    // Callback function for remote status a callback
    static void RemoteStatusACB(BrickletRemoteSwitchV2 sender, byte houseCode,
                                byte receiverCode, byte switchTo, int repeats)
    {
        Console.WriteLine("House Code: " + houseCode);
        Console.WriteLine("Receiver Code: " + receiverCode);

        if (switchTo == BrickletRemoteSwitchV2.SWITCH_TO_OFF)
        {
            Console.WriteLine("Switch To: Off");
        }
        else if (switchTo == BrickletRemoteSwitchV2.SWITCH_TO_ON)
        {
            Console.WriteLine("Switch To: On");
        }

        Console.WriteLine("Repeats: " + repeats);
        Console.WriteLine("");
    }
Ejemplo n.º 3
0
    private static string UID  = "XYZ";    // Change XYZ to the UID of your Remote Switch Bricklet 2.0

    static void Main()
    {
        IPConnection           ipcon = new IPConnection();                     // Create IP connection
        BrickletRemoteSwitchV2 rs    = new BrickletRemoteSwitchV2(UID, ipcon); // Create device object

        ipcon.Connect(HOST, PORT);                                             // Connect to brickd
        // Don't use device before ipcon is connected

        // Switch on a type A socket with house code 17 and receiver code 1.
        // House code 17 is 10001 in binary (least-significant bit first)
        // and means that the DIP switches 1 and 5 are on and 2-4 are off.
        // Receiver code 1 is 10000 in binary (least-significant bit first)
        // and means that the DIP switch A is on and B-E are off.
        rs.SwitchSocketA(17, 1, BrickletRemoteSwitchV2.SWITCH_TO_ON);

        Console.WriteLine("Press enter to exit");
        Console.ReadLine();
        ipcon.Disconnect();
    }