mirror of
https://github.com/faragher/RNS_CS_Dev.git
synced 2024-11-28 18:21:03 +01:00
93 lines
5.5 KiB
C#
93 lines
5.5 KiB
C#
|
// MIT License
|
|||
|
//
|
|||
|
// Copyright (c) 2016-2022 Mark Qvist / unsigned.io
|
|||
|
// C# Port (c) 2023 Michael Faragher / betweentheborders.com
|
|||
|
//
|
|||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|||
|
// of this software and associated documentation files (the "Software"), to deal
|
|||
|
// in the Software without restriction, including without limitation the rights
|
|||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|||
|
// copies of the Software, and to permit persons to whom the Software is
|
|||
|
// furnished to do so, subject to the following conditions:
|
|||
|
//
|
|||
|
// The above copyright notice and this permission notice shall be included in all
|
|||
|
// copies or substantial portions of the Software.
|
|||
|
//
|
|||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||
|
// SOFTWARE.
|
|||
|
|
|||
|
// This is considered pre-alpha of a minimum viable product. No warranties are provided and compatibility is not assured.
|
|||
|
|
|||
|
|
|||
|
|
|||
|
byte[] sideband_fb_data = new byte[] {
|
|||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xfe, 0x00, 0x00, 0x00,
|
|||
|
0x00, 0x00, 0x07, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xf8, 0x00, 0x00,
|
|||
|
0x00, 0x00, 0x7f, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00,
|
|||
|
0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0xc1, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00,
|
|||
|
0x00, 0x1f, 0xff, 0xff, 0xfc, 0x1f, 0xf8, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x07, 0xfc, 0x00,
|
|||
|
0x00, 0x7f, 0xff, 0xff, 0xe0, 0x03, 0xfe, 0x00, 0x00, 0xff, 0xff, 0xff, 0xc1, 0x01, 0xff, 0x00,
|
|||
|
0x01, 0xff, 0xff, 0xff, 0x80, 0x00, 0xff, 0x00, 0x01, 0xff, 0xff, 0xff, 0x80, 0x00, 0xff, 0x80,
|
|||
|
0x03, 0xff, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xc1, 0x07, 0xff, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xe0,
|
|||
|
0x07, 0xff, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xe0, 0x0f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xf0,
|
|||
|
0x0f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xf0, 0x1f, 0xff, 0xff, 0xfe, 0x00, 0x00, 0xff, 0xf8,
|
|||
|
0x1f, 0xff, 0xff, 0xf8, 0x00, 0x00, 0xff, 0xf8, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0x01, 0xff, 0xf8,
|
|||
|
0x3f, 0xff, 0xff, 0xc1, 0x20, 0x03, 0xff, 0xfc, 0x3f, 0xf8, 0x3f, 0x80, 0xf0, 0x07, 0xff, 0xfc,
|
|||
|
0x3f, 0xe0, 0x0f, 0x01, 0xfc, 0x1f, 0xff, 0xfc,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x00, 0x00, 0x7f, 0xf0, 0x07, 0xff, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xe0,
|
|||
|
0x07, 0xff, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xe0, 0x03, 0xff, 0xff, 0xff, 0x80, 0x00, 0xff, 0xc1,
|
|||
|
0x01, 0xff, 0xff, 0xff, 0x80, 0x00, 0xff, 0x80, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x01, 0xff, 0x00,
|
|||
|
0x00, 0xff, 0xff, 0xff, 0xe0, 0x03, 0xff, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xf0, 0x07, 0xfe, 0x00,
|
|||
|
0x00, 0x3f, 0xff, 0xff, 0xfc, 0x1f, 0xfc, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00,
|
|||
|
0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0xc1, 0x00,
|
|||
|
0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xfe, 0x00, 0x00,
|
|||
|
0x00, 0x00, 0x1f, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xc0, 0x00, 0x00,
|
|||
|
0x00, 0x00, 0x00, 0x7f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|||
|
};
|
|||
|
|
|||
|
//Modify the COM port and broadcast specifications as required
|
|||
|
RNode.RNodeInterface R = new RNode.RNodeInterface(new RNS.Transport(), "RNS Test Node", "COM6",915000000,125000,2,8,5,false);
|
|||
|
|
|||
|
void TestCallback(object sender, RNS.Interface.CallbackArgs e)
|
|||
|
{
|
|||
|
Console.WriteLine("Got a packet: ");
|
|||
|
foreach(byte b in e.Message)
|
|||
|
{
|
|||
|
Console.Write(b.ToString("X")+" ");
|
|||
|
}
|
|||
|
Console.WriteLine();
|
|||
|
}
|
|||
|
|
|||
|
R.Callbacks.CallbackEventHandler += TestCallback;
|
|||
|
|
|||
|
Console.WriteLine("Return to send packet. Q then return to quit.");
|
|||
|
R.EnableBacklight();
|
|||
|
R.Enable_External_Framebuffer();
|
|||
|
R.Display_Image(sideband_fb_data);
|
|||
|
|
|||
|
while (true)
|
|||
|
{
|
|||
|
var Dummy = Console.ReadLine();
|
|||
|
if (Dummy == "q") break;
|
|||
|
R.Send(new byte[] { 0x47, 0x6f, 0x6f, 0x64, 0x20, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x74 });
|
|||
|
}
|
|||
|
Console.WriteLine("Terminating...");
|
|||
|
R.Disable_External_Framebuffer();
|
|||
|
R.DisableBacklight();
|
|||
|
R.CloseRadio();
|