{"id":33,"date":"2021-01-08T18:20:13","date_gmt":"2021-01-08T23:20:13","guid":{"rendered":"https:\/\/pressbooks.bccampus.ca\/vahidnia\/?post_type=chapter&#038;p=33"},"modified":"2021-04-06T15:46:44","modified_gmt":"2021-04-06T19:46:44","slug":"chapter-3","status":"publish","type":"chapter","link":"https:\/\/pressbooks.bccampus.ca\/cellulariot\/chapter\/chapter-3\/","title":{"raw":"Chapter 3: TCP\/IP AT Commands","rendered":"Chapter 3: TCP\/IP AT Commands"},"content":{"raw":"<h1>3.1 Introduction<\/h1>\r\nIn this chapter, we would like to connect the BG96 board to the Internet to send and receive data. For this purpose, the BG96 board needs to establish a TCP\/IP connection to a server. This can be done by using a software program such as SocketTest to enable the computer to act as a server. The configuration used in this lab is shown in Figure3.1.\r\n\r\n[caption id=\"attachment_73\" align=\"aligncenter\" width=\"824\"]<img class=\"wp-image-73 \" src=\"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/16.-BG96-connection-to-the-Internet.jpg\" alt=\"\" width=\"824\" height=\"195\" \/> Figure3.1. BG96 connection to the Internet[\/caption]\r\n\r\nFor the BG96 board to communicate with the server installed on the computer, the BG96 board sends the data to the IP address of the computer. If the computer is installed behind a Network Address Translation (NAT) router like the ones in most homes and offices, the computer may use an internal address. For proper communication to take place, the NAT router needs to work well and proper port forwarding needs to be configured.\r\n\r\nQuectel BG96 module can access to the Internet using the embedded TCP\/IP stack and AT Commands. The module supports services for UDP client\/server and TCP client\/server. In this lab, the BG96 module will act as a TCP client and connects to a TCP server to exchange data.\r\n<h1>3.2 Practical tasks<\/h1>\r\nTo start using TCP\/IP AT Commands, first you need to configure the parameters of the context such as the APN, username, and password. Second, the Packet Data Protocol (PDP) context which is is the connection between the modem and the end address is activated. Third, you will start a socket service to exchange data. Finally the socket service is closed and PDP context is deactivated.\r\n<h2>A.\u00a0 Configure your PC as TCP\/IP server<\/h2>\r\nIn this part of the lab, you will set up a TCP\/IP server on your computer to be able to communicate with the BG96 module.\r\n<ol>\r\n \t<li>Go to \u201cControl panel\u201d-&gt;\u201dWindows Defender Firewall\u201d. Click on \u201cTurn Windows Defender Firewall on or off\u201d and turn off Windows Firewall or any third party firewall such Norton's or hardware firewall.<\/li>\r\n<\/ol>\r\n[caption id=\"attachment_74\" align=\"aligncenter\" width=\"369\"]<img class=\"wp-image-74 \" src=\"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/17.-Windows-defender.jpg\" alt=\"\" width=\"369\" height=\"327\" \/> Figure3.2. Windows defender[\/caption]\r\n<ol start=\"2\">\r\n \t<li>To allow remote access to your PC, go to \u201cControl Panel\u201d -&gt; \u201cSystem\u201d-&gt;\u201dRemote settings\u201d. In the \u201cRemote\u201d tab select \u201cAllow remote connections to this computer\u201d.<\/li>\r\n<\/ol>\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n[caption id=\"attachment_75\" align=\"aligncenter\" width=\"353\"]<img class=\"wp-image-75 \" src=\"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/18.-Allow-remote-connections.jpg\" alt=\"\" width=\"353\" height=\"372\" \/> Figure3.3. Allow remote connections[\/caption]\r\n<ol start=\"3\">\r\n \t<li>To create a TCP\/IP server, download and run SocketTest[footnote]http:\/\/sockettest.sourceforge.net\/[\/footnote]. Click on \u201cServer\u201d tab and enter a number (e.g., 350) as your port number. Click \u201cStart Listening\u201d.<\/li>\r\n<\/ol>\r\n[caption id=\"attachment_76\" align=\"aligncenter\" width=\"315\"]<img class=\"wp-image-76 \" src=\"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/19.-SocketTest-v-3.0.0.jpg\" alt=\"\" width=\"315\" height=\"262\" \/> Figure3.4. SocketTest v 3.0.0[\/caption]\r\n<ol start=\"4\">\r\n \t<li>In order to obtain the IP address of your computer and the default gateway, press Windows R to\u00a0open\u00a0\u201cRun\u201d box. Type \u201ccmd\u201d and then click \u201cOK\u201d to\u00a0open\u00a0a Command Prompt.<\/li>\r\n \t<li>In Command Prompt type \u201cipconfig\u201d to get the IPv4 Address and Default Gateway (i.e., the IP address of the router) in the form of xxx.xxx.xxx.xxx. In our example as it shown below \u201cIPv4 Address = 192.168.1.64\u201d and \u201cDefault Gateway = 192.168.1.254\u201d<\/li>\r\n<\/ol>\r\n[caption id=\"attachment_77\" align=\"aligncenter\" width=\"493\"]<img class=\"wp-image-77 \" src=\"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/20.-Command-Prompt.jpg\" alt=\"\" width=\"493\" height=\"283\" \/> Figure3.5. Command Prompt[\/caption]\r\n<ol start=\"6\">\r\n \t<li>Go to \u201cGoogle\u201d and search for \u201cmy public IP address\u201d. This is the IP address of your ISP router available to the rest of the Internet. Alternatively, you can go to <a href=\"https:\/\/canyouseeme.org\/\">https:\/\/canyouseeme.org\/<\/a> and find your public IP address.<\/li>\r\n<\/ol>\r\n[caption id=\"attachment_78\" align=\"aligncenter\" width=\"581\"]<img class=\"wp-image-78 \" src=\"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/21.-Public-IP-address.jpg\" alt=\"\" width=\"581\" height=\"187\" \/> Figure3.6. Public IP address[\/caption]\r\n\r\nThe Default Gateway is the IP address of the interface of your ISP router connected to your PC. IPv4 address is the private IP address given to your PC by the router. Since the private IP address is not addressable from outside your network, using \u201cport forwarding\u201d, you can tell your router where to direct traffic for a specific port on your PC. In other words, port forwarding allows a remote computer on a different network (e.g., BG96 module) to connect to your PC on a private network and run a service behind the router.\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n[caption id=\"attachment_79\" align=\"aligncenter\" width=\"845\"]<img class=\"wp-image-79 \" src=\"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/22.-Network-architecture.jpg\" alt=\"\" width=\"845\" height=\"213\" \/> Figure3.7. Network architecture[\/caption]\r\n<ol start=\"7\">\r\n \t<li>Go to your internet browser and in the address bar type in the \u201cDefault Gateway\u201d which was 192.168.1.254 in our example. You may also find the Default Gateway address on your WiFi-Router security tag. Enter the Username\/Password for your router to log in. Note that depending on your router you may see a different interface.<\/li>\r\n<\/ol>\r\n[caption id=\"attachment_80\" align=\"aligncenter\" width=\"879\"]<img class=\"wp-image-80 \" src=\"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/23.-Router-login-page.jpg\" alt=\"\" width=\"879\" height=\"382\" \/> Figure3.8. Router login page[\/caption]\r\n<ol start=\"8\">\r\n \t<li>To make the service port available to the Internet, you need to set up port forwarding using the IPv4 address (192.168.1.64) and Port number (350) in your router so that your ISP does not block the port as shown in Figure3.9.<\/li>\r\n \t<li>To verify that the port is open and your ISP does not block it, go to <a href=\"http:\/\/www.canyouseeme.org\">www.canyouseeme.org<\/a>, enter your public IP address and port number and click \u201cCheck Port\u201d. Make sure the server you created in SocketTest is listening at that port; otherwise, you will see that the port is closed as shown in Figure3.10.<\/li>\r\n<\/ol>\r\n[caption id=\"attachment_81\" align=\"aligncenter\" width=\"601\"]<img class=\"wp-image-81 \" src=\"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/24.-Port-forwarding-example.jpg\" alt=\"\" width=\"601\" height=\"467\" \/> Figure3.9. Port forwarding example[\/caption]\r\n\r\n&nbsp;\r\n\r\n[caption id=\"attachment_82\" align=\"aligncenter\" width=\"383\"]<img class=\"wp-image-82 \" src=\"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/25.-Verify-port-is-open.jpg\" alt=\"\" width=\"383\" height=\"235\" \/> Figure3.10. Verify port is open[\/caption]\r\n<h2>B.\u00a0 Configure BG96 module as TCP\/IP client<\/h2>\r\nIn this part of the lab, you will set up a TCP client connection to enter into buffer access mode. BG96 TCP\/IP AT Commands Manual[footnote]https:\/\/www.quectel.com\/UploadImage\/Downlad\/Quectel_BG96_TCP(IP)_AT_Commands_Manual_V1.0.pdf[\/footnote] has the full list and description of different modes and commands required for TCP\/IP connections.\r\n<ol start=\"10\">\r\n \t<li>Open \u201cTera Term\u201d and use the APN provided by the SIM carrier (e.g., m2m-west.telus.iot) to configure a context via AT Commands.<\/li>\r\n<\/ol>\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td><strong>AT QICSGP=1,1,\"M2M-WEST.TELUS.IOT\",\"\",\"\",1\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0<\/strong><em>\/\/ Set the your mobile carrier APN\u00a0 <\/em>\r\n\r\nOK<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<ol start=\"11\">\r\n \t<li>Activate the context and query the state of the context and IP address of the module. <strong>AT QIDEACT=1<\/strong> can be used to deactivate a context.<\/li>\r\n<\/ol>\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td><strong>AT QIACT=1\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/strong><em>\/\/ Activate a context<\/em><em>\u00a0 <\/em>\r\n\r\nOK\r\n\r\n&nbsp;\r\n\r\n<strong>AT QIACT?\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/strong><em>\/\/ query the context state<\/em><em>\u00a0 <\/em>\r\n\r\nQIACT: 1,1,1,\"10.200.109.166\"\r\n\r\nOK<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<ol start=\"12\">\r\n \t<li>Set up a TCP client connection using your PC public IP address (e.g., 172.218.32.19) and port number (e.g., 350). If the connection is successful \u201c QIOPEN: 0,0\u201d will be returned and SocketTest will show the new client IP address.<\/li>\r\n<\/ol>\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td><strong>AT QIOPEN=1,0,\"TCP\",\"172.218.32.19\",350,0,0\u00a0\u00a0\u00a0 <\/strong><em>\/\/ Set up a TCP client connection using your own public IP address<\/em>\r\n\r\nOK\r\n\r\n&nbsp;\r\n\r\nQIOPEN: 0,0<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<h2>C.\u00a0 Send and receive data using BG96 module<\/h2>\r\n<ol start=\"13\">\r\n \t<li>Enter the AT Command below and type in your text. Then press CTR Z to send it. The received text should be shown on SocketTest.<\/li>\r\n<\/ol>\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td><strong>AT QISEND=0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/strong><em>\/\/ Send changeable length data. After text press CTR Z to send.<\/em>\r\n\r\n&gt; Hello, this is a test\r\n\r\nSEND OK<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<ol start=\"14\">\r\n \t<li>When you reply using SocketTest, the module will show QIURC: \"recv\",0 which means a message has been received in the buffer. To read the buffer, type in <strong>AT QIRD=0,1500<\/strong>.<\/li>\r\n<\/ol>\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td>QIURC: \"recv\",0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <em>\/\/ Send changeable length data. After text press CTR Z to send.<\/em>\r\n\r\n<strong>AT QIRD=0,1500<\/strong>\r\n\r\nQIRD: 30\r\n\r\nHi, I received your message.\r\n\r\n&nbsp;\r\n\r\nOK<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<ol start=\"15\">\r\n \t<li>Close the connection using <strong>AT QICLOSE=0<\/strong>.<\/li>\r\n<\/ol>\r\nThe instructions above explained how to establish a TCP client connection using the BG96 module. If you are interested, referring to BG96 TCP\/IP AT Commands Manual[footnote]https:\/\/www.quectel.com\/UploadImage\/Downlad\/Quectel_BG96_TCP(IP)_AT_Commands_Manual_V1.0.pdf[\/footnote] you can try establishing UDP client, TCP server and UDP server connections.\r\n\r\nD.\u00a0\u00a0 Connectivity to the Internet\r\n\r\nTo check the connectivity between BG96 board and the Internet, we send ping commands. Since ping uses TCP\/IP connection, the success of the command below shows that your board is capable of making TCP\/IP connection and you can check the connectivity.\r\n\r\n<strong>AT QPING=1, \u201cwww.bcit.ca\u201d<\/strong>\r\n<div>\r\n<div>\r\n\r\n&nbsp;\r\n\r\n<\/div>\r\n<\/div>","rendered":"<h1>3.1 Introduction<\/h1>\n<p>In this chapter, we would like to connect the BG96 board to the Internet to send and receive data. For this purpose, the BG96 board needs to establish a TCP\/IP connection to a server. This can be done by using a software program such as SocketTest to enable the computer to act as a server. The configuration used in this lab is shown in Figure3.1.<\/p>\n<figure id=\"attachment_73\" aria-describedby=\"caption-attachment-73\" style=\"width: 824px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-73\" src=\"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/16.-BG96-connection-to-the-Internet.jpg\" alt=\"\" width=\"824\" height=\"195\" srcset=\"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/16.-BG96-connection-to-the-Internet.jpg 2301w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/16.-BG96-connection-to-the-Internet-300x71.jpg 300w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/16.-BG96-connection-to-the-Internet-1024x242.jpg 1024w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/16.-BG96-connection-to-the-Internet-768x182.jpg 768w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/16.-BG96-connection-to-the-Internet-1536x363.jpg 1536w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/16.-BG96-connection-to-the-Internet-2048x484.jpg 2048w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/16.-BG96-connection-to-the-Internet-65x15.jpg 65w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/16.-BG96-connection-to-the-Internet-225x53.jpg 225w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/16.-BG96-connection-to-the-Internet-350x83.jpg 350w\" sizes=\"auto, (max-width: 824px) 100vw, 824px\" \/><figcaption id=\"caption-attachment-73\" class=\"wp-caption-text\">Figure3.1. BG96 connection to the Internet<\/figcaption><\/figure>\n<p>For the BG96 board to communicate with the server installed on the computer, the BG96 board sends the data to the IP address of the computer. If the computer is installed behind a Network Address Translation (NAT) router like the ones in most homes and offices, the computer may use an internal address. For proper communication to take place, the NAT router needs to work well and proper port forwarding needs to be configured.<\/p>\n<p>Quectel BG96 module can access to the Internet using the embedded TCP\/IP stack and AT Commands. The module supports services for UDP client\/server and TCP client\/server. In this lab, the BG96 module will act as a TCP client and connects to a TCP server to exchange data.<\/p>\n<h1>3.2 Practical tasks<\/h1>\n<p>To start using TCP\/IP AT Commands, first you need to configure the parameters of the context such as the APN, username, and password. Second, the Packet Data Protocol (PDP) context which is is the connection between the modem and the end address is activated. Third, you will start a socket service to exchange data. Finally the socket service is closed and PDP context is deactivated.<\/p>\n<h2>A.\u00a0 Configure your PC as TCP\/IP server<\/h2>\n<p>In this part of the lab, you will set up a TCP\/IP server on your computer to be able to communicate with the BG96 module.<\/p>\n<ol>\n<li>Go to \u201cControl panel\u201d-&gt;\u201dWindows Defender Firewall\u201d. Click on \u201cTurn Windows Defender Firewall on or off\u201d and turn off Windows Firewall or any third party firewall such Norton&#8217;s or hardware firewall.<\/li>\n<\/ol>\n<figure id=\"attachment_74\" aria-describedby=\"caption-attachment-74\" style=\"width: 369px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-74\" src=\"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/17.-Windows-defender.jpg\" alt=\"\" width=\"369\" height=\"327\" srcset=\"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/17.-Windows-defender.jpg 835w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/17.-Windows-defender-300x266.jpg 300w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/17.-Windows-defender-768x680.jpg 768w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/17.-Windows-defender-65x58.jpg 65w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/17.-Windows-defender-225x199.jpg 225w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/17.-Windows-defender-350x310.jpg 350w\" sizes=\"auto, (max-width: 369px) 100vw, 369px\" \/><figcaption id=\"caption-attachment-74\" class=\"wp-caption-text\">Figure3.2. Windows defender<\/figcaption><\/figure>\n<ol start=\"2\">\n<li>To allow remote access to your PC, go to \u201cControl Panel\u201d -&gt; \u201cSystem\u201d-&gt;\u201dRemote settings\u201d. In the \u201cRemote\u201d tab select \u201cAllow remote connections to this computer\u201d.<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_75\" aria-describedby=\"caption-attachment-75\" style=\"width: 353px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-75\" src=\"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/18.-Allow-remote-connections.jpg\" alt=\"\" width=\"353\" height=\"372\" srcset=\"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/18.-Allow-remote-connections.jpg 537w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/18.-Allow-remote-connections-285x300.jpg 285w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/18.-Allow-remote-connections-65x68.jpg 65w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/18.-Allow-remote-connections-225x237.jpg 225w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/18.-Allow-remote-connections-350x368.jpg 350w\" sizes=\"auto, (max-width: 353px) 100vw, 353px\" \/><figcaption id=\"caption-attachment-75\" class=\"wp-caption-text\">Figure3.3. Allow remote connections<\/figcaption><\/figure>\n<ol start=\"3\">\n<li>To create a TCP\/IP server, download and run SocketTest<a class=\"footnote\" title=\"http:\/\/sockettest.sourceforge.net\/\" id=\"return-footnote-33-1\" href=\"#footnote-33-1\" aria-label=\"Footnote 1\"><sup class=\"footnote\">[1]<\/sup><\/a>. Click on \u201cServer\u201d tab and enter a number (e.g., 350) as your port number. Click \u201cStart Listening\u201d.<\/li>\n<\/ol>\n<figure id=\"attachment_76\" aria-describedby=\"caption-attachment-76\" style=\"width: 315px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-76\" src=\"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/19.-SocketTest-v-3.0.0.jpg\" alt=\"\" width=\"315\" height=\"262\" srcset=\"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/19.-SocketTest-v-3.0.0.jpg 576w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/19.-SocketTest-v-3.0.0-300x250.jpg 300w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/19.-SocketTest-v-3.0.0-65x54.jpg 65w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/19.-SocketTest-v-3.0.0-225x188.jpg 225w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/19.-SocketTest-v-3.0.0-350x292.jpg 350w\" sizes=\"auto, (max-width: 315px) 100vw, 315px\" \/><figcaption id=\"caption-attachment-76\" class=\"wp-caption-text\">Figure3.4. SocketTest v 3.0.0<\/figcaption><\/figure>\n<ol start=\"4\">\n<li>In order to obtain the IP address of your computer and the default gateway, press Windows R to\u00a0open\u00a0\u201cRun\u201d box. Type \u201ccmd\u201d and then click \u201cOK\u201d to\u00a0open\u00a0a Command Prompt.<\/li>\n<li>In Command Prompt type \u201cipconfig\u201d to get the IPv4 Address and Default Gateway (i.e., the IP address of the router) in the form of xxx.xxx.xxx.xxx. In our example as it shown below \u201cIPv4 Address = 192.168.1.64\u201d and \u201cDefault Gateway = 192.168.1.254\u201d<\/li>\n<\/ol>\n<figure id=\"attachment_77\" aria-describedby=\"caption-attachment-77\" style=\"width: 493px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-77\" src=\"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/20.-Command-Prompt.jpg\" alt=\"\" width=\"493\" height=\"283\" srcset=\"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/20.-Command-Prompt.jpg 1098w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/20.-Command-Prompt-300x172.jpg 300w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/20.-Command-Prompt-1024x588.jpg 1024w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/20.-Command-Prompt-768x441.jpg 768w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/20.-Command-Prompt-65x37.jpg 65w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/20.-Command-Prompt-225x129.jpg 225w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/20.-Command-Prompt-350x201.jpg 350w\" sizes=\"auto, (max-width: 493px) 100vw, 493px\" \/><figcaption id=\"caption-attachment-77\" class=\"wp-caption-text\">Figure3.5. Command Prompt<\/figcaption><\/figure>\n<ol start=\"6\">\n<li>Go to \u201cGoogle\u201d and search for \u201cmy public IP address\u201d. This is the IP address of your ISP router available to the rest of the Internet. Alternatively, you can go to <a href=\"https:\/\/canyouseeme.org\/\">https:\/\/canyouseeme.org\/<\/a> and find your public IP address.<\/li>\n<\/ol>\n<figure id=\"attachment_78\" aria-describedby=\"caption-attachment-78\" style=\"width: 581px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-78\" src=\"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/21.-Public-IP-address.jpg\" alt=\"\" width=\"581\" height=\"187\" srcset=\"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/21.-Public-IP-address.jpg 980w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/21.-Public-IP-address-300x96.jpg 300w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/21.-Public-IP-address-768x247.jpg 768w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/21.-Public-IP-address-65x21.jpg 65w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/21.-Public-IP-address-225x72.jpg 225w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/21.-Public-IP-address-350x113.jpg 350w\" sizes=\"auto, (max-width: 581px) 100vw, 581px\" \/><figcaption id=\"caption-attachment-78\" class=\"wp-caption-text\">Figure3.6. Public IP address<\/figcaption><\/figure>\n<p>The Default Gateway is the IP address of the interface of your ISP router connected to your PC. IPv4 address is the private IP address given to your PC by the router. Since the private IP address is not addressable from outside your network, using \u201cport forwarding\u201d, you can tell your router where to direct traffic for a specific port on your PC. In other words, port forwarding allows a remote computer on a different network (e.g., BG96 module) to connect to your PC on a private network and run a service behind the router.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_79\" aria-describedby=\"caption-attachment-79\" style=\"width: 845px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-79\" src=\"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/22.-Network-architecture.jpg\" alt=\"\" width=\"845\" height=\"213\" srcset=\"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/22.-Network-architecture.jpg 1276w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/22.-Network-architecture-300x75.jpg 300w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/22.-Network-architecture-1024x258.jpg 1024w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/22.-Network-architecture-768x193.jpg 768w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/22.-Network-architecture-65x16.jpg 65w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/22.-Network-architecture-225x57.jpg 225w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/22.-Network-architecture-350x88.jpg 350w\" sizes=\"auto, (max-width: 845px) 100vw, 845px\" \/><figcaption id=\"caption-attachment-79\" class=\"wp-caption-text\">Figure3.7. Network architecture<\/figcaption><\/figure>\n<ol start=\"7\">\n<li>Go to your internet browser and in the address bar type in the \u201cDefault Gateway\u201d which was 192.168.1.254 in our example. You may also find the Default Gateway address on your WiFi-Router security tag. Enter the Username\/Password for your router to log in. Note that depending on your router you may see a different interface.<\/li>\n<\/ol>\n<figure id=\"attachment_80\" aria-describedby=\"caption-attachment-80\" style=\"width: 879px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-80\" src=\"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/23.-Router-login-page.jpg\" alt=\"\" width=\"879\" height=\"382\" srcset=\"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/23.-Router-login-page.jpg 1920w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/23.-Router-login-page-300x130.jpg 300w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/23.-Router-login-page-1024x445.jpg 1024w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/23.-Router-login-page-768x334.jpg 768w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/23.-Router-login-page-1536x667.jpg 1536w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/23.-Router-login-page-65x28.jpg 65w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/23.-Router-login-page-225x98.jpg 225w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/23.-Router-login-page-350x152.jpg 350w\" sizes=\"auto, (max-width: 879px) 100vw, 879px\" \/><figcaption id=\"caption-attachment-80\" class=\"wp-caption-text\">Figure3.8. Router login page<\/figcaption><\/figure>\n<ol start=\"8\">\n<li>To make the service port available to the Internet, you need to set up port forwarding using the IPv4 address (192.168.1.64) and Port number (350) in your router so that your ISP does not block the port as shown in Figure3.9.<\/li>\n<li>To verify that the port is open and your ISP does not block it, go to <a href=\"http:\/\/www.canyouseeme.org\">www.canyouseeme.org<\/a>, enter your public IP address and port number and click \u201cCheck Port\u201d. Make sure the server you created in SocketTest is listening at that port; otherwise, you will see that the port is closed as shown in Figure3.10.<\/li>\n<\/ol>\n<figure id=\"attachment_81\" aria-describedby=\"caption-attachment-81\" style=\"width: 601px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-81\" src=\"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/24.-Port-forwarding-example.jpg\" alt=\"\" width=\"601\" height=\"467\" srcset=\"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/24.-Port-forwarding-example.jpg 1144w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/24.-Port-forwarding-example-300x233.jpg 300w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/24.-Port-forwarding-example-1024x796.jpg 1024w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/24.-Port-forwarding-example-768x597.jpg 768w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/24.-Port-forwarding-example-65x51.jpg 65w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/24.-Port-forwarding-example-225x175.jpg 225w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/24.-Port-forwarding-example-350x272.jpg 350w\" sizes=\"auto, (max-width: 601px) 100vw, 601px\" \/><figcaption id=\"caption-attachment-81\" class=\"wp-caption-text\">Figure3.9. Port forwarding example<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_82\" aria-describedby=\"caption-attachment-82\" style=\"width: 383px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-82\" src=\"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/25.-Verify-port-is-open.jpg\" alt=\"\" width=\"383\" height=\"235\" srcset=\"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/25.-Verify-port-is-open.jpg 644w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/25.-Verify-port-is-open-300x184.jpg 300w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/25.-Verify-port-is-open-65x40.jpg 65w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/25.-Verify-port-is-open-225x138.jpg 225w, https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-content\/uploads\/sites\/1097\/2021\/01\/25.-Verify-port-is-open-350x215.jpg 350w\" sizes=\"auto, (max-width: 383px) 100vw, 383px\" \/><figcaption id=\"caption-attachment-82\" class=\"wp-caption-text\">Figure3.10. Verify port is open<\/figcaption><\/figure>\n<h2>B.\u00a0 Configure BG96 module as TCP\/IP client<\/h2>\n<p>In this part of the lab, you will set up a TCP client connection to enter into buffer access mode. BG96 TCP\/IP AT Commands Manual<a class=\"footnote\" title=\"https:\/\/www.quectel.com\/UploadImage\/Downlad\/Quectel_BG96_TCP(IP)_AT_Commands_Manual_V1.0.pdf\" id=\"return-footnote-33-2\" href=\"#footnote-33-2\" aria-label=\"Footnote 2\"><sup class=\"footnote\">[2]<\/sup><\/a> has the full list and description of different modes and commands required for TCP\/IP connections.<\/p>\n<ol start=\"10\">\n<li>Open \u201cTera Term\u201d and use the APN provided by the SIM carrier (e.g., m2m-west.telus.iot) to configure a context via AT Commands.<\/li>\n<\/ol>\n<table>\n<tbody>\n<tr>\n<td><strong>AT QICSGP=1,1,&#8221;M2M-WEST.TELUS.IOT&#8221;,&#8221;&#8221;,&#8221;&#8221;,1\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0<\/strong><em>\/\/ Set the your mobile carrier APN\u00a0 <\/em><\/p>\n<p>OK<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ol start=\"11\">\n<li>Activate the context and query the state of the context and IP address of the module. <strong>AT QIDEACT=1<\/strong> can be used to deactivate a context.<\/li>\n<\/ol>\n<table>\n<tbody>\n<tr>\n<td><strong>AT QIACT=1\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/strong><em>\/\/ Activate a context<\/em><em>\u00a0 <\/em><\/p>\n<p>OK<\/p>\n<p>&nbsp;<\/p>\n<p><strong>AT QIACT?\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/strong><em>\/\/ query the context state<\/em><em>\u00a0 <\/em><\/p>\n<p>QIACT: 1,1,1,&#8221;10.200.109.166&#8243;<\/p>\n<p>OK<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ol start=\"12\">\n<li>Set up a TCP client connection using your PC public IP address (e.g., 172.218.32.19) and port number (e.g., 350). If the connection is successful \u201c QIOPEN: 0,0\u201d will be returned and SocketTest will show the new client IP address.<\/li>\n<\/ol>\n<table>\n<tbody>\n<tr>\n<td><strong>AT QIOPEN=1,0,&#8221;TCP&#8221;,&#8221;172.218.32.19&#8243;,350,0,0\u00a0\u00a0\u00a0 <\/strong><em>\/\/ Set up a TCP client connection using your own public IP address<\/em><\/p>\n<p>OK<\/p>\n<p>&nbsp;<\/p>\n<p>QIOPEN: 0,0<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>C.\u00a0 Send and receive data using BG96 module<\/h2>\n<ol start=\"13\">\n<li>Enter the AT Command below and type in your text. Then press CTR Z to send it. The received text should be shown on SocketTest.<\/li>\n<\/ol>\n<table>\n<tbody>\n<tr>\n<td><strong>AT QISEND=0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/strong><em>\/\/ Send changeable length data. After text press CTR Z to send.<\/em><\/p>\n<p>&gt; Hello, this is a test<\/p>\n<p>SEND OK<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ol start=\"14\">\n<li>When you reply using SocketTest, the module will show QIURC: &#8220;recv&#8221;,0 which means a message has been received in the buffer. To read the buffer, type in <strong>AT QIRD=0,1500<\/strong>.<\/li>\n<\/ol>\n<table>\n<tbody>\n<tr>\n<td>QIURC: &#8220;recv&#8221;,0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <em>\/\/ Send changeable length data. After text press CTR Z to send.<\/em><\/p>\n<p><strong>AT QIRD=0,1500<\/strong><\/p>\n<p>QIRD: 30<\/p>\n<p>Hi, I received your message.<\/p>\n<p>&nbsp;<\/p>\n<p>OK<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ol start=\"15\">\n<li>Close the connection using <strong>AT QICLOSE=0<\/strong>.<\/li>\n<\/ol>\n<p>The instructions above explained how to establish a TCP client connection using the BG96 module. If you are interested, referring to BG96 TCP\/IP AT Commands Manual<a class=\"footnote\" title=\"https:\/\/www.quectel.com\/UploadImage\/Downlad\/Quectel_BG96_TCP(IP)_AT_Commands_Manual_V1.0.pdf\" id=\"return-footnote-33-3\" href=\"#footnote-33-3\" aria-label=\"Footnote 3\"><sup class=\"footnote\">[3]<\/sup><\/a> you can try establishing UDP client, TCP server and UDP server connections.<\/p>\n<p>D.\u00a0\u00a0 Connectivity to the Internet<\/p>\n<p>To check the connectivity between BG96 board and the Internet, we send ping commands. Since ping uses TCP\/IP connection, the success of the command below shows that your board is capable of making TCP\/IP connection and you can check the connectivity.<\/p>\n<p><strong>AT QPING=1, \u201cwww.bcit.ca\u201d<\/strong><\/p>\n<div>\n<div>\n<p>&nbsp;<\/p>\n<\/div>\n<\/div>\n<hr class=\"before-footnotes clear\" \/><div class=\"footnotes\"><ol><li id=\"footnote-33-1\">http:\/\/sockettest.sourceforge.net\/ <a href=\"#return-footnote-33-1\" class=\"return-footnote\" aria-label=\"Return to footnote 1\">&crarr;<\/a><\/li><li id=\"footnote-33-2\">https:\/\/www.quectel.com\/UploadImage\/Downlad\/Quectel_BG96_TCP(IP)_AT_Commands_Manual_V1.0.pdf <a href=\"#return-footnote-33-2\" class=\"return-footnote\" aria-label=\"Return to footnote 2\">&crarr;<\/a><\/li><li id=\"footnote-33-3\">https:\/\/www.quectel.com\/UploadImage\/Downlad\/Quectel_BG96_TCP(IP)_AT_Commands_Manual_V1.0.pdf <a href=\"#return-footnote-33-3\" class=\"return-footnote\" aria-label=\"Return to footnote 3\">&crarr;<\/a><\/li><\/ol><\/div>","protected":false},"author":197,"menu_order":3,"template":"","meta":{"pb_show_title":"on","pb_short_title":"","pb_subtitle":"","pb_authors":[],"pb_section_license":""},"chapter-type":[],"contributor":[],"license":[],"class_list":["post-33","chapter","type-chapter","status-publish","hentry"],"part":3,"_links":{"self":[{"href":"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-json\/pressbooks\/v2\/chapters\/33","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-json\/pressbooks\/v2\/chapters"}],"about":[{"href":"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-json\/wp\/v2\/types\/chapter"}],"author":[{"embeddable":true,"href":"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-json\/wp\/v2\/users\/197"}],"version-history":[{"count":22,"href":"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-json\/pressbooks\/v2\/chapters\/33\/revisions"}],"predecessor-version":[{"id":301,"href":"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-json\/pressbooks\/v2\/chapters\/33\/revisions\/301"}],"part":[{"href":"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-json\/pressbooks\/v2\/parts\/3"}],"metadata":[{"href":"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-json\/pressbooks\/v2\/chapters\/33\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-json\/wp\/v2\/media?parent=33"}],"wp:term":[{"taxonomy":"chapter-type","embeddable":true,"href":"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-json\/pressbooks\/v2\/chapter-type?post=33"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-json\/wp\/v2\/contributor?post=33"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/pressbooks.bccampus.ca\/cellulariot\/wp-json\/wp\/v2\/license?post=33"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}