Home

4 Sending requests using the Wifi Block

image

Contents

1. Gives the date UNIX like timestamp Returns the GET status Bit 0 Port ready 0 KO 1 OK Bit 1 Reserved Bit 2 Send request 1 send Bit 3 Request done 1 done Bit 6 4 Reserved Bit 7 Request error 1 error Returns the Wifi status Bit 0 Enable Wifi 0 dis 1 en Bit 1 Wifi save config 1 save Bit 2 Start scan 1 start Bit 3 Scan done 0 busy 1 done Bit 4 Wifi status 1 connected Bit 5 Disable Rs232 debug 1 no Rs232 Bit 6 Re connexion 0 dis 1 en Bit 7 Wifi erase config 1 erase Returns the Http last response code 3 bytes Returns the number of Wifi connection retry Return the length of the last data received from a GET request Returns the IP address of the last GET request Returns the port of the last GET request Returns the URL of the last GET request the part after IP address that you enter in the data field see the GET request paragraph Returns the last data received from a GET request Humarobotics Making your personal robot smarter Data Read Post Status 23 lon Returns the POST status Bit 0 Port ready 0 KO 1 OK Bit 1 Reserved Bit 2 Send request 1 send Bit 3 Request done 1 done Bit 4 Enable Dataflash Storage Bit 5 Enable Dataflash Retransmission Bit 6 Reserved Bit 7 Request error 1 error Read Post Length 24 Return the length of the last data transmitted by a
2. If you get a unable to reach the destination host down for your WifiBlock S22 Linux Launch a command prompt and run the ifconfig command This command displays the network configuration of your computer and the parameters of your network Find the wireless connection settings and write down your default gateway the value for your network mask and the IP address of the computer You now need to find a free IP address that will be attributed to the WifiBlock Build a new IP address by taking your computer s IP and replacing the last number by another number between 1 and 255 Then type ping and this IP in your command prompt If the ping command gives an answer Ctrl C to stop the command this IP address is already in use so choose another one Humarobotics Making your personal robot smarter Page 8 If you get a unable to reach the destination host answer the IP address is free so write it down for your WifiBlock 3 2 3 Mac Launch a terminal located in Applications Utilities then type the ifconfig command IP addresses are on lines that start by inet to get only these lines you can type ifconfig grep inet Find the line that looks like inet 192 168 1 20 netmask Oxffffff00 broadcast 192 168 1 1 The IP address will be between inet and netmask Warning there will always be a line with the 127 0 0 1 IP which is your machine loopback address that yo
3. 1 3 A Robot PC connection As seen in the two previous examples the WifiBlock creates a true bridge between the robot and connected computer enabling unprecedented capabilities for the Lego Mindstorms NXT robot like long distance remote control with sensor return Humarobotics Making your personal robot smarter Page 4 2 Comparison between Wifi and other wireless communication technologies 2 1 Bluetooth By default the Lego Mindstorms NXT smart brick offers a wireless connection It is the Bluetooth technology The Wifi has several critical advantages compared to the Bluetooth e The bandwidth Wifi allows to transmit more data up to 11Mbps theoretical max to be compared with the 460 kbps maximum rate for NXT Bluetooth http www tau ac il stoledo lego btperformance html The WifiBlock being a low power embedded system its maximum bandwidth is 1Mbps a value that is way enough for the NXT e The range The Bluetooth present on the NXT has a 10m range only The Wifi range is much better up to 300 or 400m according to the norms and the surrounding environment and in addition if we consider that the WifiBlock equipped robot can communicate over the internet this range is no longer a limitation 2 2 XBee Xbee is a radio protocol with a bandwidth that is better than the Bluetooth but is still out of reach of the Wifi Even if the Xbee range is more important it only remains a point to point connection with no TCP IP co
4. This address has been determined in the previous step using the ping command This is the addressing mask for your IP address This is the one that we discovered using the ipconfig or ifconfig command The value of this mask depends on your network configuration Humarobotics Making your personal robot smarter Page 10 O N This is the IP address of your network router in the case of a personal network it is often the IP address of your modem or Wifi router This address has also been discovered using the ipconfig or ifconfig command This is the name of the wifi network you are going to connect to This is the name that you see when hovering the Wifi Icon on your computer if of course it is connected to a Wifi network JIa This is the encryption and authentication protocol for your Wifi network OPEN No Security and no encryption Your network is entirely open and anyone or any device can connect to it WEP fixed key encryption It is a basic setting for many networks WPA More secure than the WEP security setting WPA2 2 version of the WPA setting offering advanced security Please make sure to select the right security mode to connect the WifiBlock Any error at this stage will result in a connection error as the various encryption modes are not compatible LESS This is the password or passphrase of your Wifi network Please refer to the documentation provided with your Wifi router or modem He
5. LED shuts down while the green one still blinks showing a connection attempt Once connected the green LED stays on stable The orange LED will blink if the WifiBlock receives or emits information To see this try to ping your WifiBlock using its IP address in your computer s command prompt and you will see the orange LED blink Connection time depends on your Wifi encryption When there is no security OPEN network connection is quick On the contrary if you have a strongly secured network like WPA2 connection time can increase up to 30 seconds because the calculation of the encrypted key takes more resources and time 3 4 Advanced functionality of the WifiBlockUtils block The WifiBlockUtils block offers other possibilities than writing the Wifi configuration on the WifiBlock The DebugLogs box allows you to ask the NXT Brick to store logs in a file that you can retrieve for debug purpose see Troubleshooting section 3 4 1 The Wifi State action This action allows you to do some actions on the WifiBlock once it is configured Enable Wi fi checked wifi enabled Auto reconnection if connection lost checked auto reconnection activated Humarobotics Making your personal robot smarter Page 12 Actions Description EraseConfig Erase the saved Wifi configuration checked config will be erased Table 2 Wifi state actions WifiBlock Utils LE Por O 02 03 Oa CEN Wii
6. OND C z Action Wifi State Auto O Debuglogs O EraseConfig www humarobotics com WifiBlock 1 0 Figure 12 The Wifi State configuration panel 3 4 2 Write Wifi Config with dynamic parameters In the previous example we hard coded the Wifi configuration But if you want some setting to depend from what happened previously in your program you can dynamically change the parameters using the block s data hub To open the data hub ofa block click on its lower edge You get access to the following settings Number 1 help 2 Write Wifi Config 3 Wifi State 4 Read WifiBlock Value to Read Number Value to be read in the WifiBlock registers see next paragraph Security Number 0 Open 1 WEP 2 WPA 3 WPA2 SSID Text The Wifi network name Password Text The Wifi network password IILE LI Numbers IP address divided into 4 numbers eo WES WN Numbers IP mask divided into 4 numbers MSK3 MSK4 CAVE eis Numbers Gateway divided into 4 numbers GW3 GW4 Wifi On Boolean Wifi enabled A E S Boolean Auto reconnection enabled Save Boolean The Wifi configuration will be saved EraseConfig Boolean _ Wifi configuration will be erased DebugLogs Boolean Debug logs enabled Table 3 Data accessible by the WifiBlockUtils data hub Humarobotics Making your personal robot smarter Page 13 3 4 3 The Read WifiBlock action When you choose th
7. POST request Read Post IP 25 Returns the IP address of the last POST request Read Post Port 26 Returns the port of the last POST request Read Post URL 27 Returns the URL of the last POST request the part after IP address that you enter in the data field see the GET request paragraph Read Post Data 28 Returns the last data transmitted by a POST request Read UDP Status 29 Returns the UDP status Bit 0 Port enable 0 dis 1 en Bit 1 Send Tx data 1 send Bit 2 Send Tx done 1 done Bit 3 Rx data ready Bit 4 Rx data read Bit 6 5 Reserved Bit 7 Send error 1 error Read UDP dest IP 30 Returns IP address for UDP Read UDP dest port Ey Returns destination port for UDP Read UDP src port 32 Returns source port for UDP Read UDP Tx Data 33 Length Returns the length of the Tx data Read UDP Tx Data 34 Returns the Tx data Read UDP Rx Data 35 Length Returns the length of the Rx data Read UDP Rx Data 36 Returns the Rx data Read TCP status 37 Returns the TCP status Bit 0 Port ready 0 KO 1 OK Bit 1 Send request 1 send Bit 2 Request done 1 done Bit 6 3 Reserved Bit 7 Send error 1 error Read TCP IP 38 Returns IP address for TCP Read TCP port 39 Returns port for TCP Read TCP Tx Data 40 Length Returns the length of the Tx data Read TCP Tx Data 41 Returns the Tx da
8. VOC USSU n sac coana adi Da la d a 22 Bi TW SS TOU A cea set dota oi ea nl da Ei ati eae aes 23 6 Appendix import NXT G DIOS i555 ecen oaia ala ec cala ae 25 7 Appendix upload a file from the NXT Brick cscsssseseseseeeseessecesecesecesesesseeceesesesenenenes 27 8 Appendix Regulatory notice and Warning ien e i pol inecat 28 Humarobotics Making your personal robot smarter Page 2 1 Introduction to the WifiBlock The WifiBlock for Lego Mindstorms NXT is a standalone enclosure containing an electronic board with a Wifi device Useful features are 1 Two leds one green and one orange 2 ANXT compatible female connector 3 An ON OFF switch Figure 1 Overview of the WifiBlock The WifiBlock is powered by 3 AA LR6 batteries not supplied that must be inserted into the WifiBlock as shown on the battery hatch marking Figure 2 Battery hatch The WifiBlock connects to your Lego Mindstorms NXT brick enabling it to have a complete TCP IP connectivity with an access to the internet With such equipment your NXT robot will be able to send data to a computer over the internet or receive information from this computer Let s introduce some use case for the WifiBlock Humarobotics Making your personal robot smarter Page 3 Webpage to control the motors connected to the NXT G block to configure the network login PWD NXT Brick and IP address Webpage to store and use data
9. humarobotics com You have to be sure that the server answers if called by its IP address particularly in the case of virtual hosts To test this you can call the IP address in your web browser and see if you get an answer for example http 88 190 16 18 won t give you an error 4 1 2 Using the result of a request To visualize the return data from the GET request you can use a Display block so the return data will be displayed on the NXT Brick s screen Drag and drop a Display block after the WifiBlockCommunication one Then connect the Buffer output from the WifiBlockCommunication block to the 7ex input of the Display one like in the figure 14 You can also retrieve the http response code using the HttpCode output 7ex output It should be 200 if the request was successful Your web server can also return you other values to inform you about potential errors 404 when the requested document was not found for example Check this page to interpret other codes http en wikipedia org wiki List of HTTP status codes The two other outputs are Error Boo ean type telling you if any error occurred and DataLength Number type containing the length in byte of the request s result In the configuration panel of the Display block choose Text from the Action dropdown menu Humarobotics Making your personal robot smarter Page 18
10. the radio and telecommunications terminal equipment Wifi Alliance The module is certified under Wi Fi 802 11 with WPA2 WPA and WEP System Interoperability ASD Model Test Plan with Test Engine For IEEE 802 11a b and g Devices Version 1 0 Manufacturer identification G n ration Robots 1 Rue Th odore Blanc B timent L 33520 Bordeaux Cedex France T l phone 33 5 56 39 37 05 Humarobotics Making your personal robot smarter Page 29
11. DP transmission previously launched ends Returns 1 when data are available after a UDP reception Returns 1 if an error occurred after a UDP operation Returns 1 if the TCP port is ready available Returns 1 when a TCP operation ends Returns 1 if an error occurred during a TCP operation Returns 1 when a DataFlash write operation ends Returns 1 when a DataFlash read operation ends Returns 1 if an error occurred during the last DataFlash operation Table 6 Data accessible by the Read Wifi Block action 5 2 The debug logs All the NXT G blocks allowing using the WifiBlock have a checkbox called DebugLogs When this box is checked a file names WifiBlockLogs txt will be created on your NXT block and all the operations that are performed by the WifiBlock will be logged and available for further analysis You ll only have to download this file on your computer from NXT G as explained in the dedicated appendix Note Debug Logs written on your NXT robot can take space in the memory When debugging is not needed think to disable the DebugLogs feature by unticking the associated box in your NXT G programs Humarobotics Making your personal robot smarter Page 24 6 Appendix import NXT G blocks To import new blocks to your block palette follow these steps e In NXT G the graphical programming environment for Lego Mindstorms open Tools Block Import and Export Wizard The fol
12. Other and Program to see the contents WifiBlockLogs b Try Color rtm Figure 22 NXT window with Memory tab Select the file you want to retrieve and click on the Upload button A window will ask you where to save in on your computer From this tab you can also delete or download files from your computer to the NXT Brick Humarobotics Making your personal robot smarter Page 27 8 Appendix Regulatory notice and warning The product named WifiBlock and sold under the commercial brand of HumaRobotics has been designed using a wireless module that has received regulatory approval in the United States Canada European countries and Japan No changes or modification were made to the module and the product design strictly follows the manufacturer s integration guidelines The integrated module regulatory approval status is the following USA Contains FCC ID W70ZG2100 ZG2101 This device complies with Part 15 of the FCC Rules Operation is subject to the following two conditions 1 this device may not cause harmful interference and 2 this device must accept any interference received including interference that may cause undesired operation This equipment has been tested and found to comply with the limits for a Class B digital device pursuant to part 15 of the FCC Rules These limits are designed to provide reasonable protection against harmful interference in a residential installation This equipment gen
13. Sr Acton tle sit EE Display amp Ces prea Figure 14 Data transmission between the WifiBlockCommunication block and the Display one The problem with this is that you won t have time to see what is displayed on the brick screen because the program will stop right after displaying the result This is a classic problem with NXT G Therefore you will have to add a Wait block after the Display one to have some time to visualize your GET request s result In the configuration panel of the Wait block select time in the Control dropdown menu and set the number of seconds you want for example 10 in the Until field Finally you get this program Humarobotics Making your personal robot smarter Page 19 Cont te ds 5S uri Seconds 10 Figure 15 NXT G code displaying on the brick screen the result of a http GET request Download and run your program from the command panel Note In some network configuration it has been shown that the first requests succeed but return a blank result DataLength and Data 0 This behavior can be avoided by performing several requests 5 at the minimum 4 2 Sending a POST request using the Wifi Block A POST request allows you to send data to a server You can do your request the same way as the GET request but you have an additional field at your disposal the Post data field In this field you can enter all the data
14. ation you can dynamically set the parameters for your requests by using the data hub The available parameters are pe Description Number The NXT port where the WifiBlock is connected Number 1 GET request 2 POST request 3 UDP Tx 4 UDP Rx 5 TCP Tx 6 TCP RX IP1 Number First part of the IP address IP2 Number Second part of the IP address IP3 Number Third part of the IP address IP4 Number Fourth part of the IP address dstPort Number The port used for connection URL Text The additional data html page with parameters that will be added after IP address PostData Text The data to transmit when you use the POST request Rey Boolean The logs will be stored in a file on the brick for debug purpose Table 5 Description of the WifiBlockCommunication data hub fields Like for any data hub in NXT G you can retrieve this data unchanged as output of the hub There several outputs that are Buffer HTTPCode Error and DataLength respectively returning the received data the HTTP code received from the server a potential errors and finally the length of the received data Humarobotics Making your personal robot smarter Page 22 5 Troubleshooting In this part we will show you some possibilities to debug your programs understand what went wrong during communication and hopefully what to do to repair it First check that the port on witch you plugged the WifiBlock o
15. coming from the sensors connected to the NXT Brick We provide with the Wifiblock a simple html page that the user can install on his own web server to do data logging locally create a csv file USB connection NXT G block to make a get post http request on any URL and to parameter the answer Using this block the user can create his own webpage Figure 3 Use case for the WifiBlock 1 1 Data logging The data logging is a function consisting in saving on a file for example a dataset of measures made by a system Once saved these measurements are available for further analysis or visualization In the case of the Lego robot it can be sensor measurements for example ultrasounds telemeters data Data logging can of course be made directly on the Lego Brick writing a local file that will be stored in the memory The main advantage brought by the WifiBlock is the ability to send data almost in real time to a computer that can use much more memory and computational power A graphical visualization or more complex analysis could then be performed by the computer using the data received from the Lego robot for example to build a representation of the robot environment 1 2 Remote control In this case the computer sends information to the Lego Brick using the WifiBlock connection It is possible to design a control interface on a computer and to send control commands to the robots over the wireless network
16. configuration panel allows you to choose the action to be done Select GET request to make a GET http request on the internet Like for the previous block it is important to correctly configure the connection port The right part of the panel contains the following fields IP The IP web server on which you want to make the request dstPort The destination port used for connection The default port for internet communication is 80 Humarobotics Making your personal robot smarter Page 17 URL character chain that will be placed after IP address containing html page or any kind of extension you want to call including parameters You can check the DebugLogs box so your WifiBlock will store logs in a file in the NXT Brick for debug purpose For example if you wish to call http 88 190 16 18 data php sku 23 amp tr 47 webpage you divide the URL into the IP part 88 190 16 18 for the IP address and the additional data and parameters here data php sku 23 amp tr 47 Your configuration panel will look like below LE Por 01 z 3 O84 IP ss 190 16 18 dstPort 80 Action GET request URL data php sku 238tr 47 Debuglogs O WifiBlock 1 0 www humarobotics com Figure 13 Configuration panel of the WifiBlockCommunication to do a Get request on http 88 190 16 18 data php sku 23 amp tr 47 To know the IP address of a website you can ping in from your command prompt ping www
17. e ReadWifiBlock action you have read access to all values saved in the WifiBlock Select one using the Value to read dropdown menu The data will be accessible in the Buffer output of the data hub with a 7ext data type The following table describes the accessible data The numbers correspond to the numbers you have to enter in the Value to read field of the data hub see previous paragraph Data Read Version Read Product ID Read Sensor Type Read Voltage Read Mac Read IP Read IP Mask Read Gateway Read SSID Read Security Read Passphrase Read Get Result Read Date Read Get Status Read Wifi Block Status Read HTTP response Read WifiRetryNb Read Get Length Read Get IP Read Get Port Read Get URL Read Get Data Description ss Returns the firmware version Returns the product ID should be HRWB Returns the Sensor Type Should return WIFI Returns 10 times the battery voltage Don t forget to divide this value by 10 to get the real voltage Returns the MAC address of the WifiBlock works only if the WifiBlock is connected to a network Returns the configured IP address Returns the IP mask of the Wifi network Returns the gateway of the Wifi network Returns the SSID of the Wifi network Returns the Wifi security type OPEN WEP WPA WPA2 Returns the password of the Wifi configuration Returns the result of the latest GET request
18. e communication link and it incorporates data acknowledgement verification and retransmission mechanisms These ensure a reliable ordered delivery of the data It is the most used protocol for internet applications 4 3 2 UDP transmission and reception Remark At the time of the writing only GET POST and TCP requests are available with NXT G blocks a new block with UDP requests will be released very soon Please check www humarobotics com 4 3 3 TCP transmission and reception Similarly to the GET and POST requests you need to drag and drop a WifiBlockComm NXT G block and make sure set the port field to the one you have plugged the WifiBlock to In the Action field select the TCP request option You can now define the parameters of your TCP request First set the IP address of the TCP server you are connecting to Then specify the destination port of your request for this you need to know which port the server is running on For example standard port numbers are 80 for HTTP 21 for FTP 23 for Telnet a detailed list can be found here http www iana org assignments service names port numbers service names port numbers xml In the URL field you can specify the data that you want to transmit to the server which is not an actual URL but can be any data Its size is limited to 32 bytes Humarobotics Making your personal robot smarter Page 21 4 4 Parameterized requests Like for the Wifi configur
19. erates uses and can radiate radio frequency energy and if not installed and used in accordance with the instructions may cause harmful interference to radio communications However there is no guarantee that interference will not occur in a particular installation If this equipment does cause harmful interference to radio or television reception which can be determined by turning the equipment off and on the user is encouraged to try to correct the interference by one or more of the following measures e Reorient or relocate the receiving antenna e Increase the separation between the equipment and receiver e Connect the equipment into an outlet on a circuit different from that to which the receiver is connected e Consult the dealer or an experienced radio TV technician for help To satisfy FCC RF Exposure requirements for mobile and base station transmission devices a separation distance of 20 cm or more should be maintained between the antenna of this device and persons during operation To ensure compliance operation at closer than this distance is not recommended The antenna s used for this transmitter must not be co located or operating in conjunction with any other antenna or transmitter Canada Contains IC 8248A G21ZEROG Humarobotics Making your personal robot smarter Page 28 Europe CE The product is herewith conformed to comply with the requirement of Directive 1999 5 EC of the Council European Parliament on
20. lowing window appears Figure 17 Block import and export wizard e With the Browse button select the folder where the source code of your block lies i e where you unzipped the folders you downloaded from the Humarobotics website containing the blocks presented in this documentation The name of the found block is displayed in the list of blocks to import e Select in the Add Blocks to Palette dropdown menu in which palette you want to import your blocks e The Import button becomes clickable only when you select the block to import from the blocks list Humarobotics Making your personal robot smarter Page 25 Figure 18 Import wizard before importation e Click on the Import button e The Status text is updated to Import successful Figure 19 Import successful Do this for each block you want to import or update Humarobotics Making your personal robot smarter Page 26 7 Appendix upload a file from the NXT Brick With your NXT Brick connected to your computer and switched on click on the NXT Window button Figure 20 The NXT Window button A new window will open showing information on connected devices Find your Brick and you can See its name battery level and firmware version Connected Figure 21 NXT window Go to the Memory tab to access to the documents inside your Brick Click on the names of the different sections here Unused
21. n the NXT Brick and the port you parameterized in your blocks are the same because it is a very common mistake 5 1 The WifiBlockQuery block This block can be downloaded on the Humarobotics website and should be imported into your NXT G software following the procedure described in appendix Using this block you can ask a set of questions to your WifiBlock and receive Boolean yes no responses This allows you to check if your WifiBlock sends and receive information correctly and to precise where a problem can be The DebugLogs box allows you to ask the brick to store logs in a file for debug purpose The list of available questions is the following uestion i n rror on GET port Returns 1 if an error occurred at the last GET request rror on POST port 2 Returns 1 if an error occurred at the last POST request Returns 1 if an error occurred at the last UDP transaction Returns 1 if an error occurred at the last TCP transaction Returns 1 if an error occurred at the last DataFlash operation read or write Returns 1 if the Wifi is enabled 0 if it is disabled Use the WifiBlockUtils block to enable or disable the Wifi Scan in progress If 1 scanning for Wifi please wait Should not last more than 50 seconds Wifi connected Returns 1 if the WifiBlock is connected to a wireless network If the value is 9 you should check the parameters used in the WifiBlockUtils block and make sure that your Wifi netwo
22. nnectivity and the lack of internet connection To learn more on the Xbee modules for Lego Mindstorms NXT please refer to http www generationrobots com wireless communication module nxtbee pro dexter industries mindstorms nxt us 4 NXTBeePRO cfm Humarobotics Making your personal robot smarter Page 5 3 Connecting and configuring the WifiBlock 3 1 First step connect the WifiBlock Make sure that the 3 batteries are correctly inserted in the WifiBlock Connect the WifiBlock using a standard Lego Mindstorms cable to one of the sensors ports of the Mindstorms These ports are labeled from 1 to 4 Figure 4 Connection between the Lego Mindstorm Brick and the WifiBlock Warning Never connect the WifiBlock to one of the motor ports A B and C ports The voltage on these connectors is not suitable and could do irreversible damages your WifiBlock 3 2 Second step Find out your network parameters The WifiBlock doesn t offer a DHCP feature that would allow it to automatically obtain an IP address from your wireless router Therefore you will have to configure your WifiBlock to allow it to communicate with your Wifi network by providing the following information An IP address for the WifiBlock A network mask A default gateway The login for your Wifi network The password for your Wifi network The following paragraphs will explain you step by step how to find these information 3 2 1 Windows Humarobotic
23. re again make sure that you have entered the right password Table 1 IP configuration data fields Enter the parameters you determined during step two If you check the Save box your Wifi configuration will be saved and will remain until you choose to modify it Therefore when you shut down your WifiBlock and then switch it on again it will try to connect directly to the Wifi using the previous configuration Once all the parameters are entered make sure that the NXT brick is switched on and connected to your computer using the USB cable and that the WifiBlock is also switched on and plugged to the correct sensor port Then click on the play button of NXT G in order to launch the compilation of the program and the transmission to your NXT brick i Figure 10 Download and run button at the center of the command panel of NXT G In order to check with your configuration has been sent to the WifiBlock and if it has successfully connected to your network you have to look at the LEDs placed on the side of the block Humarobotics Making your personal robot smarter Page 11 w a Not connected ei Ej Connecting H Connected D E Transmitting data External LED Internal LED Switch Figure 11 Visualization of the connection state with LEDs When you switch your WifiBlock on the two LEDs blink alternatively showing that the device is not connected Once you inject the IP configuration the orange
24. rk is up and running Re connection enabled Returns 1 if the automatic re connection is enabled In this case your WifiBlock automatically reconnects after a Wifi connection loss GET port ready Returns 0 if the WifiBlock is doing a GET request Returns 1 if the port is ready GET request done Returns 1 when a previously launched GET request ends GET request error Returns 1 if an error occurred during a GET request POST port ready Returns 0 if the WifiBlock is doing a POST request Returns 1 if the port is ready Humarobotics Making your personal robot smarter Page 23 Question POST request done POST request error Dataflash storage enabled Dataflash enabled retransmit UDP port enabled UDP Tx done UDP data ready UDP send error TCP port ready TCP request done TCP send error Dataflash write done Dataflash read done Dataflash error Returns 1 when a previously launched POST request ends Returns 1 if an error occurred during a POST request Returns 1 if the automatic storage is enabled In case of loss of Wifi connectivity your request will be automatically stored in the internal DataFlash Returns 1 if the retransmission is enabled In case of Wifi connectivity loss your request will be automatically stored in the DataFlash and transmitted when the Wifi is retrieved Returns 1 is the UDP port is enabled Returns 1 if a U
25. s Making your personal robot smarter Page 6 Launch a command prompt by entering cmd in the program panel of your computer windows button R to get the program panel Enter the ipconfig command This command displays the network configuration of your computer and the parameters of your network as shown in the example below Was C Windows system3Acmdene sex Figure 5 Ipconfig command result Find the wireless connection settings and write down your default gateway in our example 192 168 1 1 as well as the value for your network mask 255 255 255 0 in the screenshot above The IP address of the computer in our example is 192 168 1 20 You now need to find a free IP address that will be attributed to the WifiBlock Build a new IP address by taking your computer s IP and replacing the last number by another number between 1 and 255 Then type ping and this IP in your command prompt If the ping command gives an answer Ctrl C to stop the command this IP address is already in use so choose another one The ping command followed by an IP address performs a request on your request to lookup if device is already using this IP address If no reply is returned this means that the device is not connected to the network or that no device on the network is using this IP address This is what we are looking for Humarobotics Making your personal robot smarter Page 7 s de donn es thi tne
26. ta Read TCP Rx Data 42 Length Returns the length of the Rx data Read TCP Rx Data 43 Returns the Rx data Humarobotics Making your personal robot smarter Data Read DEI 44 Status cription Returns the Dataflash status Bit 0 Write data 1 write Bit 1 Write done 1 done Bit 2 Read data 1 read Bit 3 Read done 1 done Bit 6 4 Reserved Bit 7 Dataflash error DECK 45 Return the Dataflash address Table 4 Data accessible by the Read Wifi Block action Humarobotics Making your personal robot smarter Page 16 4 Sending requests using the Wifi Block In this part we describe how the WifiBlock asks and gets a piece of information on the web 4 1 Sending a GET request using the Wifi Block A GET request asks data from an internet resource using its URL 4 1 1 Using the WifiBlockCommunication block to send a GET request If you haven t done it already import the WifiBlockComm NXT G block and drag and drop it on a worksheet like in the screenshot below J LEGO MINDSTORMS NXT retetei TEANO N Te 88 CI Untities 1 Need help Move the cursor over an object to read about its function For G additional help dick the More help link wwnw humarobotics com WifiBlock 1 0 Figure 12 The WifiBlockCommunication NXT G block This block works in the same way as the WifiBlockUtils used before The
27. te appendix of this document or to the NXT G user manual in order to know how to add third party blocks to NXT G Humarobotics Making your personal robot smarter Page 9 Need help 4 n n Move the cursor over an abject to read about its function For G For help documentation examples and much additional help dick the More help link Visit us at www humarobotics com For all your NXT related needs nanaratinnrahate ram This block allows writing the IP configuration of the WifiBlock used to make a connection to your network To enter the parameters choose Write Wifi Config from the Action dropdown menu You ll then see the panel displaying various parameters that have to be filled out O1 O2 3 IP1 192 L 168 lac gt IP Mask 255 Write Wifi Config Gateway 192 168 Debuglogs O SSID Security www humarobotics com WifiBlock 1 0 Password Figure 9 Configuration panel for the WifiBlock The data to be filled out are described in the following table Number of the Port on the NXT where the WifiBlock is plugged Make sure that you have set up this to the correct value as it is a very common mistake Drop down menu allowing to choose the action that will be performed by the WifiBlock In our case we have selected Write Wifi Config as we want to provide connection information to the WifiBlock This is the IP address that we want to assign to the WifiBlock
28. u should not take into account for wifi connection Write down your computer s IP address in our example 192 168 1 20 your default gateway in our example 192 168 1 1 and the value for your network mask Oxffffff00 equivalent to 255 255 255 0 if you divide the hexadecimal number by groups of two digits and convert them to decimal numbers You now need to find a free IP address that will be attributed to the WifiBlock Build a new IP address by taking your computer s IP and replacing the last number by another number between 1 and 255 Then type ping and this IP in your command prompt If the ping command gives an answer this IP address is already in use so choose another one If you get a unable to reach the destination host answer the IP address is free so write it down for your WifiBlock 3 3 Third step Configuring the WifiBlock Now that you have determined your network parameters you have to provide to the WifiBlock the information in order to allow it to connect to your network Launch NXT G the programming environment for Lego Mindstorms To configure the WifiBlock and allow it to connect to the web we are going to use the block called WifiBlockUtils You can find this block as well as the WifiBlock Communication and the WifiBlock Query ones that we will use later on the Humarobotics website here You will need to download them and to import them into NXT G Please refer to the appropria
29. ws HumaRobotics Wifi Block Table of content 1 Tntrod ctiorito the VAM EI CDI iei atitea ag tent ae eye cane ne mene tenet een e a ee 3 ys Data logging saene e aons na i ere eee alta ee eee a 4 12 Remote CD IEI loiali ea Di ee eee pa ee te data ca a 4 13 A RODOIRPC CONNECTION nii R E 4 2 Comparison between Wifi and other wireless communication technologies 5 Dal MAGS TO OG acca cee deea cada Ea case ct Data oh A ata ic ada aia pda 5 A2 ABCE IE IRINEI CREIER E ION NP ARII SR E NIRO PIERE E PRR DRINA NEI PREPRINT CR ei 5 3 Connecting and configuring the WifiBloCk cic isessseccsssescasssnessscsearscerencteconsdenesaacisasceceneoscessaassicves 6 3 1 Firststep connect the WifiBlOCK aescaa eat noa a aleasa 6 3 2 Second step Find out your network parameterS esesscseseceseccecesseeererererseeneneees 6 3 3 Third step Configuring the WITTE OK sei apei de ati e 9 3 4 Advanced functionality of the WifiBlockUtils block 0 0 eeeeeeeeeeeessteteenteteteeeeeees 12 4 Sending requests using the Wifi BOCK cases samanta a 17 4 1 Sending a GET request using the Wifi BIOCk ieseau eu a Bg ao d a i a 17 4 1 1 Using the WifiBlockCommunication block to send a GET request s 17 4 1 2 Using theresult ofa regut apoase 052000 a ol ca lt oa 18 4 2 Sending a POST request using the Wifi BIOCK scie oo oa La a i d a i d 20 4 3 UDP and TCP data transmission and reception using the Wifi BIOCK eects 21 4 4 P rameterized
30. you want to transmit to the server encoded in application x www form urlencoded type You have several key value pairs with possibly duplicate keys the key being separated from the value by The character amp is used to separate key values pairs and for spaces other non alphanumeric characters being encoded with URL encoding See http en wikipedia org wiki POST HTTP for an example Humarobotics Making your personal robot smarter Page 20 The data in the Post data field will be included in the message body whereas a GET request only sends a message header and a URL m _ 190 16 ie Port 0 Action POST request Data data php Debuglogs O aaa WifiBlock 0 1 Name Jonathan Doe amp Age 238Formula a 2E www humarobotics com Figure 16 The WifiBlockCommunication block configured for a POST request 4 3 UDP and TCP data transmission and reception using the Wifi Block 4 3 1 Usages of UDP and TCP The User Data Protocol UDP and the Transmission Data Protocol TCP are both core protocols of the Internet Protocol Suite the set of network protocols used for the internet UDP is the simplest protocol It does not require establishing the communication link or acknowledging data reception Therefore it is quick but unreliable data can arrive out of order duplicated or be missing without notice TCP is a bit slower as it first needs three packets to establish th

Download Pdf Manuals

image

Related Search

Related Contents

Virtual Surround Sound USB Audio Adapter  5571 756A Thank you for purchasing this INNO product.  251061 benchpro QRC 25June10.indd  High Capacity Solar Charger and Battery with Flashlight  Contents    中学校教科書のエネルギー記述に関する提言  RCA S2102 User's Manual  Sony BDV-IS1000/C Marketing Specifications  Evaluación de higiene por Bioluminiscencia - DePa  

Copyright © All rights reserved.
Failed to retrieve file