Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

AlfredBr

Member Since 29 Oct 2010
Offline Last Active May 01 2015 08:03 AM
-----

#36980 Netduino Plus - Login to Windows Network

Posted by AlfredBr on 10 October 2012 - 06:34 PM

After you talking about the security and all I don’t want to annoy IT with connecting a non-work device. I wish I could think of a completely new project, but I’ve been having trouble. I’ll have to ponder it.


Using Stefan's idea of thinking about how a private notebook would authenticate to your Windows network:

1. First of all, getting an IP address on the network may be more involved than you want. For instance, in many workplaces, you cannot even get an IP address on the wired network if your MAC address is not known beforehand.

2. Assuming you can get an IP address, then you want your Netduino to navigate to a particular URL on your network and authenticate with that server with your Windows credentials, yes? The process would be the same as if you brought...say, your Macintosh into the office and connected it to the network. When you navigate to the URL, you would be presented with an authentication process that can take many forms: it could be Windows Basic Auth, Windows Integrated Auth, Windows Forms Auth or if you are lucky Anonymous Auth.

If it is anonymous auth, then no username and password is required. You probably don't have anonymous auth.
Let's talk about Windows Basic Auth. (We cannot use Windows Integrated Auth).

When your Netduino client application tries to access the web site, the web server issues a challenge for credentials. Normally a web browser would handle this challenge by presenting you with a dialog box where you can type in your username and password. When you receive this challenge on the Netduino, your code will have to then provide for the proper username and password pair to be returned to the web server. If the authentication succeeds, you can then navigate the website.

Consider a different approach. You didn't specify your goals, but depending on what you want to do, you could do this in two hops. Let's say you wanted to light an LED on the Netduino if a value on a particular page on your company website exceeds a certain threshold. You could write a desktop application that does all of the network authentication and website parsing and value comparing on your full-size computer and then send a message via a serial link to the Netduino. When the Netduino receives the serial message, you light the LED (or launch the missile or what-have-you...)

The above scenario is not compliant with the 'internet of things' vision, but it does allow you to interface your Netduino with an arbitrary value on your website. I've glossed over huge technology areas here, but the first hop is from your website to your desktop computer and the second hop is from your desktop computer to your Netduino+.

You can take it from here...


#36466 Servo Controller GO Module

Posted by AlfredBr on 03 October 2012 - 02:43 PM

Do you have any idea how to emulate a serial port on the netduino to send commands at a certain baud rate to another device? I'm slowly researching this but curious if anyone else has attempted it.


Serial communication is well established on the original Netduino and Netduino Plus and is a common way of getting debug information out to a dumb terminal.

The code below might work for you (I pulled it out of one of my projects) but your solution does not have to be this complex. There are also several threads on 'Netduino serial communication' (with various levels of complexity) here in the forums. If you have any trouble making progress, I'll try to help.

        public class SerialPort : IDisposable
        {
            private System.IO.Ports.SerialPort _serialPort;

            public static string NewLine
            {
                get { return "\r\n"; }
            }

            public SerialPort() : this(SerialPorts.COM1)
            {
            }

            public SerialPort(string portName)
            {
                _serialPort = new System.IO.Ports.SerialPort(portName, 9600, Parity.None, 8, StopBits.One);
                _serialPort.Open();
                _serialPort.DataReceived += OnDataReceived;
                Thread.Sleep(50);
                _serialPort.Write(Encoding.UTF8.GetBytes("\r"), 0, "\r".Length);
            }

            public System.IO.Ports.SerialPort Native
            {
                get { return _serialPort; }
            }

            public void Dispose()
            {
                _serialPort.Dispose();
                _serialPort = null;
            }

            public event DataReceivedHandler DataReceived;

            private void OnDataReceived(object sender, SerialDataReceivedEventArgs e)
            {
                var port = sender as System.IO.Ports.SerialPort;
                if (port == null)
                {
                    return;
                }

                DataReceivedHandler handler = DataReceived;
                if (handler == null)
                {
                    return;
                }

                var buffer = new byte[port.BytesToRead];
                int numBytesRead = port.Read(buffer, 0, port.BytesToRead);
                if (numBytesRead <= 0)
                {
                    return;
                }

                var message = new string(Encoding.UTF8.GetChars(buffer));
                handler(new DataReceivedEventArgs(message));
            }

            public virtual void Write(byte[] bytes)
            {
                _serialPort.Write(bytes, 0, bytes.Length);
            }

            public virtual void Write(string message)
            {
                Write(Encoding.UTF8.GetBytes(message));
            }

            public virtual void WriteLine(string message)
            {
                Write(message);
                Write(NewLine);
            }
        }



#11819 Thoughts on the StorageDevice class

Posted by AlfredBr on 08 April 2011 - 03:10 PM

I too would prefer if StorageDevice were a regular class and not a static class. IMO, static classes are great for things like "Math.Xxx()" which do not hold state or have a lifetime. Also, it would allow for more natural subclassing, if it became necessary (minor).


#7150 Familiarization Question

Posted by AlfredBr on 06 January 2011 - 02:59 PM

The Netduino and the Arduino are very different, but it is possible to port code from one to the other with a little effort.

I have been using a Netduino for 3 or 4 months and I have ported several Arduino projects to the Netduino having never seen an actual Arduino board! (However, I just bought an Arduino UNO a few days ago). The Arduino community is a rich resource of ideas and code and familiarity with both Netduino and Arduino makes for a lot of fun.


home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.