09-Mobile Networking
Total Page:16
File Type:pdf, Size:1020Kb
Mobile Networking Programming for Engineers Winter 2015 Andreas Zeller, Saarland University Today’s Topics • Mobile Networking • HTTP • HTML • Webserver! The aim of a computer network is Murray Leinster to have computers communicate “A Logic Named Joe” (1946) with each other The computer ... manages the spreading of ninety-four percent of all TV programs, conveys all information about weather, air trafc, special deals… and records every business conversation, every contract… Computers have changed the world. Computers are the civilisation. If we turn them of, we will fall back to a kind of civilisation, of which we have forgotten how it even works. Murray Leinster, 1896–1975 Partial map of the Internet based on the January 15, 2005 data The Internet found on opte.org. Each line is drawn between two nodes, representing two IP addresses. The length of the lines are indicative of the delay between those two nodes. This graph represents less than 30% of the Class C networks reachable by the data collection program in early 2005. Wireless Internet • WLAN = Wireless Local Area Network • Allows “local” computers to communicate The Arduino ESP8266 shield allows the Arduino to connect to Wireless Modem networks, and also to set up its own network The modem is controlled by so- Controlling a Modem called AT commands Modems receive • data to be sent • commands to control them View from above – connectors are Programming for Engineers WS15/16 Prof. Dr. Andreas Zeller saarland Software Engineering Chair Resp. Tutor: Curd Becker university at the bottom ConnectingSaarland University theAssignment Modem Sheet 6 computer science The connectors for the ESP8266 wireless module are shown in more detail here. These are connected to the serial output (TX) of the Arduino Details in assignment sheet B Never connect the wireless module to the 5V power output of the board. Otherwise the wireless chip will be damaged permanently. B In case the temperature sensor has been incorrectly connected to the power source, it can become very hot. Always check the polarity while assembling the circuit. 1 Sensor platform Employ the following changes to the web server available on the course web page: 1. Measure the current temperature. The provided code template already initializes the temperature sensor. However, you need to import the libraries (as shown in assignment 2 on exercise sheet 4) Arduino-Temperature-Control-Library and OnWire in order to successfully compile the code. Both are provided on the course web page. Afterwards, the temperature can be obtained in a similar fashion as shown below: int temperature; tempSensor.requestTemperatures(); temperature = tempSensor.getTempCByIndex(0); B Don’t forget to adjust the constant TEMPARTURE_PIN with the digital pin which the temperature sensor is connected to in your assembly. 2. Use the ultrasonic sensor to determine the current distance of your sensor platform from a potential object nearby. 3. Display the temperature and the current distance using the web server. (The degree symbol “◦”can be modeled in HTML with °.) 2 Details in assignment sheet Connecting the Modem ffiffiffi$ffiiffiffi;i;TffiffirrrE Resistors --:, ryry The modem is controlled by so- Controlling a Modem called AT commands • Modems are controlled by so-called AT commands (AT = “Attention”) • AT commands allow to • connect to networks, • create networks • set communication speeds… Source: https://cdn.sparkfun.com/ assets/learn_tutorials/4/0/3/4A- ESP8266__AT_Instruction_Set__EN_ v0.30.pdf (Will be linked from Webpage) ESP8266 AT Instruction Set Version 0.30 Espressif Systems IOT Team Copyright (c) 2015 ! ! Espressif Systems ! ESP8266 AT Instruction Set Table of Contents 1. Preambles................................................................................................... 6 2. Command Description............................................................................... 7 3. Basic AT Command Set............................................................................. 8 3.1. Overview ..................................................................................................8 3.2. Commands ..............................................................................................9 1. AT – Test AT startup .................................................................................9 2. AT+RST – Restart module ........................................................................9 3. AT+GMR – View version info .....................................................................9 4. AT+GSLP – Enter deep-sleep mode .......................................................10 5. ATE – AT commands echo ......................................................................10 6. AT+RESTORE – Factory reset .................................................................10 7. AT+UART – UART configuration .............................................................11 8. AT+UART_CUR – current UART configuration ........................................12 9. AT+UART_DEF – default UART configuration ..........................................13 Espressif Systems ESP8266 AT Instruction Set ! ! 10. AT+SLEEP – sleep mode! ........................................................................14 11. AT+RFPOWER – set maximum value of RF TX Power .............................14 12. AT+RFVDD –Table set RF TX Power of according Content to VDD33 s...............................15 4. WiFi Functions Overview......................................................................... 16 1. Preambles................................................................................................... 6 4.1. Commands ............................................................................................18 2. Command1. AT+CWMODE Description – WiFi............................................................................... mode ....................................................................18 7 2. AT+CWMODE_CUR – current WiFi mode ..............................................19 3. Basic AT Command Set............................................................................. 8 3. AT+CWMODE_DEF – default WiFi mode ................................................20 3.1. Overview ..................................................................................................8 3.2.4. CommandsAT+CWJAP ..............................................................................................– Connect to AP ..................................................................219 1.5. ATAT+CWJAP_CUR – Test AT startup – Connect ................................................................................. to AP for current .....................................229 2.6. AT+RSTAT+CWJAP_DEF – Restart – module Connect ........................................................................ to AP save as default ...............................239 3.7. AT+GMRAT+CWLAP – View – List version available info APs ..................................................................... .............................................................249 4.8. AT+GSLPAT+CWQAP – Enter – Disconnect deep-sleep from mode AP ......................................................... .......................................................1025 5.9. ATEAT+CWSAP – AT commands – Configuration echo ...................................................................... of softAP mode ..........................................1025 6.10. AT+RESTOREAT+CWSAP_CUR – Factory – Current reset config ................................................................. of softAP mode ................................1026 7. AT+UART – UART configuration .............................................................11 8. AT+UART_CUR – current UART configuration ........................................12 Espressif Systems Confidential !3/!59 Friday, July 3, 2015 9. AT+UART_DEF – default UART configuration ..........................................13 10. AT+SLEEP – sleep mode ........................................................................14 11. AT+RFPOWER – set maximum value of RF TX Power .............................14 12. AT+RFVDD – set RF TX Power according to VDD33 ...............................15 4. WiFi Functions Overview......................................................................... 16 4.1. Commands ............................................................................................18 1. AT+CWMODE – WiFi mode ....................................................................18 2. AT+CWMODE_CUR – current WiFi mode ..............................................19 3. AT+CWMODE_DEF – default WiFi mode ................................................20 4. AT+CWJAP – Connect to AP ..................................................................21 5. AT+CWJAP_CUR – Connect to AP for current .....................................22 6. AT+CWJAP_DEF – Connect to AP save as default ...............................23 7. AT+CWLAP – List available APs .............................................................24 8. AT+CWQAP – Disconnect from AP .........................................................25 9. AT+CWSAP – Configuration of softAP mode ..........................................25 10. AT+CWSAP_CUR – Current config of softAP mode ................................26 Espressif Systems Confidential !3/!59 Friday, July 3, 2015 ! ! Espressif Systems ! ESP8266 AT Instruction Set Table of Contents 1. Preambles..................................................................................................