Home

.NET & Internet of Things

image

Contents

1. break case SmtpState DomainAccepting if Response 25 Requested mail action okay completed SmtpConnection Send Encoding UTF8 GetBytes MAIL FROM lt from gt r n 5 state SmtpState MailFromAccepting break case SmtpState MailFromAccepting if Response 250 Requested mail action okay completed SmtpConnection Send Encoding UTF8 GetBytes RCPT TO lt recipient gt r n 5 state SmtpState RecipientAccepting break case SmtpState RecipientAccepting if Response 250 Requested mail action okay completed SmtpConnection Send Encoding UTF8 GetBytes DATA r n state SmtpState DataCommandAccepting break case SmtpState DataCommandAccepting if Response 354 Start mail input end with lt CRLF gt lt CRLF gt SmtpConnection Send Encoding UTF8 GetBytes Subject subject rin SmtpConnection Send Encoding UTF8 GetBytes From from r n SmtpConnection Send Encoding UTF8 GetBytes To recipient r n r n SmtpConnection Send Encoding UTF8 GetBytes body r n SmtpConnection Send Encoding UTF8 GetBytes r n state SmtpState MessageAccepting break case SmtpState MessageAccepting if Response 250 Requested mail action okay completed SmtpConnection Send Encoding UTF8 GetBytes QUIT r n state SmtpState ConnectionClosing break case SmtpState ConnectionClosing if Response 221 Req
2. lt form gt lt body gt lt html gt 3 response ContentType text html response OutputStream Write HTML HTML Length response Close catch if context null context Close value Up gt Mouse Up lt input gt lt br gt value Down gt Mouse Down lt input gt value Left gt Mouse Left lt input gt value Right gt Mouse Right lt input gt value Random gt Mouse Random lt input gt Make sure you have the following assemblies in references FEZPanda_Il_GHlElectronics NETMF FEZ e GHlElectronics NETMF Hardware e GHIlElectronics NETMF USBClient e GHlElectronics NETMF W5100 e GHlElectronics NETMF W5100 Http e Microsoft SPOT Hardware e Microsoft SPOT Native e mscorelib hes Join our community at www TinyCLR com Page 58 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things Remote Mouse Prank Run the project and windows will now detect a USB mouse This USB Mouse is actually FEZ Panda presenting itself to the PC as a USB Mouse We can now try the web page hosted from FEZ Open the browser like in the last project and enter FEZ s IP address You should see something similar to this image Ea lt E gt http 192 168 1 176 192 168 1 176 What is happening to my mouse Select Mouse Up Mouse Down Mouse Left Mouse Right 5 Mouse Random Select one of the radio buttons and click submit Y
3. Bob Example lt bob example org gt C To Alice Example lt alice example com gt C Cc theboss example com C Date Tue 15 Jan 2008 16 02 43 0500 C Subject Test message C C C C C C S C S Hello Alice This is a test message Your friend Bob 250 Ok queued as 12345 QUIT 221 Bye The server closes the connection So all we need to let our device send an email is to talk to the SMTP server the same way In other words 1 Open a TCP Socket with the SMTP server at port 25 2 Send the required information for the email as in the example 3 Verify that the server understands what the device is sending 4 Close the TCP Connection The following class does the SMTP Client part Copy the code into a new file and add to your project Name the file SMTP cs eJo Join our community at www TinyCLR com Page 70 of 81 Rev 1 20 GHI Electronics _LLC NET amp Internet of Things You ve got mail and SMS using System using Microsoft SPOT using System Text using GHIElectronics NETMF Net using GHIElectronics NETMF Net Sockets using GHIElectronics NETMF Net NetworkInformation public class SmtpClient private string _SmtpServerName null private int _Port private enum SmtpState NotConnected DomainAccepting MailFromAccepting RecipientAccepting DataCommandAccepting MessageAccepting ConnectionClosing J SmtpState state public SmtpClient string Sm
4. subnet 255 255 255 byte gateway 192 168 1 byte mac 0x00 x26 x1C Ox7B x29 OxE8 WIZnet_W510 Enable SPI SPI_module SPI1 Cpu Pin FEZ_Pin Digital Di10 Cpu Pin FEZ_Pin Digital Di9 true WIZnet interface setting on FEZ Connect NetworkInterface EnableStaticIP ip subnet gateway mac NetworkInterface EnableStaticDns new byte 192 168 1 IPAddress DestinationIP new IPAddress new byte 192 168 1 IPEndPoint DestinationEndPoint new IPEndPoint DestinationIP 2000 String msg Hello PC Socket mySocket new Socket AddressFamily InterNetwork SocketType Dgram ProtocolType Udp hes Join our community at www TinyCLR com Page 37 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things FEZ TCP IP Networking Sockets byte bytesToSend Encoding UTF8 GetBytes msg while true mySocket SendTo bytesToSend bytesToSend Length SocketFlags None DestinationEndPoint while mySocket Po11 2000000 SelectMode SelectRead if mySocket Available gt byte inBuf new byte mySocket Available EndPoint recEndPoint new IPEndPoint IPAddress Any mySocket ReceiveFrom inBuf ref recEndPoint if recEndPoint Equals DestinationEndPoint Check if the received packet is from the 192 168 0 2 continue Debug Print new String Encoding UTF8 GetChars inBuf Now create a regular C console applicat
5. 1 1 byte mac x x88 0x98 x9 xD4 OxEO WIZnet_W5100 Enable SPI SPI_module SPI1 Cpu Pin FEZ_Pin Digital Di10 Cpu Pin FEZ_Pin Digital Di7 true NetworkInterface EnableStaticIP ip subnet gateway mac NetworkInterface EnableStaticDns gateway start server HttpListener listener new HttpListener http 80 listener Start while true HttpListenerResponse response null HttpListenerContext context null try context listener GetContext response context Response The button is pressed if context Request HttpMethod POST audio Set scare wav GetDataIndex wav GetDataSize wav GetSampleRate Sends response response StatusCode int HttpStatusCode OK byte HTML Encoding UTF8 GetBytes lt html gt lt body gt lt hil gt Hosted on FEZ Panda II lt h1 gt lt p gt Let s scare some people lt p gt lt form action method post gt lt input type submit value Activate gt lt form gt lt body gt lt html gt response ContentType text html response OutputStream Write HTML HTML Length response Close catch if context null context Close C49 Join our community at www TinyCLR com Page 54 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things Remote Mouse Prank 9 Remote Mouse Prank Building on the previous project we want
6. SelectMode SelectRead If bytes in buffer then the connection has been closed reset or terminated if m_clientSocket Available return Read the first chunk of the request we don t actually do anything with it Int32 bytesRead m_clientSocket Receive buffer m_clientSocket Available SocketFlags None Return a static HTML document to the client String s HTTP 1 1 200 OK r nContent Type text html charset utf 8 r n r n lt html gt lt head gt lt title gt NET Micro Framework Web Server on USBizi Chipset lt title gt lt head gt lt body gt lt bold gt lt a href http www tinyclr com gt Learn more about the NET Micro Framework with FEZ by clicking here lt a gt lt bold gt lt body gt lt htm1 gt byte buf Encoding UTF8 GetBytes s int offset int ret int len buf Length while len gt ret m_clientSocket Send buf offset len SocketFlags None len ret offset ret m_clientSocket Close RS Join our community at www TinyCLR com Page 42 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things FEZ TCP IP Networking Sockets To test the server open any web browser on any station connected to the same network and enter this address 192 168 0 200 1200 Oe http 192 168 0 200 12000 Pp Bex NET Micro Framework We x Google x Search 4 Aa x S gt Ap Check gt 3
7. on any IO This tutorial covers the details http wiki tinyclr com index php title Output_Compare eJo Join our community at www TinyCLR com Page 28 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things Going on a Test Drive Open Drain Two of the eblock connections are I2C capable pins These pins are special from other pins because they are open drain An open drain pin is a pin than can be low or floating but never high FEZ has on board resistors pulling the two I2C pins high so these pins 12C and SDA can be high and low as usual but the high state is high through pull up resistors If you do not understand this fully then do not worry about this for now 5 6 Connecting Ethernet The details of sockets and networking are covered in later projects but here we want to make sure Ethernet is connected and working properly Start by connecting FEZ through the included Ethernet cable to the same switch where your PC is connected Note that your PC laptop can be connected using WiFi but the same switch should also have wired Ethernet connection to where you plug in your FEZ You could connect FEZ directly to the PC s Ethernet port but then you will not be able to access the internet Now you need to know your local network address It should be 192 168 x The reason 192 168 is used is because these addresses are only allowed on local networks and are not routed to the internet Your router switch handles Et
8. shift F5 Save your project as we will be adding to it shortly MFConsoleApplication1l C Users Gus Issa Desktop test MFConsoleApplication1 E Create directory for solution Join our community at www TinyCLR com Page 15 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things Going on a Test Drive 5 2 Check the Firmware Version very important Before using your FEZ it is very important to check that your PC and your FEZ has the latest firmware Start by checking the release notes online found at this link http www tinyclr com release notes Now open the release notes file found on your PC under C Program Files x86 GHI Electronics GHI NETMF v4 1 SDK Release Notes rtf If your PC has an older version than what is online you should uninstall the GHI SDK then download and install the newer one from GHI The next thing to check is that FEZ has the latest firmware loaded on it which is also the latest version as we have done in previous step We need to start MFDeploy a software that ships with Microsoft NETMF SDK You should find it under C Program Files x86 Microsoft NET Micro Framework v4 1 Tools Under Device select USB and you should see USBizi_USBizi in the list am assuming you have FEZ connected of course Now click Ping and your FEZ will respond with TinyCLR ge NET Micro Framework Deployment Tool Target Options Plug in Help Device USB X
9. 2011 04 22 10 14 00 We will save a flag in RTC Battery RAM indicating that we set the time SetTimeFlag helper 1 BatteryRAM Write SetTimeFlag 4 Thread Sleep Timeout Infinite try WIZnet_W510 Enable SPI SPI_module SPI1 Cpu Pin FEZ_Pin Digital Di10 Cpu Pin FEZ_Pin Digital Di7 true Dhcp EnableDhcp new byte 0x00 9x26 x1C x7B x29 OxE8 FEZ_SMTP Debug Print Network settings Debug Print IP Address new IPAddress NetworkInterface IPAddress ToString Debug Print Subnet Mask new TPAddress NetworkInterface SubnetMask ToString Debug Print Default Getway new IPAddress NetworkInterface GatewayAddress ToString Debug Print DNS Server new TPAddress NetworkInterface DnsServer ToString mySmtp new SmtpClient smtp comcast net 25 In our application we saved this SetTimeFlag to 1 when we set the correct time and date BatteryRAM Read SetTimeFlag helper 4 oo Join our community at www TinyCLR com Page 73 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things You ve got mail and SMS if SetTimeFlag helper 1 IsTimeSet true if IsTimeSet The time and date are still set correctly in the Real Time Clock and we can use it in our application Set system s clock Utility SetLocalTime RealTimeClock GetTime Indicator StartBlinking 1000 1000 This means t
10. Issa Do Join our community at www TinyCLR com Page 19 of 81 Rev 1 20 GHI Electronics _LLC NET amp Internet of Things Going on a Test Drive Then add FEZPanda_Il_GHIElectronics NETMF FEZ if you are using FEZ Panda Il Projects Recent Browse Component Name Version Runtime System Net Security 4 1 2821 0 v4 0 30319 System Xml 4 1 2821 0 v4 0 30319 System Xml Legacy 4 1 2821 0 v4 0 30319 FEZCobra_GHIElectronics NETMF FEZ 413 0 v4 0 30319 FEZDomino_GHlElectronics NETMF FEZ 413 0 v4 0 30319 FEZMini_GHlElectronics NETMF FEZ 413 0 v4 0 30319 f FEZPanda_GHlElectronics NETMF FEZ 413 0 v4 0 30319 FEZRhino_GHlElectronics NETMF FEZ 413 0 v4 0 30319 GHlElectronics NETMF Hardware Chipwo 4 1 3 0 v4 0 30319 GHlElectronics NETMF Hardware 4 13 0 v4 0 30319 GHlElectronics NETMF Hardware EMX 4 13 0 v4 0 30319 m We will be controlling processor ports pins so we need the Microsoft SPOT Hardware SPOT is an old name for NETMF NeT Projects Recent Browse Component Name Version Runtime pe MFDpwsClient 4 1 2821 0 v4 0 30319 MFDpwsDevice 4 1 2821 0 v4 0 30319 MFDpwsExtensions 4 1 2821 0 v4 0 30319 MFWsStack 4 1 2821 0 v4 0 30319 Microsoft SPOT Graphics 4 1 2821 0 v4 0 30319 Microsoft SPOT Hardware 4 1 2821 0 v4 0 30319 Microsoft SPOT Hardware SerialPort 4 1 2821 0 v4 0 30319 Microsoft SPOT Hardware Usb 4 1 2821 0 v4 0 30319
11. NET amp Internet of Things The fun ana easy way the FEZ way Connecting the world one thing at a time Brought to you by QD electronics with the April 27 2011 Copyright 2011 GHI Electronics LLC www ghielectronics com Micro Framework GHI Electronics _LLC NET amp Internet of Things Table of Contents PAO MUCHO Hise Seisicsecaneassesecarsarsesrnerneaeeersenecnscectanqesdeateavdeateauiarscssaee 2 Prerequisite 3 Complete Kits 3 Lntemetior things Kiticccecscscessaccaasceesnsnessaredac saeneaaee 5 3 2 FEZ Ultimate RIL cos cseessncdp ncn carenongsnecnecia censctavendsoaternarecontaeren 6 4 FEZ Ultimate Kit CONLIN cescasccsvcasccssesasescecszerszacacrecssccnsasanessacazee 7 A i ee Pandai iaa E T The Panda HardWwaro nissip ndi tani Erra ai iS 7 The Panda SoftWare riide aata 8 4 2 FEZ Internet of Things Kit Contents c cceeeeeeeees 9 FEZ Connect Shield sccvecssstnesssescessnesecaccassesnessncestacavaneastase 9 OWiG sanaa o anA Mace aaeeaS 10 Temperature sensor 2210 38Khz Infrared Receiver IRLED Transmitter Light Sensor Piezo Speaker Variable Resistor POT Seria to USB iiris BS Gogon a Test DAWG eseis na n ae rae iSi 5 1 Testing he EMUN sarisin 5 2 Check the Firmware Version very important Did Tesio FEZ Panga ll sperrir ieai aAA 5 4 The on board LED amp Buttons siesscsicsasceicoses cases censca
12. X Erase Image File v Browse Deploy Base 3 1 TinyCLR WAND WY Qa sss Join our community at www TinyCLR com Page 16 of 81 Rev 1 20 GHI Electronics _LLC NET amp Internet of Things Going on a Test Drive From the top menu run Target Device Capabilities which will query a lot of info from FEZ but we are mainly interested in is the Solution version This number much match the USBizi version number in release notes which also matches the latest from the website Firmware update tutorial is available here http wiki tinyclr com index php title Firmware_Update_USBizi Target Options Plug in Help Device Image File Maio y LEM Ss y LEMOS li csNulmes ClrInfo clrVersion 1 2821 0 ClriInfo clrVendoriInfo Microsoft Copyrigh ie E a ig 5 O targetFrameworkVersion call SolutionReleaselInfo solutionVersion S9 bande leaseInfo solutionVendoriInfo Electronics SoftwareVersion BuildDate Apr 11 2011 SoftwareVersion CompilerVersion 410561 FloatingPoint True WT SMOG Join our community at www TinyCLR com Page 17 of 81 Rev 1 20 GHI Electronics _LLC NET amp Internet of Things Going on a Test Drive 5 3 Testing FEZ Panda II We now know NETMF is working fine on the emulator so let us do the same but this time on FEZ Panda II You may have a different FEZ board but this will apply Assuming you already have t
13. amp Internet of Things Complete Kits 3 2 FEZ Ultimate Kit Expanding on the Fez Internet of Things Kit FEZ Ultimate kit takes the same kit and adds FEZ Panda II with FEZ Touch at only 149 95 Page 6 of 81 Rev 1 20 GHI Electronics _LLC NET amp Internet of Things FEZ Ultimate Kit Contents 4 FEZ Ultimate Kit Contents 4 1 FEZ Panda II The second generation of FEZ Panda is a state of the art processor board capable of hosting complete commercial applications Compatible with most 54 Digital I O Arduino Shields 6 Analog inputs 6 PWM ports 72 MHz CPU with lots of FLASH and RAM Analog output with audio playback Runtime debugging Configurable USB r KOSS 2 CAN channels Commerical quality support Real time clock for TCP IP HTTP with W5100 High speed MicroSD 2 SPI 4 UART and No 2GB limitation one 12C serial interfaces The Panda Hardware e 72Mhz 32 bit processor with 512KB of FLASH and 96KB of RAM e 148KB of FLASH and 62KB of RAM are available for your application e Micro SD socket capable of hosting any size memory card drop in a 16GB memory card and you have near unlimited embedded storage Real Time Clock RTC By adding a little 3V watch battery FEZ Panda can keep track of time for years even if FEZ Panda is powered off Over 60 digital inputs and outputs gt 6x Analog inputs e One analog output which is also capable of audio playback Join our com
14. and active community available at http www tinyclr com forum and the hundreds of code examples found at http code tinyclr com OP Join our community at www TinyCLR com Page 4 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things 3 Complete Kits This book is aimed towards the FEZ Internet of Things Kit and FEZ Ultimate Kit 3 1 Internet of things Kit With over ten years of experience working on little embedded devices and with the help of the www TinyCLR com community GHI is combining the most popular sensors along with plenty of projects to bring the internet of things right to your desk Complete projects with detailed explanations are included in this book to complete many internet connected device all for under 100 On the hardware side all of the components are plug and play No soldering or any special skill is required Also on the software side all open source drivers are included Use the provided drivers as is or modify to fit your needs The kit doesn t come with a processor board giving the user further flexibly selecting a device FEZ Domino FEZ Panda or FEZ Panda Il are ideal mates for the Internet of Things Kit The kit even works with Arduino and its derivatives keeping in mind that all open source code samples are this book are aimed to using C for FEZ and NET Micro Framework oo Join our community at www TinyCLR com Page 5 of 81 Rev 1 20 GHI Electronics LLC NET
15. back the temperature form the included Temperature eblock AAN Or Join our community at www TinyCLR com Page 68 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things 12 You ve Got Mail And SMS In this project we will create a piece of hardware that reports a door opened closed status through emails This can be good starting point for a security system or a monitoring system Maybe you are monitoring the temperature in a warehouse and need a warning email if the temperature is too high or too low What if you don t have access to email but you had access to SMS through your phone This is actually very easy Each provider has a specific email that you can use as a gateway for SMS For example AT amp T in the USA uses XXXXXXXXXX tXt att net so if the phone number was 0123456789 then the email to send an SMS is 0123456789 txt att net Contact your cellphone provider for details The program flow 1 The system is connected to the Ethernet network and it gets the network settings automatically using DHCP feature 2 It checks whether the date and time are set and sends an email if they are not 3 After complete boot up the system sends an email with the initial door state Subject FEZ Door Monitor has booted up Body The system booted up at 04 22 2011 10 54 28 and the door was opened 4 The systems monitors the door and sends an email as soon as the status changes for example it sends and email with this messa
16. i 1 eJo Join our community at www TinyCLR com Page 36 of 81 Rev 1 20 GHI Electronics _LLC NET amp Internet of Things FEZ TCP IP Networking Sockets while true if serversocket Poll 1 SelectMode SelectRead EndPoint recEndPoint null byte inBuf new byte serversocket Available int count serversocket ReceiveFrom inBuf ref recEndPoint Debug Print new String Encoding UTF8 GetChars inBuf Debug Print From recEndPoint Address ToString UDP Transceive data with PC Now we will try to exchange UDP messages between our FEZ device and the PC Let s suppose that the PC s IP address is 192 168 0 1 and the FEZ device s IP address is 192 168 0 200 and we will set a UDP server at the PC that receives messages on UDP port 2000 On the other side we will let our FEZ device send this message Hello PC to the PC s IP address and UDP port 2000 then it will wait for the response message from the PC Hello FEZ device Deploy this code on FEZ device using System using System Threading using Microsoft SPOT using Microsoft SPOT Hardware using GHIElectronics NETMF FEZ using GHIElectronics NETMF Net using GHIElectronics NETMF Net Sockets using GHIElectronics NETMF Net NetworkInformation using System Text using Socket GHIElectronics NETMF Net Sockets Socket public class Program public static void Main byte ip 192 168 200 byte
17. kee Device Hello PC Hello FEZ Device Message Fromi 2 168 0 200 Hello FEZ Device Hello PC Hello FEZ Device Hello FEZ Device Halla FET Nawuira 6 2 Transmission Control Protocol TCP TCP is the other important member of TCP IP stack UDP is connectionless on the other hand TCP is connection oriented protocol This means that you can imagine TCP session as a virtual connection between the client and the server The main thing that TCP connection offers is a handshaking mechanism between the client and the server to ensure that the sent TCP packet has been received successfully You don t need to worry about all these details since they are handled internally You only need to open the TCP connection using a networking socket in the code and start exchanging data TCP is also widely used with services such as HTTP web browsing Telnet FTP SMTP sending emails and POP3 TCP client example Here is a simple example on how to create a TCP client using System using System Threading using Microsoft SPOT using Microsoft SPOT Hardware using GHIElectronics NETMF FEZ using GHIElectronics NETMF Net using GHIElectronics NETMF Net Sockets using GHIElectronics NETMF Net NetworkInformation using System Text using Socket GHIElectronics NETMF Net Sockets Socket OQ T2 Join our community at www TinyCLR com Page 39 of 81 Rev 1 20 GHI Electronics _LLC NET amp Internet of Things FEZ TCP IP Network
18. port uint state DateTime time if state pressed ButtonTimer Change 5000 1 else ButtonTimer Change 1 1 send the signal LED Write true Debug Print Send TV signal RemoteGenerator SetBlocking true buffer edges 100 true 38000 LED Write false Note that the IrLED eblock uses a tiny LED You will need to be close to the TV for it to work If desired an experienced user can modify the eblock with a transistor and a high power IrLED We Need More The project needs to be expanded to learn multiple buttons Also the recorded signals should be stored on the SD card You can even use the touch display to create a fancy full color display universal remote control hes Join our community at www TinyCLR com Page 79 of 81 Rev 1 20 GHI Electronics _LLC NET amp Internet of Things Using FEZ Touch 14 Using FEZ Touch GHI provides drivers for the color display and for the touch interface A sample paint application demonstrates the driver and the touch interface http code tinyclr com project 27 7 fez touch lcd component SS o n unor 23499 GHI Electromcs wuu TinyCLR com aA oy Join our community at www TinyCLR com Page 80 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things What is next 15 What Is Next One important place to always visit is this page that has all the resources needed and many tutorial li
19. re now ready to expand upon our example or create a whole new project For example ever ask yourself Did close the garage door You can now answer that question Using a light sensor and distance detector you can reasonably record when your garage door is open or closed Simply log into ThingSpeak to check Just imagine all the information you can collect and access from the internet hos Join our community at www TinyCLR com Page 64 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things FEZ Telnet 11 FEZ Telnet Telnet is very simple but very powerful It is basically a TCP connection between 2 nodes and works very well like a terminal software There are many applications that support Telnet for PCs and for mobile phones We will run the tests on Moca Telnet Lite a free iPhone app and on TeraTerm on PC TeraTerm is a free software that GHI uses for firmware update and it is also recommended for development Even though it is mostly used with serial connections it can also work over the network Telnet FEZ will be the server waiting for client requests to handle specific tasks We need to run a listening socket and wait for connection A new thread is spawned for every connection so you can actually have more than one connection The Process method will look for strings ending with enter key that is r for return Once it detects the enter key it will send the command string to the Handle
20. server new Socket AddressFamily InterNetwork SocketType Stream ProtocolType Tcp Telnet usually uses port 23 IPEndPoint localEndPoint new IPEndPoint IPAddress Any 23 server Bind localEndPoint start listening server Listen 1 while true Wait for a client Socket Sock server Accept new TelnetProcess Sock internal sealed class TelnetProcess byte prompt Encoding UTF8 GetBytes r nFEZ gt private Socket clientSocket bool EchoIsEnabeled false public TelnetProcess Socket Sock clientSocket Sock Spawn a new thread new Thread Process Start private void HandleCommand string cmd string str cmd cmd ToUpper switch cmd case ECHO EchoIsEnabeled EchoIsEnabeled clientSocket Send prompt str EchoIsEnabeled EchoIsEnabeled clientSocket Send Encoding UTF8 GetBytes str str Length SocketFlags None break case LED ON LED Write true clientSocket Send prompt str LED is now on clientSocket Send Encoding UTF8 GetBytes str str Length SocketFlags None break case LED OFF LED Write false clientSocket Send prompt str LED is now off clientSocket Send Encoding UTF8 GetBytes str str Length SocketFlags None private void Process break oo Join our community at www TinyCLR com Page 66 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things FEZ Te
21. Any c_port server Bind localEndPoint server Listen 1 while true Wait for a client to connect Socket clientSocket server Accept Process the client request true means asynchronous new ProcessClientRequest clientSocket true lt summary gt Processes a client request lt summary gt internal sealed class ProcessClientRequest private Socket m_clientSocket lt summary gt The constructor calls another method to handle the request but can optionally do so in a new thread lt summary gt Do Join our community at www TinyCLR com Page 41 of 81 Rev 1 20 GHI Electronics _LLC NET amp Internet of Things FEZ TCP IP Networking Sockets lt param name clientSocket gt lt param gt lt param name asynchronously gt lt param gt public ProcessClientRequest Socket clientSocket Boolean asynchronously m_clientSocket clientSocket if asynchronously Spawn a new thread to handle the request new Thread ProcessRequest Start else ProcessRequest lt summary gt Processes the request lt summary gt private void ProcessRequest const Int32 c_microsecondsPerSecond 1000000 using ensures that the client s socket gets closed using m_clientSocket Wait for the client request to start to arrive Byte buffer new Byte 1024 if m_clientSocket Pol1 5 c_microsecondsPerSecond
22. AudioFormat ushort Utility ExtractValueFromArray wav index 2 index 2 if AudioFormat 1 throw new Exception AudioFormat invalid ushort NumChannels ushort Utility ExtractValueFromArray wav index 2 index 2 if NumChannels 1 throw new Exception Must be mono sampleRate int Utility ExtractValueFromArray wav index 4 index 4 if sampleRate 8000 throw new Exception Sample rate must be 8 KHz ushort ByteRate ushort Utility ExtractValueFromArray wav index 4 index 4 ushort BlockAlign ushort Utility ExtractValueFromArray wav index 2 index 2 if BitVarSampleRate16 ushort BitsPerSample ushort Utility ExtractValueFromArray wav index 2 index 2 if BitsPerSample 8 throw new Exception Must be 8 bit else uint BitsPerSample Utility ExtractValueFromArray wav index 4 index 4 if BitsPerSample 8 throw new Exception Must be 8 bit OS Join our community at www TinyCLR com Page 52 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things Network Controlled Screamer data sub chunk 11111111 111TTTSTTTTTTT if wav index d wav index 1 a wav index 2 t wav index 3 a throw new Exception Unexpected data subchunk index 4 uint Subchunk2Size ushort Utility ExtractValueFromArray wa
23. Command method Note that whatever you enter on the Telnet client will be sent to the server but not necessarily shown in the client side your side This is resolved by the server echoing the data back to the client In our code this is done by entering echo command which toggles EcholsEnabeled flag The code also has LED ON and LED OFF commands so try them out Note that the LED is connected to Di5 using System using System Threading using System Text using Microsoft SPOT using Microsoft SPOT Hardware using GHIElectronics NETMF FEZ using GHIElectronics NETMF Net using GHIElectronics NETMF Net NetworkInformation using GHIElectronics NETMF Net Sockets public static class MySocketServer Our LED eblock is connected to Di5 static OutputPort LED new OutputPort Cpu Pin FEZ_Pin Digital Di5 false public static void Main byte ip 192 168 1 176 byte subnet 255 255 255 byte gateway 192 168 1 1 byte mac 0x00 0x88 0x98 x9 OxD4 OxE WIZnet_W510 Enable SPI SPI_module SPI1 Cpu Pin FEZ_Pin Digital Di10 Cpu Pin FEZ_Pin Digital Di7 true OQ 72 Join our community at www TinyCLR com Page 65 of 81 Rev 1 20 GHI Electronics _LLC NET amp Internet of Things FEZ Telnet NetworkInterface EnableStaticIP ip subnet gateway mac NetworkInterface EnableStaticDns gateway Our Listening socket Socket
24. Internet of Things Going on a Test Drive Note that in my case my router did work as my DNS server but this may not be the case for your network setup If you are not sure of what DNS address to you use ppen your PC s command prompt and enter ipconfig all and it will show the DNS server your PC using You only need DNS if you want to access a website by its name instead of its IP But you can always ping a website from your PC to find its IP then use that in your code Not a good practice as the IP of a website may change Here is an output of pinging GHI website compare to the output above Using DHCP In modern networks with many devices connected it can be very difficult to assign an IP address to every device Instead the device starts by requesting an IP address from a DHCP server which assigns a unique IP for the device The challenge is that we need to know the IP of the device to connect to it Some code can be added to print the device s IP on the display or the debug output The examples used in this book assumes a static IP is used Here is an example code to obtain an IP address using DHCP public static void Main Enable the Ethernet WIZnet_W5100 Enable SPI SPI_module SPI1 Cpu Pin FEZ_Pin Digital Di1 Cpu Pin FEZ_Pin Digital Di7 true Dhcp EnableDhcp new byte 0x00 0x88 0x98 x9 xD4 xE AnyName Debug Print Network settings Debug Print IP Address new IPAddre
25. Microsoft SPOT Ink 4 1 2821 0 v4 0 30319 Microsoft SPOTIO 4 1 2821 0 v4 0 30319 Microsoft SPOT Native 4 1 2821 0 v4 0 30319 4 Page 20 of 81 Rev 1 20 GHI Electronics _LLC NET amp Internet of Things Going on a Test Drive We can now change the code to match the following You can copy paste the code if you like using System using System Threading using Microsoft SPOT using Microsoft SPOT Hardware using GHIElectronics NETMF FEZ public class Program public static void Main while true MyLED Write false Thread Sleep 3 MyLED Write true Thread Sleep 3 static OutputPort MyLED new OutputPort Cpu Pin FEZ_Pin Digital LED true If you don t understand the code above we suggest reading the beginner s guide Basically the code goes in an endless loop and turns the LED on then off every 300ms FEZ Panda Il also hosts a button that is used to force the board in boot loader mode but we can also use this button in our application Modify the code to the following using System using System Threading using Microsoft SPOT using Microsoft SPOT Hardware using GHIElectronics NETMF FEZ public class Program Port ResistorMode Pullup public static void Main while true MyLED Write MyButton Read Thread Sleep 10 static OutputPort MyLED new OutputPort Cpu Pin FEZ_Pin Digital LED true
26. SPOT using Microsoft SPOT Hardware using GHIElectronics NETMF Hardware using GHIElectronics NETMF FEZ public class Program static PinCapture cap new PinCapture Cpu Pin FEZ_Pin Digital Di2 Port ResistorMode Disabled static OutputPort LED new OutputPort Cpu Pin FEZ_Pin Digital Di5 false static OutputCompare RemoteGenerator new OutputCompare Cpu Pin FEZ_Pin Digital Di8 false 300 static uint buffer new uint 30e static int edges static Timer ButtonTimer new Timer new TimerCallback ButtonTimerHandler null 1 1 public static void Main InterruptPort Button new InterruptPort Cpu Pin FEZ_Pin Interrupt Di3 true Port ResistorMode PullUp Port InterruptMode InterruptEdgeBoth Add a button event Button OnInterrupt new NativeEventHandler Button_OnInterrupt Thread Sleep Timeout Infinite OQ 72 Join our community at www TinyCLR com Page 78 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things FEZmote Internet TV Remote static void ButtonTimerHandler object o Debug Print Programming mode Debug Print Press and hold a button on the TV remote LED Write true edges cap Read false buffer buffer Length 3000 if edges else Debug Print Nothing was captured Debug Print We have edges edges LED Write false Debug Print Done programing static void Button_OnInterrupt uint
27. Show we ve started by blinking the LED int count bool ledState false OutputPort led new OutputPort Cpu Pin FEZ_Pin Digital LED ledState while count lt 20 ledState ledState led Write ledState count 3 Thread Sleep 1 Initialize the eblocks thermometer new AnalogIn AnalogiIn Pin FEZ_Pin AnalogIn An2 thermometer SetLinearScale 22 56 lightSensor new AnalogiIn AnalogiIn Pin FEZ_Pin AnalogIn An3 lightSensor SetLinearScale 100 Begin sampling the temperature running true thread new Thread MainLoop thread Priority ThreadPriority Highest thread Start public static void MainLoop string result while running temp thermometer Read light lightSensor Read Convert to Fahrenheit temp temp 9 5 32 Debug Print Temperature temp F Swap the intensity making zero complete darkness light 100 light Debug Print Brightness light ThingSpeak will respond with an Entry ID result SendToThingSpeak url key key amp fieldi temp amp field2 light Debug Print Entry ID result Thread Sleep 30e public static string SendToThingSpeak string url string result null Create an HTTP Web request HttpWebRequest request HttpWebRequest Create url as HttpWebRequest Set request KeepAlive to use a persistent connection request KeepAlive true G
28. TMF FEZ Sjpublic class Program static PWM MyFader new PWM PWM Pin FEZ_Pin PWM P Di10 aP DiS FEZ_Pin PWM PWM Di5 P Di6 aP Di8 a Di9 aP MOD Looking at what IntelliSense gave us and at the board it seems that the easiest socket to access is Di5 since it s on the edge so let s use it Do Join our community at www Tiny CLR com Page 25 of 81 Rev 1 20 GHI Electronics _LLC NET amp Internet of Things Going on a Test Drive using System using System Threading using Microsoft SPOT using Microsoft SPOT Hardware using GHIElectronics NETMF Hardware using GHIElectronics NETMF FEZ public class Program static PWM MyFader new PWM PWM Pin FEZ_Pin PWM Di5 public static void Main byte i while true MyFader Set 10000 i if i gt 100 i Thread Sleep 10 The LED will now be coming in slowly till it is fully on 100 then it s back to level zero 0 This can be more exiting by making the LED fade in and out using System using System Threading using Microsoft SPOT using Microsoft SPOT Hardware using GHIElectronics NETMF Hardware using GHIElectronics NETMF FEZ public class Program static PWM MyFader new PWM PWM Pin FEZ_Pin PWM Di5 public static void Main byte i int dirr 1 while true MyFader Set 10000 i i byte i dirr if i gt 90 dirr 1 if i lt 10 di
29. Trai Learn more about the NET Micro Framework with FEZ by clicking here You probably noticed that this web server code is simple but it can be even simpler using the HTTP class provided as you will see in the next examples hes Join our community at www TinyCLR com Page 43 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things FEZ HTTP 7 FEZ HTTP Do you know that you are probably using HTTP daily HTTP is how web pages are transferred from servers to your internet browser Let s go back one step and detail this What defines a web page s look is something called HTML Hyper Text Markup Language a text that defines the look of a page Nothing better to explain this than trying a simple example Open notepad on your PC and put this text in it lt html gt lt body gt lt h1 gt FEZ Panda lt h1 gt lt p gt Embedded Systems were never easier lt p gt lt body gt lt html gt Save the file and then rename its extension from txt to HTML Now open the file with any browser It should look like this D test html CO file C Users Yg q gt 5 Other bookmarks FEZ Panda Embedded Systems were never easier Do Join our community at www TinyCLR com Page 44 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things FEZ HTTP Those HTML files are stored on the server or even dynamically generated and then transferred to yo
30. _GHlElectronics NETMF FEZ Description Temperature and light intensity a GHIElectronics NETMF Hardware Tags GHlElectronics NETMF USBClient Entries 21 e GHIlElectronics NETMF W5100 Created Fri Apr 22 at 8 40 am e GHlElectronics NETMF W5100 Dhcp Latitude GHlElectronics NETMF W5100 Http a Microsoft SPOT Hardware Microsoft SPOT Native le s emperature Field 2 Light Intensity mscorelib using using using using using using using using using using static static static static static static public System System IO System Threading System Text Microsoft SPOT Microsoft SPOT GHIElectronics GHIElectronics GHIElectronics GHIElectronics public class Program Enable the Ethernet WIZnet_W510 Cpu Pin FEZ_Pin Digital Di7 true Dhcp EnableDhcp new byte 0x00 x26 x1C x7B x29 OxE8 FEZ Hardware NETMF Net Thread thread bool running string url http api thingspeak com update string key lt YourThingSpeakChannelKey gt AnalogIn thermometer AnalogIn lightSensor static int temp static int light static void Main NETMF FEZ NETMF Hardware NETMF Net NetworkInformation Enable SPI SPI_module SPI1 Cpu Pin FEZ_Pin Digital Di10 Do Join our community at www TinyCLR com Page 61 of 81 Rev 1 20 GHI Electronics _LLC NET amp Internet of Things Sensor Monitoring Temp Light
31. al peripheral interface from the system such as PWM or UART The eblocks connectors on the FEZ Connect Shield offer UART serial 12C Analog In Analog Out and PWM The provided projects will utilize the eblocks showing their functions and possible uses All of the eblocks connectors have a standard pin out composing of 5V signal and Ground Optionally the 2 analog related connectors can have 3 3V or 5V through a jumper If you re not sure what you need then leave it at 5V the default Let s try to connect an LED eblock through FEZ Connect and blink it just like we did with the on board LED First disconnect FEZ and plug the FEZ Connect shield on top Now plug any of the LED eblocks that came with the kit into any of the eblock connectors To demonstrate that analog pins also work as digital we are going to connect the LED to An2 just like shown below RSA Join our community at www TinyCLR com Page 23 of 81 Rev 1 20 GHI Electronics _LLC Se amem ee DE CEEEEE GEEERE B Then we will take the old code and modify it NET amp Internet of Things Going on a Test Drive using System using System Threading using Microsoft SPOT using Microsoft SPOT Hardware using GHIElectronics NETMF FEZ public class Program public static void Main while true MyLED Write false Thread Sleep 3 MyLED Write true Thread Sleep 3 static OutputPort MyLED new OutputPort Cp
32. cation Visual C FEZ Cobra Console Application Visual C Leave the code unchanged and press F10 once to step in the code This is a shortcut for Debug Step Over Now open the output window Note that you need to enable expert settings if you haven t done so already Tools Window Help 3 Connect to Database B Code Snippets Manager Ctrl K Ctrl B Tosese5iing a Choose Toolbox Items a Extension Manager External Tools Settings gt Basic Settings Customize v Expert Settings Options ka Import and Export Settings Join our community at www TinyCLR com Page 14 of 81 Rev 1 20 GHI Electronics _LLC NET amp Internet of Things Going on a Test Drive Step more in the code using F10 till you go over the line with Debug Print and you will see Hello World in the output window z public class rrogram a public static void Main Debug Print Resources GetString Resources StringResources String1 gt b 100 Show output from eu a RIS Microsoft SPOT Emulator Sample SampleEmulator exe Managed Loaded C Progri Microsoft SPOT Emulator Sample SampleEmulator exe Managed Loaded C Progri Microsoft SPOT Emulator Sample SampleEmulator exe Managed Loaded C Users The thread lt No Name gt x2 has exited with code x Hello World Stop debugging using
33. ectronics NETMF FEZ using GHIElectronics NETMF Net using GHIElectronics NETMF Net NetworkInformation using GHIElectronics NETMF USBClient public class Program public static void Main start the mouse USBC_Mouse mouse USBClientController StandardDevices StartMouse byte ip 192 168 1 176 byte subnet 255 255 255 byte gateway 192 168 1 1 byte mac 0x00 0x88 0x98 x9 OxD4 OxEe chr Join our community at www TinyCLR com Page 56 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things Remote Mouse Prank WIZnet_W5100 Enable SPI SPI_module SPI1 Cpu Pin FEZ_Pin Digital Di10 Cpu Pin FEZ_Pin Digital Di7 true NetworkInterface EnableStaticIP ip subnet gateway mac NetworkInterface EnableStaticDns gateway start server HttpListener listener new HttpListener http 80 listener Start while true HttpListenerResponse response null HttpListenerRequest request null HttpListenerContext context null try context listener GetContext response context Response request context Request The button is pressed if request HttpMethod POST if request ContentLength64 gt read te radio value byte buffer new byte int request ContentLength64 request InputStream Read buffer buffer Length string move new string Encoding UTF8 GetChars buffer now we ha
34. esult new String charData charUsed result new String System Text Encoding UTF8 GetChars byteData else Read until the end of the data is reached while true If the Read method times out it throws an exception which is expected for Keep Alive streams because the connection isn t terminated try Thread Sleep 5 bytesRead respStream Read byteData byteData Length catch Exception oo Join our community at www TinyCLR com Page 63 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things Sensor Monitoring bytesRead Zero bytes indicates the connection has been closed by the server if bytesRead break int byteUsed charUsed bool completed false totalBytes bytesRead UTF8decoder Convert byteData bytesRead charData bytesRead true out byteUsed out charUsed out completed result result new String charData charUsed Close the response stream For Keep Alive streams the stream will remain open and will be pushed into the unused stream list resp Close J return result After allowing the program to run awhile you ll be ready to view the data ThingSpeak also has charting tools which enable you to create a line bar or column graph to visualize your data including many additional options FEZ Temp Light FEZ Temp Light Temperature Light Intensity Date Date You
35. et a response from the server WebResponse resp null try oo Join our community at www TinyCLR com Page 62 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things Sensor Monitoring resp request GetResponse catch Exception e Debug Print Exception in HttpWebRequest GetResponse e ToString Get the network response stream to read the page data if resp null Stream respStream resp GetResponseStream byte byteData new byte 4e96 char charData new char 4 96 int bytesRead Decoder UTF8decoder System Text Encoding UTF8 GetDecoder int totalBytes allow 5 seconds for reading the stream respStream ReadTimeout 5000 If we know the content length read exactly that amount of data otherwise read until there is nothing left to read if resp ContentLength 1 for int dataRem int resp ContentLength dataRem gt Thread Sleep 5 bytesRead respStream Read byteData byteData Length if bytesRead Debug Print Error Received resp ContentLength dataRem Out of resp ContentLength break dataRem bytesRead Convert from bytes to chars and add to the page string int byteUsed charUsed bool completed false totalBytes bytesRead UTF8decoder Convert byteData bytesRead charData bytesRead true out byteUsed out charUsed out completed result r
36. ge The Door was closed at 04 22 2011 10 56 15 What we need 1 The main system is our FEZ Panda II board 2 Real Time Clock which is included with FEZ Panda II and is maintained by the on board super capacitor included on FEZ Connect shield 3 FEZ Connect shield 4 A button eblock that we will use as a touch sensor So when the door is closed the button will be pressed We are connecting it to Digital I O Di2 5 A LED eblock optional connected to Digital I O Di8 There are many methods of sending emails In this project we will use the simplest and the eJo Join our community at www TinyCLR com Page 69 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things You ve got mail and SMS most common method which is Simple Mail Transfer Protocol SMTP SMTP is an application layer protocol of the Internet protocol suite This protocol uses TCP protocol to exchange data between the client and the server Usually the SMTP server TCP port number is 25 Here is a simple dialog from wikipedia between the SMTP client the party willing to send the email and the SMTP server the party that handle sending the message S 220 smtp example com ESMTP Postfix C HELO relay example org S 250 Hello relay example org am glad to meet you C MAIL FROM lt bob example org gt S 250 Ok C RCPT TO lt alice example com gt S 250 Ok C DATA S 354 End data with lt CR gt lt LF gt lt CR gt lt LF gt C From
37. hat the led will blink every one second This tells the user that the system s time and date are still set correctly else This means that the Real Time Clock has lost power so the time and date need to be set again by the user mySmtp Send fez somedomain1 com recipient somedomain com The date and time are not set The date and dime are not set please set the correct time and date n Indicator StartBlinking 5 50 This will let the led blink fast to tell the user that the time and date are not set mySmtp Send fez somedomain1 com recipient somedomain com FEZ door Monitor has booted up The system booted up at IsTimeSet DateTime Now ToString time is invalid and the door was DoorSensor GetState FEZ_Components Button ButtonState Pressed closed n opened DoorSensor ButtonPressEvent new FEZ_Components Button ButtonPressEventHandler DoorSensor_ButtonPressEvent Thread Sleep Timeout Infinite catch Indicator StartBlinking 100 1000 This means that something wrong has happened and the system is not currently working Thread Sleep Timeout Infinite static void DoorSensor_ButtonPressEvent FEZ_ Pin Interrupt pin FEZ_Components Button ButtonState state if pin DoorSensorPin if state FEZ_Components Button ButtonState NotPressed mySmtp Send fez somedomain1 com recipient somedomain com FEZ Door Monitor The door
38. he GHI NETMF SDK installed and it is usually located at this folder on your PC C Program Files x86 GHI Electronics GHI NETMF v4 1 SDK From the earlier project enter project properties Solution Explorer Zany E a Se f A Solution MFConsoleApplicat ea nls MFConsoleApplication1 Es Build Sa Properties Rebuild 3 References Deploy Program cs Add z El Resources resx Add Reference Set as StartUp Project Debug i Paste Ctrl E X Remove Del Rename MFConsoleApr z Properties Alt Enter ct Folder C Users Gus Is T Setting the Deployment Transport interface is found under the NET Micro Framework tab MFConsoleApplicationl x PRE Program cs Application Configuration Active Debug x Platform Active Build Build Events Deployment Tr Debug Resources Reference Paths Device 4 lt none gt X NET Micro Framework Generate native stubs for internal methods Idco bY Join our community at www TinyCLR com Page 18 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things Going on a Test Drive First plug in FEZ Panda II to your PC using the provided USB cable Do not connect FEZ Panda Il to anything besides the USB cable no shields and no eblocks It is highly recommend to use a powered USB HUB If you do not have one then plug FEZ directly to your PC not through a HUB Once it is connected Windo
39. hernet traffic internally and when you access the internet your data get translated with your external IP Open your PC s command prompt and enter ipconfig You should see your internet connection and determine what is your local network address From the above image you can see that am using WiFi to connect to the router switch with IP address 192 168 1 5 this means my network address is 192 168 1 and my PC s address is 5 am not going to use DHCP and need to make sure am using an IP that is not used by any other device It will probably be safe if assume that address 222 is not RS Join our community at www TinyCLR com Page 29 of 81 Rev 1 20 GHI Electronics _LLC NET amp Internet of Things Going on a Test Drive used by any PC or device since am on a small network in my setup only have my PC my laptop and FEZ We need to write some code now Go back to the last code we created and add GHlElectronics NETMF W5100 dll assembly The Ethernet controller used on FEZ Panda is Wiznet W5100 NET Projects Recent Browse Component Name Version Runtime GHlElectronics NETMF IO 41 3 0 v4 0 30319 GHlElectronics NETMF Native 413 0 v4 0 30319 GHlElectronics NETMF Net 413 0 v4 0 30319 GHlElectronics NETMF SQLite 413 0 v4 0 30319 GHlElectronics NETMF System 413 0 v4 0 30319 GHlElectronics NETMF SystemUpdate 413 0 v4 0 30319 GHlElectronics NETMF USBClient 4 13 0 v4 0 30319 GHIElectron
40. ht intensity Temperature Light Intensity Update Channel volv vlv v 8 8 8 8 ea a gs a8 8 8 amp 3 3 s als als a 2l Once you sign up you ll be redirected to the Channels page Now we need to create a channel that we can publish our data to This is done by clicking Create New Channel which will bring up the channel form For Name let s put FEZ Temp Light and for the Description add Temperature and light intensity Since this project publishes two pieces of data We ll need to use two fields Label Field1 Temperature and then click add field next to Field2 and set it as Light Intensity Finally click Update Channel to save your changes Join our community at www TinyCLR com Page 60 of 81 Rev 1 20 GHI Electronics _LLC NET amp Internet of Things Sensor Monitoring After saving you should land on the channel you created In the data table below is your Write API Th I ngSpeak Key Copy the key value and overwrite the key HOME CHANNELS APPS variable lt YourThingSpeakKey gt in Visual Studio Copy the code below into a project and run it As it Channels Channel 559 runs you will see the Debug Print output every 30 e Edit Channel seconds of the data being sent to ThinkSpeak e Manage API Keys e View Charts Make sure you have the following assemblies in e Import Data references Channel ID 559 Name FEZ Temp Light Write API Key lt Your API Key le Here gt e FEZPanda_ll
41. ics NETMF USBHost 413 0 v4 0 30319 GHlElectronics NETMF W5100 4130 v4 0 30319 Microsoft NET Gadgeteer 1 4 300 0 v2 0 50727 Microsoft NET Gadgeteer MeshRadio 1 4 300 0 v2 0 50727 4 m To initialize the Ethernet controller you need to choose the SPI module connected to Di13 Di12 and Di11 SPI1 SPI_module spI1 on FEZ boards Also you need to choose Di10 as Chip Select and Di7 as W5100 Reset WIZnet_W510 Enable SPI SPI_module SPI1 Cpu Pin FEZ_Pin Digital Di10 Cpu Pin FEZ_Pin Digital Di7 true WIZnet interface with FEZ Connect Then you need to provide the network settings according to your needs static or dynamic settings using DHCP We will use static settings in the following example In the network settings MAC address physical address is needed This is a good tool to generate MAC addresses http www macvendorlookup com Take the LED blinking example and add a new line of code to initialize the Ethernet controller and some code to set FEZ s IP and MAC addresses as explained before Page 30 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things Going on a Test Drive using System using System Threading using Microsoft SPOT using Microsoft SPOT Hardware using GHIElectronics NETMF FEZ using GHIElectronics NETMF Net using GHIElectronics NETMF Net NetworkInformation public class Program public static void Main static Outpu
42. ing Sockets public class Program public static void Main byte mac 0x00 x26 x1C x7B 0x29 OxE8 WIZnet_W5100 Enable SPI SPI_module SPI1 Cpu Pin FEZ_Pin Digital Di10 Cpu Pin FEZ_Pin Digital Di9 true WIZnet interface on FEZ Connect Dhcp EnableDhcp mac FEZ Get the network settings from Dhcp server The user can exchange this with static settings Debug Print Network settings Debug Print IP Address new IPAddress NetworkInterface IPAddress ToString Debug Print Subnet Mask new IPAddress NetworkInterface SubnetMask ToString Debug Print Default Getway new IPAddress NetworkInterface GatewayAddress ToString Debug Print DNS Server new IPAddress NetworkInterface DnsServer ToString Socket socket new Socket AddressFamily InterNetwork SocketType Stream ProtocolType Tcp IPAddress ServerIP new IPAddress new byte 192 168 200 IPEndPoint ServerEndPoint new IPEndPoint ServerIP 12000 byte buf Encoding UTF8 GetBytes Hello World from FEZ Panda socket Connect ServerEndPoint socket Send buf if socket Pol1 5 100000 SelectMode SelectRead wait for data from the server byte inbuf new byte socket Available socket Receive inbuf Debug Print new string Encoding UTF8 GetChars inbuf socket Close oo Join our community at www TinyCLR com Page 40 of 81 Rev 1 20 GHI Electronics LLC NET am
43. ion and add System and System Net libraries and add this code using System using System Collections Generic using System Ling using System Text using System Net Sockets using System Net class Program static void Main string args Socket mySocket new Socket AddressFamily InterNetwork SocketType Dgram ProtocolType Udp IPEndPoint MyServiceEndPoint new IPEndPoint IPAddress Any 2000 mySocket Bind MyServiceEndPoint while true while mySocket Pol1 200000 SelectMode SelectRead if mySocket Available gt byte inBuf new byte mySocket Available EndPoint recEndPoint new IPEndPoint IPAddress Any mySocket ReceiveFrom inBuf ref recEndPoint Console WriteLine Message From IPEndPoint recEndPoint Address ToString Console WriteLine new string Encoding UTF8 GetChars inBuf String msg Hello FEZ Device byte bytesToSend Encoding UTF8 GetBytes msg mySocket SendTo bytesToSend bytesToSend Length SocketFlags None IPEndPoint recEndPoint oo Join our community at www TinyCLR com Page 38 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things FEZ TCP IP Networking Sockets Run this application You will notice that the PC and the device are exchanging the messages as expected Output o Show output from Debug Message Fromi 2 168 6 266 Helio FEZ Vevice peste Poi 192 168 8 208 s essage From z Hello
44. ith code x Capturing We have 155 edges Edge 3412 Edge 1 3301 Edge 2 857 Edge 3 822 Edge 4 857 Edge 5 822 Fdce f RAR Page 77 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things FEZmote Internet TV Remote Signal Playback Another unique feature of GHI s NETMF devices is OutputCompare which helps in generating digital waveforms We want to take the signals recorded earlier and pass it on to OutputCompare for playback The challenge here is in generating the 38KHz carrier frequency This can be done with PWM but then we will need a PWM pin for the carrier plus a free pin for signal Not to worry the OutputCompare has a built in carrier frequency generator In this example code we will use the button to playback the signal If the button is held down for 5 seconds then FEZ goes into recording mode and the LED comes on We will take the same setup from before and add an IrLED eblock to Di8 The steps are simple 1 Press and hold the button eblock for 5 seconds till the Red LED comes on Quickly do the next step as FEZ will timeout in 3 seconds 2 Bring the TV remote and face it to the 32KHz infrared receiver eblock Hit one of the buttons you want to learn 3 Once FEZ learns the one button on the remote then the Red LED shuts off 4 Press and release the button eblock and FEZ will transmit the learned signal using System using System Threading using Microsoft
45. lnet byte command new byte 100 int index using clientSocket clientSocket Send prompt while true if clientSocket Receive command index 1 SocketFlags None clientSocket Close break if command index r do we have some data string cmd new string Encoding UTF8 GetChars command index HandleCommand cmd index clientSocket Send prompt else if command index gt 32 amp amp command index lt 126 Echo back if EchoIsEnabeled clientSocket Send command index 1 SocketFlags None index if index gt command Length Debug Print We have too much data index dump it all We can now use Telnet with a few lines of code This image shows TeraTerm communicating with FEZ hoes Join our community at www TinyCLR com Page 67 of 81 Rev 1 20 NET amp Internet of Things GHI Electronics _LLC FEZ Telnet E Tera Term disconnected VT a ey File Edit Setup Control Window Help Tener Newsommson TCP IP Host 192 168 1 176 W History Service Telnet TCP port 23 SSH SSH version SSH2 5 Soner Protocol Serial Port X 192 168 1 176 Tera Term VT Z gt EchoIsEnabeled True ed on gt LED is now on gt led off gt LED is now off gt E If we want to read the temperature back from the device we will add a command called temp to return
46. mple shows how to send UDP messages with FEZ Connect FEZ will send hello messages to the device with the IP 192 168 1 1 at UDP port 2000 using System using System Threading using Microsoft SPOT using Microsoft SPOT Hardware using GHIElectronics NETMF FEZ using GHIElectronics NETMF Net using GHIElectronics NETMF Net Sockets using GHIElectronics NETMF Net NetworkInformation using System Text using Socket GHIElectronics NETMF Net Sockets Socket public class Program public static void Main byte ip 192 168 1 200 byte subnet 255 255 255 byte gateway 192 168 1 1 byte mac 0x00 x26 x1C Ox7B x29 xE8 WIZnet_W5100 Enable SPI SPI_module SPI1 Cpu Pin FEZ_Pin Digital Di10 Cpu Pin FEZ_Pin Digital Di9 true WIZnet interface setting on FEZ Connect NetworkInterface EnableStaticIP ip subnet gateway mac NetworkInterface EnableStaticDns new byte 192 168 1 1 Socket socket new Socket AddressFamily InterNetwork SocketType Dgram ProtocolType Udp IPAddress DestinationIP new IPAddress new byte 192 168 1 IPEndPoint DestinationEndPoint new IPEndPoint DestinationIP 2000 byte buf OQ 72 Join our community at www TinyCLR com Page 35 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things FEZ TCP IP Networking Sockets for int y y lt 1000 y Thread Sleep 20 b
47. munity at www TinyCLR com Page 7 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things FEZ Ultimate Kit Contents 6x PWM channels 2x CAN channels 4x UART serial ports 2x SPI I2C USB Client USB Host requires minor hardware modifications The Panda Software FEZ Panda packs loads of libraries ready for you to use Some of these libraries are from the core of NETMF and some are GHI exclusive Here is some of the main libraries Threading Memory management Visual Studio Debugging SPI UART serial COM ports I2C CAN OneWire In Field Update Wiznet networking CAN USB Client Customization USB Card reader simulation USB mouse keyboard simulation USB virtual serial port USB Debugging Virtual Serial port eJo Join our community at www TinyCLR com Page 8 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things FEZ Ultimate Kit Contents 4 2 FEZ Internet of Things Kit Contents FEZ Connect Shield This shield plugs right into FEZ Panda and connects you to the outside world It has the circuitry needed to connect to Ethernet and also has eight JST connectors where eblocks can plug right in There are also 2 headers to connect servo motors eblocks are electronics building blocks where each has a specific feature allowing electronics to connect to our physical world From measuring temperature to outputting light The following eblocks come standard with the FEZ Inter
48. net of Things kit but note that there are plenty of other sensors for you to add to your project these sensors can be purchased at http www ghielectronics com catalog category 3 LED There are 3 LEDs included with the kit Red Yellow and Green choos Join our community at www TinyCLR com Page 9 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things FEZ Ultimate Kit Contents Switch An easy way to read an input from a user Temperature sensor This component provides an analog value representing the temperature at the tip of the NTC water resistant thermistor included Temperature measured can be ranging between 20 to 54 degree Celsius This sensor works with any pin with Analog input feature on FEZ Do Join our community at www TinyCLR com Page 10 of 81 Rev 1 20 GHI Electronics _LLC NET amp Internet of Things FEZ Ultimate Kit Contents 38Khz Infrared Receiver This component is used to detect infrared signals of 38kHz carrier The sensor output is logical high when it detects 38kHz frequency otherwise the output is low It can be used to detect the signal sent by the ER 4 Easy Remote not included or most TV remotes IRLED Transmitter Pair this simple IR LED Transmitter with the Infrared Receiver oo Join our community at www TinyCLR com Page 11 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things FEZ Ultimate Kit Contents Light Sen
49. nks http www tinyclr com support This is a list of other resources that should help in your next invention The official FEZ website with all the fun http www tinyclr com GHI blog is always a good place to visit http ghielectronics blogspot com The GHI community wiki http wiki tinyclr com The GHI community code share http code tinyclr com Facebook http www facebook com pages GHI Electronics 201366383211427 Twitter http twitter com GHIElectronics YouTube http www youtube com GHIElectronics A good and free eBook to continue learning about C is available at http www programmersheaven com 2 CSharpBook Microosft s NET Micro Framework community http www netmf com oo Join our community at www TinyCLR com Page 81 of 81 Rev 1 20
50. nnect things to the cloud oo Join our community at www TinyCLR com Page 2 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things Introduction 1 Introduction While the internet is becoming an essential part of our daily life it is also becoming an important part of the devices things we depend on If devices can communicate then they can probably preform better This concept is called The internet of things See wikipedia for more details http en wikipedia org wiki Internet_of_Things and don t forget to watch this video as well http Awww youtube com watch v sfEbMV295Kk But how do we connect to the internet We would need hardware with Ethernet or WiFi interface We also need the low level software that carries out the low level communication over the internet Neither of these is usually simple to accomplish but thanks to NET Micro Framework from Microsoft and the devices and libraries from GHI Electronics connecting devices to the internet is a simple task chr Join our community at www TinyCLR com Page 3 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things Prerequisite 2 Prerequisite This book expects you to have basic knowledge of C and visual studio Not to worry if you don t there is another beginner guide to get you through it all This page is a compilation of key resources and tutorials http www tinyclr com support Not to forget about the very friendly
51. on FEZ Panda ll you will see MOD pin right next to GND pin All we need is a wire in between You can use a metal clip or a jumper as well We are now ready to try FEZ with a serial connection instead of USB Remember that even though you have a USB cable connected to the PC the eblock creates a USB virtual Serial Connection So as far as Windows and its software this is a serial connection Open MFDeploy and select serial instead of USB then check what COM ports are available Let s say we have COM1 COM2 and COM5 Now close MFDeploy disconnect the USB cable from Serial to USB eblock and re open MFDeploy and check the ports again You will notice that one of them is missing That one is then the one we need which is the eblock virtual serial port For example if now have COM1 and COM2 but no longer have COM5 then COM5 is the one associated with the eblock We now can use COM5 in our example to ping FEZ Panda from MFDeploy You should see TinyCLR back just like we did before with USB If not go back and check all steps before proceeding Note that the USB cable going to the eblock doesn t power FEZ Panda so you need to power it up using a power supply or the second USB cable included in the kit Once we can ping FEZ Panda from MFDeploy to verify a good debugging connection copy this code to your project using System using System Threading using System Text using Microsoft SPOT using Microsoft SPOT Hardware using GHIEl
52. ou will notice the mouse moving on the screen You can now hide FEZ Panda behind the PC and then move the mouse remotely from the phone s browser a fun way to drive someone crazy oo Join our community at www TinyCLR com Page 59 of 81 Rev 1 20 GHI Electronics _LLC NET amp Internet of Things Sensor Monitoring 10 Sensor Monitoring BO hincspeak HOME Sign up to start using ThingSpeak User ID Email Time Zone Password Password Confirmation GMT 05 00 Eastern Time US amp Canada Create Account With the Internet of Things catching on so quickly we are starting to see websites that have services dedicated for things A good example is ThingSpeak which is a free website that lets you upload sensor information to the server and then this data can be retrieved or charted later for analysis In this project we will see how to periodically read the thermometer and light sensor eblocks and publish the data to ThingSpeak Y Start by connecting the thermometer eblock to An2 and the light sensor to An3 This is everything we need for hardware but we still need to do some setup on www ThingSpeak com EO inospeak HOME CHANNELS APPS PLUGIN Channels Channel 559 Edit Name Description Tags Latitude Longitude Elevation URL Make Public Field 1 Field 2 Field 3 Field 4 Field 5 Field 6 Field 7 Field 8 o FEZ Temp Light Temperature and lig
53. p Internet of Things FEZ TCP IP Networking Sockets TCP server example This is a simple web server Given a request it returns an HTML document The same document is returned for all requests and no parsing of the request is done This example is based on SimpleServer example code available with NETMF SDK example code This server IP address is 192 168 0 200 and the network ID is 192 168 0 x This server is listening on TCP port 12000 You can change these addresses according to your network settings using System using System Threading using Microsoft SPOT using Microsoft SPOT Hardware using GHIElectronics NETMF FEZ using GHIElectronics NETMF Net using GHIElectronics NETMF Net Sockets using GHIElectronics NETMF Net NetworkInformation using System Text using Socket GHIElectronics NETMF Net Sockets Socket public class Program public static void Main const Int32 c_port 12000 byte ip 192 168 200 byte subnet 255 255 255 byte gateway 192 168 0 1 byte mac x x26 x1C Ox7B x29 xE8 WIZnet_W510 Enable SPI SPI_module SPI1 Cpu Pin FEZ_Pin Digital Di10 Cpu Pin FEZ_Pin Digital Di7 true NetworkInterface EnableStaticIP ip subnet gateway mac NetworkInterface EnableStaticDns new byte 192 168 1 Socket server new Socket AddressFamily InterNetwork SocketType Stream ProtocolType Tcp IPEndPoint localEndPoint new IPEndPoint IPAddress
54. rogram chr Join our community at www TinyCLR com Page 76 of 81 Rev 1 20 GHI Electronics _LLC NET amp Internet of Things FEZmote Internet TV Remote static PinCapture cap new PinCapture Cpu Pin FEZ_Pin Digital Di2 Port ResistorMode Disabled static uint buffer new uint 30e static OutputPort LED new OutputPort Cpu Pin FEZ_Pin Digital Di5 false public static void Main InterruptPort Button new InterruptPort Cpu Pin FEZ_Pin Interrupt Di3 true Port ResistorMode PullUp Port InterruptMode InterruptEdgeLow Add a button event Button OnInterrupt new NativeEventHandler Button_OnInterrupt Thread Sleep Timeout Infinite static void Button_OnInterrupt uint data1 uint data2 DateTime time Debug Print Capturing LED Write true button was pressed int edges cap Read false buffer 0 buffer Length 3000 if edges Debug Print Nothing was captured else Debug Print We have edges for int i i lt edges i edges Debug Print Edge i buffer i LED Write false Microsoft SPOT Debugger CorDebug d1ll Managed Loaded C Prc Microsoft SPOT Debugger CorDebug d11l Managed Loaded C Prc Microsoft SPOT Debugger CorDebug d1ll Managed Loaded C Prc Microsoft SPOT Debugger CorDebug d1ll Managed Loaded C Prc The thread lt No Name gt x2 has exited w
55. rr 1 eJo Join our community at www TinyCLR com Page 26 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things Going on a Test Drive Thread Sleep 10 Making Noise In our coming projects we may need to generate some sounds as an indication of something This is where the Peizo eblock becomes very handy Connect it to a PWM pin and give a frequency of your choice you can even play some melodies In the last fading demo we were playing with the duty cycle but we left the frequency constantly at 10Khz When generating tones we will leave the duty cycle at 50 but we change the frequency Look at the code below do you recognize this code It the the same fading LED code only with a different eblock using System using System Threading using Microsoft SPOT using Microsoft SPOT Hardware using GHIElectronics NETMF Hardware using GHIElectronics NETMF FEZ public class Program static PWM MyPWM new PWM PWM Pin FEZ_Pin PWM DiS public static void Main int i 5000 int dirr 100 while true MyPWM Set i 50 i i dirr if i gt 2000 dirr 1 if i lt 10000 dirr 1 Thread Sleep 1 Try this code and see if you recognize what FEZ is playing OQ 72 Join our community at www TinyCLR com Page 27 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things Going on a Test Drive using System using S
56. sor Use with any analog pin to measure light s intensity Piezo speaker Piezo can be used to generate all kinds of tones Use it as an alarm clock or to play simple melodies Do Join our community at www TinyCLR com Page 12 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things FEZ Ultimate Kit Contents Variable Resistor POT Potentiometers POT for short are variable resistors that change their resistance when the knob is rotated This is similar to the volume control you see on many devices Works with any pin with Analog input feature on a FEZ Serial to USB This eblock instantly converts any COM serial port into a USB connection Windows sees this eblock as a virtual serial port so for Windows applications this is simply a serial port on the system Cables The kit also includes a mini USB Cable for the Serial to USB eblock and an Ethernet Cable irc Rev 1 20 Join our community at www TinyCLR com Page 13 of 81 GHI Electronics _LLC NET amp Internet of Things Going on a Test Drive 5 Going On A Test Drive Note 1 If you are already using GHI s NETMF devices then you can skip this chapter If this is the first time you use GHI NETMF devices then start with this tutorial http wiki tinyclr com index php title First_ Project 5 1 Testing the Emulator Create a new Micro Framework C console project fci Device Emulator Visual C EMX Appli
57. ss NetworkInterface IPAddress ToString Debug Print Subnet Mask new IPAddress NetworkInterface SubnetMask ToString Debug Print Default Getway new IPAddress NetworkInterface GatewayAddress ToString Debug Print DNS Server new IPAddress NetworkInterface DnsServer ToString OQ 72 Join our community at www TinyCLR com Page 33 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things Going on a Test Drive 5 7 We are Ready So far you have tested the functionality of individual components in the system and we are ready to make some fun and exciting projects Remember to always consult the contents of this page for future help and explanations http www tinyclr com support chr Join our community at www TinyCLR com Page 34 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things FEZ TCP IP Networking Sockets 6 FEZ TCP IP Networking Sockets 6 1 User Datagram Protocol UDP UDP is an important member of TCP IP stack It is a simple connectionless protocol For you it means that its communication mechanism is simply sending data to the other peer without verifying whether the data packet is received successfully or not UDP is widely used with services such as DNS DHCP NTP and TFTP Send UDP Message To send UDP messages you define the destination IP address and the destination UDP port For example the DNS service UDP port is 53 This exa
58. static InputPort MyButton new InputPort Cpu Pin FEZ_Pin Digital LDR false OP Join our community at www TinyCLR com Page 21 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things Going on a Test Drive In an endless loop we are reading the button and setting its value to the LED Since an unpressed button is high true and pressed button is low false then the LED will be on when button is not pressed and off when pressed The 10ms delay is added there as a good programming practice There is no reason on why we should use 100 of processor time in a dead endless loop and if the time we press the button to the time the LED change was delayed by 10ms then you will probably not see the difference 5 5 FEZ Connect Shield One of the most popular FEZ Panda add ons is the FEZ Connect shield This shield has Ethernet interface with all its required circuitry and also has connections for eblocks and Servo Motors The two servo connections are connected to PWM capable digital pins Powering a servo requires 6V which should be connected to the Srv Pwr pin This requires little soldering skills This is not explained in the book but the FEZ Connect user manual explains all of this in details Do Join our community at www TinyCLR com Page 22 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things Going on a Test Drive eblocks can be digital or analog and can even require speci
59. t SPOT Hardware public class WAVE int index int dataSize int sampleRate lt summary gt Loads a WAV file ONLY PCM 8 bit Mono lt summary gt lt param name wav gt WAV file bytes lt param gt public WAVE byte wav see https ccrma stanford edu courses 422 projects WaveFormat index if wav index R wav index 1 I wav index 2 F wav index 3 F throw new Exception File is not RIFF index 4 ChunkSize uint ChunkSize Utility ExtractValueFromArray wav index 4 index 4 format if wav index W wav index 1 A wav index 2 v wav index 3 E throw new Exception File is not WAVE format index 4 fmt sub chunk 77 subchunk ID if wav index f wav index 1 m wav index 2 t wav index 3 Do Join our community at www TinyCLR com Page 51 of 81 Rev 1 20 throw new Exception Unexpected fmt subchunk GHI Electronics LLC NET amp Internet of Things Network Controlled Screamer index 4 bool BitVarSampleRate16 uint SubchunkiSize Utility ExtractValueFromArray wav index 4 index 4 if Subchunk1Size 16 BitVarSampleRate16 true else if Subchunk1Size 18 BitVarSampleRate16 false else throw new Exception Invalid Subchunk1iSize ushort
60. t phone can control the satellite receiver Well here is how to make one This project can be divided into smaller parts 1 Learn the original remote signal and record it 2 Replay the recorded signal to simulate the original remote 3 Use a web page to control the signal Part 3 above is very similar to the earlier screamer project will not cover this here but will show you how to record a TV remote signal and how to play it back Digital Signal Recording The TV remotes usually transmit an Infrared signal with a 38KHz carrier frequency The Infrared eblock filters out the carrier giving us the actual remote signal which is exactly what we need FEZ is very well capable of decoding the signal This means FEZ can tell when the mute button is pressed for example This won t be necessary for this project FEZ will record the signal and play it back later without knowing what is in the signal GHI NETMF devices include a class called PinCapture which takes an int array and records the time between any transitions on a pin For the remote demo 100 samples should be enough but let s get 300 samples Here is the code to record the signal on pin Di2 when a button is pressed on Di3 There is also an LED on Did which lights up when FEZ is recording using System using System Threading using Microsoft SPOT using Microsoft SPOT Hardware using GHIElectronics NETMF Hardware using GHIElectronics NETMF FEZ public class P
61. tPort MyLED new OutputPort Cpu Pin FEZ_Pin Digital An3 true byte ip 192 168 1 222 byte subnet 255 255 255 byte gateway 192 168 1 1 byte mac 0x00 0x88 x98 x9 OxD4 OxE WIZnet_W5100 Enable SPI SPI_module SPI1 Cpu Pin FEZ_Pin Digital Di10 Cpu Pin FEZ_Pin Digital Di7 true NetworkInterface EnableStaticIP ip subnet gateway mac NetworkInterface EnableStaticDns new byte 192 168 1 1 while true MyLED Write false Thread Sleep 3 MyLED Write true Thread Sleep 3 The arguments used in the above example match where the W5100 Ethernet controller on FEZ Connect Shield is connected to FEZ Panda We are now ready to run our program which will blink an LED and setup the Ethernet Controller The blinking LED is an indication that the system is up and running While FEZ is running blinking try to ping it from your PC and you should see something like this Ping 192 168 1 222 OP Join our community at www TinyCLR com Page 31 of 81 Rev 1 20 GHI Electronics _LLC NET amp Internet of Things Going on a Test Drive Important If you do not see a response then go back and check your code and setup The next chapters rely on having FEZ Panda being connected to your network Accessing the Internet This is optional but if you have an internet connection you can verify the connection by obtaining GHI s websi
62. te IP address Here is the code You have to make sure that you are using a correct Gateway IP address and DNS server IP address to get internet access using System using System Threading using Microsoft SPOT using Microsoft SPOT Hardware using GHIElectronics NETMF FEZ using GHIElectronics NETMF Net using GHIElectronics NETMF Net NetworkInformation public class Program static OutputPort MyLED new OutputPort Cpu Pin 69 true public static void Main byte ip 192 168 1 222 byte subnet 255 255 255 byte gateway 192 168 1 1 byte mac 0x00 0x88 x98 x9 OxD4 xE WIZnet_W510 Enable SPI SPI_module SPI1 Cpu Pin FEZ_Pin Digital Di10 Cpu Pin FEZ_Pin Digital Di7 true NetworkInterface EnableStaticIP ip subnet gateway mac NetworkInterface EnableStaticDns new byte 192 168 1 1 IPHostEntry GHI_ip Dns GetHostEntry www GHIElectronics com Debug Print GHI s IP GHI_ip AddressList ToString IPHostEntry TinyCLR_ip Dns GetHostEntry www TinyCLR com Debug Print TinyCLR s IP TinyCLR_ip AddressList ToString while true MyLED Write false Thread Sleep 3 MyLED Write true Thread Sleep 3 The code prints this in the output window GHI s IP 207 58 176 212 TinyCLR s IP 207 58 176 213 Do Join our community at www TinyCLR com Page 32 of 81 Rev 1 20 GHI Electronics LLC NET amp
63. to see how we can control the cursor on a PC using an emulated mouse The USB port on FEZ Panda is normally used for deploying and debugging applications The same USB port can be customized in many ways An easy example would be to make this port works as if it was a USB mouse Thanks to the enhanced GHI libraries developers don t need to have any knowledge of USB classes In order for us to use the USB port we first need to switch deploying debugging to serial port The kit includes a Serial to USB eblock which takes a serial port and converts it into a Serial lt gt USB connection on the PC First connect 2 cables from the eblock to FEZ Connect COM1 sockets C1TX socket is COM1 TX pin for example Note that TX pin from the eblock goes to RX pin on FEZ Connect and RX pin on eblock goes to TX pin on FEZ Connect This is shown in this image eJo Join our community at www TinyCLR com Page 55 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things Remote Mouse Prank Connect the USB cable from the eblock to the PC Windows should be able to automatically download and install the drivers If not you can find the drivers at http www ftdichip com FTDrivers htm We now have a serial connection going to the PC but we still need to switch debugging from USB to serial that is virtual USB lt gt serial in our case This is simply accomplished by connecting MODE pin to ground If you look in the middle of the 40 pin header
64. tpListenerResponse response null HttpListenerContext context null try context listener GetContext response context Response We are ignoring the request assuming GET HttpListenerRequest request context Request Sends response response StatusCode int HttpStatusCode 0OK byte HTML Encoding UTF8 GetBytes lt html gt lt body gt lt h1 gt FEZ Panda lt hi gt lt p gt Embedded Systems were never easier lt p gt lt body gt lt html gt response ContentType text html Do Join our community at www TinyCLR com Page 45 of 81 Rev 1 20 GHI Electronics _LLC NET amp Internet of Things FEZ HTTP response OutputStream Write HTML HTML Length response Close catch if context null t context Close To test the server open any web browser on any station connected to the same network and enter this address 192 168 0 200 if you are using a port other than 80 then you need to enter 192 168 0 200 port_number C REOR oo x Google gt I Search gt A A Bar ApCheck FEZ Panda Embedded Systems were never easier anny SRE Join our community at www TinyCLR com Page 46 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things Network Controlled Screamer 8 Network Controlled Screamer In this project we will use use FEZ to activate lights and sounds remotely through a net
65. tpServerName Int32 Port if Port lt throw new ArgumentOutOfRangeException _SmtpServerName SmtpServerName _Port Port public void Send string from string recipient string subject string body state SmtpState NotConnected Connect to the Server Figure out the Server IP Address IPHostEntry SmtpServerHostEntry Dns GetHostEntry _SmtpServerName IPEndPoint SmtpServerEndPoint new IPEndPoint SmtpServerHostEntry AddressList _Port Establish the connection with SMTP Server Socket SmtpConnection new Socket AddressFamily InterNetwork SocketType Stream ProtocolType Tcp SmtpConnection Connect SmtpServerEndPoint String ResponseStr null while SmtpConnection Pol1 5 0000 0 SelectMode SelectRead byte ReceiveBuffer new byte SmtpConnection Available SmtpConnection Receive ReceiveBuffer ReceiveBuffer Length SocketFlags None The first 3 bytes hold the message number which is enough for us ResponseStr new String Encoding UTF8 GetChars ReceiveBuffer 3 int Response Inti6 Parse ResponseStr switch state case SmtpState NotConnected if Response 220 Domain service ready SmtpConnection Send Encoding UTF8 GetBytes HELO from Split new char 1 r n state SmtpState DomainAccepting oo Join our community at www TinyCLR com Page 71 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things You ve got mail and SMS
66. u Pin FEZ_Pin Digital An2 true oo Join our community at www TinyCLR com Page 24 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things Going on a Test Drive Run the program and observe the LED eblock blinking Now can you connect the button eblock to your hardware and control the LED from it All you need to do is copy the code we did before with the on board button LED and change one line of code Fading LED We saw how easy it was to blink an LED but what about fading an LED in and out This can be done using PWM See http www tinyclr com support for PWM tutorials PWM controls the level of energy transferred by switching a pin high and low very quickly where the ratio of the ON to OFF state determines the level For example 50 duty cycle is 50 energy and so on and so forth The PWM feature can be found in GHlElectronics NETMF Hardware dll If you re not sure how to add an assembly then consult http wiki tinyclr com index php title First_ Project Now what pin is PWM capable This is generated by the internal hardware which means the pins will handle the signal with zero processor interaction but this is not available on every single pin Thanks to VS2010 s IntelliSense we can easily see what pins have PWM feature SSMS Debug flan cru Eleve 2h 2 OPGAaQ bject Browser FEZ Panda II Application Program cs X tg Program using GHIElectronics NETMF Hardware using GHIElectronics NE
67. uested mail action okay completed SmtpConnection Close return break SmtpConnection Close throw new Exception SMTP connection Timeout Now we are ready to complete our email based door monitor Here is the complete oo Join our community at www TinyCLR com Page 72 of 81 Rev 1 20 GHI Electronics _LLC NET amp Internet of Things You ve got mail and SMS project s main program using System using System Threading using Microsoft SPOT using Microsoft SPOT Hardware using GHIElectronics NETMF Hardware using GHIElectronics NETMF Net using GHIElectronics NETMF Net NetworkInformation using GHIElectronics NETMF FEZ This application uses the drivers button cs and lcd cs provided by GHI Electronics for faster developing The user can use different methods to read the button such as InterruptPort class and OutputPort Class to control the LED public class Program static public SmtpClient mySmtp static public FEZ_Components Button DoorSensor new FEZ_Components Button FEZ Pin Interrupt Di2 static public FEZ_Pin Interrupt DoorSensorPin FEZ_Pin Interrupt Di2 static public FEZ_Components LED Indicator new static public FEZ_Components LED FEZ_Pin Digital Di8 public bool IsTimeSet false static void Main byte SetTimeFlag helper new byte 4 a simple application to set the time and date RealTimeClock SetTime new DateTime
68. uf Encoding UTF8 GetBytes Hello World from FEZ Panda y ToString try socket SendTo buf DestinationEndPoint catch Receive UDP Messages To receive UDP messages you need to bind to a specific port number so the other peer can find your UDP service through the IP address and that port This example shows how to receive UDP messages with FEZ Connect FEZ will receive UDP messages sent to port 2000 using System using System Threading using Microsoft SPOT using Microsoft SPOT Hardware using GHIElectronics NETMF FEZ using GHIElectronics NETMF Net using GHIElectronics NETMF Net Sockets using GHIElectronics NETMF Net NetworkInformation using System Text using Socket GHIElectronics NETMF Net Sockets Socket public class Program public static void Main byte ip 192 168 1 200 byte subnet 255 255 255 byte gateway 192 168 1 1 byte mac x x26 x1C Ox7B x29 OxE8 WIZnet_W5100 Enable SPI SPI_module SPI1 Cpu Pin FEZ_Pin Digital Di10 Cpu Pin FEZ_Pin Digital Di7 true WIZnet interface setting on FEZ Connect NetworkInterface EnableStaticIP ip subnet gateway mac NetworkInterface EnableStaticDns new byte 192 168 1 1 Socket serversocket new Socket AddressFamily InterNetwork SocketType Dgram ProtocolType Udp EndPoint ServerEndPoint new IPEndPoint IPAddress Any 2000 serversocket Bind ServerEndPoint int
69. ugh PC speakers are perfect for what we need We will use some wires to connect the speakers input connector to An3 which is the analog out pin on FEZ Panda The audio connector for a speaker has different regions where it gets the audio from To read more about it see Wikipedia http en wikipedia org wiki TRS_connector Basically the sleeve is connected to GND on FEZ and the right or left audio channel is connected to the Audio Out on FEZ In the image below the black wire and black clip are connected to ground and the green wire and green clip are connected to the A3 pin i eJo Join our community at www TinyCLR com Page 50 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things Network Controlled Screamer The audio files supported are in wave format 8000 KHz mono These can take a lot of memory so normally you can put them on an SD card or USB thumb drive But we can include a short one in the Visual Studio project s Resources Visual Studio has special handling for Audio resources so you will get errors when you add an audio file To solve this rename the file from scream wav to scream bin The file is found at http www ghielectronics com downloads FEZ scream wav Now you can extract the resource and play it To play the audio files you need a WAVE parser Copy the following code and add into a new file in the same project Name the file WAVE cs using System using Microsoft SPOT using Microsof
70. ur browser using HTTP Hyper Text Transfer Protocol This protocol runs on top of TCP To handle HTTP on FEZ we can either implement HTTP right on top of TCP or use the HTTP services built in FEZ Compare this with the Telnet project in upcoming sections Here is an example that uses HTTP to transfer the HTML code we tested earlier Note how we are listening on port number 80 which is the default HTTP port This FEZ s IP address is 192 168 0 200 and the network ID is 192 168 0 x you can change these addresses according to your network settings using System using System Threading using Microsoft SPOT using Microsoft SPOT Hardware using GHIElectronics NETMF FEZ using GHIElectronics NETMF Net using GHIElectronics NETMF Net Sockets using GHIElectronics NETMF Net NetworkInformation using System Text using Socket GHIElectronics NETMF Net Sockets Socket public class Program public static void Main const Int32 c_port 80 byte ip 192 168 200 byte subnet 255 255 255 byte gateway 192 168 1 byte mac x x26 x1C x7B 9x29 OxE8 WIZnet_W510 Enable SPI SPI_module SPI1 Cpu Pin FEZ_Pin Digital Di10 Cpu Pin FEZ_Pin Digital Di7 true NetworkInterface EnableStaticIP ip subnet gateway mac NetworkInterface EnableStaticDns new byte 192 168 1 HttpListener listener new HttpListener http c_port listener Start while true Ht
71. v index 4 index 4 dataSize int Subchunk2Size TUVALTTAT TTL TATA TAT ATTA EAT A public int GetDataIndex return index public int GetDataSize public int GetSampleRate return dataSize return sampleRate One important note here since we are adding a resource to our project then things can be tricky for beginners due to the namespace of the resource handler and the namespace of the project Here is what we suggest start a new console project and name it FEZscare Then copy paste the code below to your project and add the new WAVE cs file Here s the project code modified to play audio back using System using System Text using Microsoft SPOT using Microsoft SPOT Hardware using GHIElectronics NETMF FEZ using GHIElectronics NETMF Hardware using GHIElectronics NETMF Net using GHIElectronics NETMF Net NetworkInformation public class Program public static void Main byte scare Resources GetBytes Resources BinaryResources scream WAV_playback WAVE wav new WAV_playback WAVE scare AnalogOut audio new AnalogOut AnalogOut Pin FEZ_Pin AnalogOut An3 audio SetLinearScale 255 hos Join our community at www TinyCLR com Page 53 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things Network Controlled Screamer byte ip 192 168 1 176 byte subnet 255 255 255 byte gateway 192 168
72. ve Move Up for example let s get the Up int index move Index0f move move Substring index 1 switch move case Up mouse SendData 10 USBC_Mouse Buttons BUTTON_NONE break case Down mouse SendData 100 USBC_Mouse Buttons BUTTON_NONE break case Right mouse SendData 10 USBC_Mouse Buttons BUTTON_NONE break case Left mouse SendData 100 USBC_Mouse Buttons BUTTON_NONE break case Random mouse SendData 10 USBC_Mouse Buttons BUTTON_NONE Thread Sleep 1 mouse SendData 100 USBC_Mouse Buttons BUTTON_NONE Thread Sleep 10 mouse SendData 100 100 USBC_Mouse Buttons BUTTON_NONE Thread Sleep 1 break oo Join our community at www TinyCLR com Page 57 of 81 Rev 1 20 GHI Electronics _LLC NET amp Internet of Things Remote Mouse Prank Sends response response StatusCode int HttpStatusCode 0K byte HTML Encoding UTF8 GetBytes lt html gt lt body gt lt hl gt oWhat is happening to my mouse lt h1 gt Select lt form action method post gt lt input type radio name Move lt input type radio name Move lt br gt lt input type radio name Move lt br gt lt input type radio name Move lt br gt lt input type radio name Move lt br gt lt br gt lt input type submit value Send gt
73. was opened at IsTimeSet DateTime Now ToString time is invalid n else mySmtp Send fez somedomain1 com recipient somedomain com FEZ Door Monitor oo Join our community at www TinyCLR com Page 74 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things You ve got mail and SMS The door was closed at IsTimeSet DateTime Now ToString time is invalid n Important note The sender s email address should be a real address or the server will refuse to send the message We now can change the email address with the SMS gateway s email and the email will be transmitted as a SMS message What is next 1 Develop an NTP Network Time Protocol client to get the correct time from the internet and feed it to the real time clock 2 Add other kinds of sensors to report other information through emails 3 Add an attachment feature p a Join our community at www TinyCLR com Page 75 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things FEZmote Internet TV Remote 13 FEZmote Internet TV Remote How many times have you looked for the TV remove and you couldn t find it How many remotes do you have in your living room Since you probably own a smart phone which is always in your pocket wouldn t it be great if you could open up the web browser and change the station or the volume on your TV Even better the same smar
74. weecs 5 5 FEZ Connect Shield Document Information OPEM Draca nsanra 5 6 Connecting Ethernet Accessing the Internet Using DAG Pi ocunasirtonsiap naana 5 7 W are IROGGY casscanceneaansceoasecencennsansdenesugtessdeceecessaneesaecnd 6 FEZ TCP IP Networking Sockets 6 1 User Datagram Protocol UDP ccccesseeeeeeeeeeees Send UDP MESSAGE spiare 35 Receive UDP MESSAGE Scrii npon 36 UDP Transceive data with PC sil 6 2 Transmission Control Protocol TCP pres TCP client Cxarmple ccscsscessessces ie TCP server Damplein E 41 re are i EE E E E E E T E E 44 8 Network Controlled Screamer stl 9 Remote Mouse Prank ino MGS SMSO MONLO sasani octscrese creaanausasrcacetaseansdeanebadsedanardaseneanars 60 AGRE Ze TENO kaneron i 65 12 You ve got mail and SMS 69 The program flow 89 What we NOOO cccccisscs secvscciatacwinaersoersecvseptanaceccanesseesai saad 69 What 1S OK ics sssdcsiesscesecaestesenessierncsaecrecsiasarsseneanasoatscns 75 13 FEZmote temet TV REmO tEn esinik 76 Digital Signal Recording 0 sssseccrseecerecsscsssrescereseane 76 DiGhal PIBY DECK sesccascscecsaicsavesecanconasrarennstacaadevaaaszecscaccseees 78 We Neeg Mone icsccnimamiearpinarciareanacenaresses 79 14 Using FEZ Touch QUE 16 WEP oo eciens cscdssscpcarseasinsicsovecsseatercesrarian oreginorcarenctll Abstract This document provides several fun projects on how to co
75. work connection and a simple web page This page can be accessed from a smart phone with a web browser or from any PC s browser on the same network a perfect gadget for Halloween The hosted web page will look like this A D http 1921681 176 1921681176 Hosted on FEZ Panda Il Let s scare some people Activate We will first start with LEDs and use the Piezo eblock to make some noise The next step will be to utilize the audio playback feature to play some scary sounds Here is an image of our first setup eJo Join our community at www TinyCLR com Page 47 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things Network Controlled Screamer The Connections Red LED eblock on Di1 Green LED eblock on Di0 e Yellow LED eblock on Di8 Piezo eblock on Di5 The code is shown below using System using System Threading using System Text using Microsoft SPOT using Microsoft SPOT Hardware using GHIElectronics NETMF FEZ using GHIElectronics NETMF Hardware using GHIElectronics NETMF Net using GHIElectronics NETMF Net NetworkInformation public class Program public static void Main OutputPort red new OutputPort Cpu Pin FEZ_Pin Digital Dil false OutputPort green new OutputPort Cpu Pin FEZ_Pin Digital Di false OutputPort yellow new OutputPort Cpu Pin FEZ_Pin Digital Di8 false PWM piezo new PWM PWM Pin FEZ_Pin PWM DiS b
76. ws will ask for drivers which are found at C Program Files x86 GHI Electronics GHI NETMF v4 1 SDK USB Drivers GHI_NETMF_Interface Now change Transport to USB and you should see USBizi_USBizi under Device Why USBizi The base processor of FEZ Panda is GHI s commercial USBizi chipset View the source code file and try F10 as before but this time the deploying will happen to FEZ Panda instead of the emulator Step in the code and verify that you see Hello world in the output window as before 5 4 The on board LED amp Button LEDs are those little lights you see in about every electronics devices out there They draw very little power extremely cheap and they live almost forever There is an LED right on FEZ Panda but what pin the LED is connected to We could check the circuits schematics but that is not what modern programming is about There is a library an assembly from the GHI SDK that includes all pin definitions Let us add it to our project Right click on your project and select Add Reference Solution Explorer gt 22 E a Solution MFConsoleApplicatior pi F ConsoleApplication1 Build E 1 Properties B References Deploy 8 Program cs Add gt i Resources resx Add Reference Set as StartUp Project Debug rl Paste Ctrl V e ication1 Project Pro X Remove Del Appl Rename E Properties ape File MFConsoleApplic oet Folder C Users Gus
77. ype submit value Activate gt lt form gt lt body gt lt html gt response ContentType text html response OutputStream Write HTML HTML Length response Close catch if context null context Close Create a new project and add the above code to it You will also need to add these assemblies to references FEZPanda_Il_GHlElectronics NETMF FEZ dll e GHlElectronics NETMF Hardware e GHlElectronics NETMF W5100 GHlElectronics NETMF W5100 Http e Microsoft SPOT Hardware e Microsoft SPOT Native e mscorelib hoes Join our community at www TinyCLR com Page 49 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things Network Controlled Screamer You are now ready to run the project on FEZ Once running open a browser on the network and enter your device s IP address This should result in A http 192 168 1 176 1921681176 Hosted on FEZ Panda Il Let s scare some people Activate Note If the page didn t show then your network settings are different Please go back to the earlier chapters and make sure you can network ping the device ping 192 168 x x Click the button on that page and you should see the LEDs blinking and hear some noise coming from the Piezo All is fun but not very scary yet We need to add some scary audio and also use an amplified speakers to make sure the sound is loud eno
78. ystem Threading using Microsoft SPOT using Microsoft SPOT Hardware using GHIElectronics NETMF Hardware using GHIElectronics NETMF FEZ public class Program static PWM MyPWM new PWM PWM Pin FEZ_Pin PWM DiS const int NOTE_C 261 const int NOTE_D 294 const int NOTE_E 330 const int NOTE_F 349 const int NOTE_G 392 const int WHOLE_DURATION 1000 const int EIGHTH WHOLE DURATION 8 const int QUARTER WHOLE_DURATION 4 const int QUARTERDOT WHOLE DURATION 3 const int HALF WHOLE_DURATION 2 const int WHOLE WHOLE_DURATION static int note NOTE_E NOTE_E NOTE_F NOTE_G NOTE_G NOTE_F NOTE_E NOTE_D NOTE_C NOTE_C NOTE_D NOTE_E NOTE_E NOTE_D NOTE_D NOTE_E NOTE_E NOTE_F NOTE_G NOTE_G NOTE_F NOTE_E NOTE_D NOTE_C NOTE_C NOTE_D NOTE_E NOTE_D NOTE_C NOTE_C static int duration QUARTER QUARTER QUARTER QUARTER QUARTER QUARTER QUARTER QUARTER QUARTER QUARTER QUARTER QUARTER QUARTERDOT EIGHTH HALF QUARTER QUARTER QUARTER QUARTER QUARTER QUARTER QUARTER QUARTER QUARTER QUARTER QUARTER QUARTER QUARTERDOT EIGHTH WHOLE public static void Main while true for int i i lt note Length i MyPWM Set note i 50 Thread Sleep duration i Thread Sleep 1 What if we don t have a free PWM pin then how do we use the Piezo Not to worry FEZ can generate all kinds of waveforms using a feature called Output Compare
79. yte ip 192 168 1 176 byte subnet 255 255 255 byte gateway 192 168 1 1 byte mac 0x00 0x88 x98 x9 OxD4 xE WIZnet_W510 Enable SPI SPI_module SPI1 Cpu Pin FEZ_Pin Digital Di10 Cpu Pin FEZ_Pin Digital Di7 true NetworkInterface EnableStaticIP ip subnet gateway mac NetworkInterface EnableStaticDns gateway start server HttpListener listener new HttpListener http 80 listener Start while true HttpListenerResponse response null HttpListenerContext context null try context listener GetContext response context Response The button is pressed if context Request HttpMethod POST oo Join our community at www TinyCLR com Page 48 of 81 Rev 1 20 GHI Electronics LLC NET amp Internet of Things Network Controlled Screamer for int i i lt 10 i piezo Set 1000 50 Thread Sleep 100 piezo Set 100 50 Thread Sleep 100 green Write red Read yellow Write red Read red Write red Read turn of F green Write false yellow Write false red Write false piezo Set false Sends response response StatusCode int HttpStatusCode OK byte HTML Encoding UTF8 GetBytes lt html gt lt body gt lt h1 gt Hosted on FEZ Panda II lt h1 gt lt p gt Let s scare some people lt p gt lt form action method post gt lt input t

Download Pdf Manuals

image

Related Search

Related Contents

MICROSCOPES NUMERIqUES photo/video  Scarica Manuale Italiano Nyne NB-230 Data: 23/10/13 Formato: Pdf  Motores  Furuno BC-6158 User's Manual  TDK Supereta iQM Series User's Manual  Pentax Optio X Digital Camera  www.kegel8.co.uk USER GUIDE  SERVICE MANUAL  取扱説明書 - 新晃工業  

Copyright © All rights reserved.
Failed to retrieve file