-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
109 lines (101 loc) · 3.77 KB
/
Program.cs
File metadata and controls
109 lines (101 loc) · 3.77 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using System.Collections;
using System.IO.Ports;
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
// follow instructions to load dev env. under netduino 3, netduino 2, and go
// (this is a netduino plus 2).
// i updated the firmware to 4.3.2.1
// http://www.netduino.com/downloads/
// https://learn.sparkfun.com/tutorials/using-the-bluesmirf
// http://www.netduino.com/downloads/gettingstarted.pdf
// https://msdn.microsoft.com/en-us/subscriptions/downloads/
// Test with Hyperterminal - find the Com port you connect to, be sure to enable line feeds.
namespace NetduinoApplication1
{
public class Program
{
static RovingNetworks rn42;
// Create a method for a delegate.
public static void DelegateMethod(string message)
{
Debug.Print(message);
rn42.write(message);
}
public static void Main()
{
// flash the led to say hi
OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
for (int i = 0; i < 5; i++)
{
led.Write(true);
Thread.Sleep(250);
led.Write(false);
Thread.Sleep(250);
}
Debug.Print("flashed LEDs 5 times, not setting up BT");
//rn42 = new RovingNetworks(Serial.COM1, BaudRate.Baudrate115200, Parity.None, 8, StopBits.None);
//Debug.Print("exiting command mode");
rn42 = new RovingNetworks(Serial.COM1, BaudRate.Baudrate115200, Parity.None, 8, StopBits.One);
rn42.ExitCommandModeJustInCase();
//while (true)
//{
// rn42.write("TEST");
// Thread.Sleep(1000);
//}
Thread.Sleep(Timeout.Infinite);
//rn42.CommandEvent = c.CommandEvent;
//rn42.CommsCommands = c.CommsCommands;
//// use a symmetric event wait for both input from Serial (bt) port, and from Brain
//ArrayList newCommands = new ArrayList();
//while (true)
//{
// c.CommandEvent.WaitOne(); // wait forever, or should i timeout just in case i missed an event?
// lock (c.thelock)
// {
// //if (CommsCommands.Count == 0) getGo = true;
// while (c.CommsCommands.Count > 0)
// {
// // service the queue
// // newCommands.Add(CommsCommands[0]);
// string returnString = "You said:" + c.CommsCommands[0];
// Debug.Print(returnString);
// c.CommsCommands.RemoveAt(0);
// rn42.write(returnString);
// }
// }
// // dispatch commands
// //dispatchCommands(newCommands);
// //newCommands.Clear();
//}
//Debug.Print("entering command mode");
//if (rn42.EnterCommandMode())
//{
// Debug.Print("Success");
// ArrayList result = rn42.SendCommand("D\r\n", 500);
// foreach (string str in result)
// {
// Debug.Print(str);
// }
// //Thread.Sleep(Timeout.Infinite);
//}
//else
//{
// Debug.Print("Oh dear...");
//}
//if (rn42.ExitCommandMode())
//{
// Debug.Print("exited command mode");
//}
//else
//{
// Debug.Print("Oh Dear 2...");
//}
}
}
}