forked from nanoframework/Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
51 lines (42 loc) · 1.52 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
using nanoFramework.TI.EasyLink;
using System.Diagnostics;
using System.Threading;
namespace EasyLink.Concentrator
{
public class Program
{
static byte s_concentratorAddress = 0x00;
public static void Main()
{
EasyLinkController controller = new EasyLinkController(PhyType._5kbpsSlLr);
// need to initialize the EasyLink layer on the target before any operation is allowed
var initResult = controller.Initialize();
if (initResult == Status.Success)
{
controller.AddAddressToFilter(new byte[] { s_concentratorAddress });
while (true)
{
Debug.WriteLine($"Waiting for packet...");
var rxResult = controller.Receive(out ReceivedPacket packet);
if (rxResult == Status.Success)
{
Debug.WriteLine($"Rx packet: {packet.Payload[0]}, RSSI: { packet.Rssi }dB @ {packet.AbsoluteTime}");
}
else
{
Debug.WriteLine($"Error receiving packet: {rxResult}");
}
}
}
else
{
Debug.WriteLine($"Failed to initialize SimpleLink. Error: {initResult}");
}
Thread.Sleep(Timeout.Infinite);
}
}
}