|  | 622 | === Thingsquare === | 
          
            |  | 623 | [http://www.thingsquare.com Thingsquare] is a software company that offers customized software for the chip on the GW16122, the Ti CC135x. This software allows for the use of a smartphone app to monitor and control sensors through the Thingsquare cloud/backend. A REST API is available as well. | 
          
            |  | 624 |  | 
          
            |  | 625 | A brief description of what is happening in the demo below: | 
          
            |  | 626 | * A Gateworks GW16122 is acting as the IoT Gateway on the Gateworks SBC | 
          
            |  | 627 | * The GW16122 exposes a few serial interfaces (/dev/ttyACM0 and /dev/ttyACM1) which are then used for the SLIP interface | 
          
            |  | 628 | * dnsmasq acts as a DNS server for the slip interface | 
          
            |  | 629 | * The sl0 uses PTP for the DNS | 
          
            |  | 630 | * The SLIP requires some routing and forwarding between interface sl0 and eth0 | 
          
            |  | 631 | * The firmware on the GW16122 pushes data up to the Thingsquare cloud | 
          
            |  | 632 | * The CC1350 Sensor tag is reporting back to the Gateway and pushing it's information up to the cloud | 
          
            |  | 633 |  | 
          
            |  | 634 | Hardware required as noted [#HardwareRequirements here] | 
          
            |  | 635 |  | 
          
            |  | 636 | Steps: | 
          
            |  | 637 | 1. Flash the GW16122 and sensor nodes with Thingsquare Firmware located [https://www.thingsquare.com/docs/downloads/ here] | 
          
            |  | 638 | 1. GW16122 Firmnware: CC1350 Launchpad Serial USB Access Point (US / 915 MHz) | 
          
            |  | 639 | 1. Sensor Firmnware: CC1350 Sensortag | 
          
            |  | 640 | 1. Insert GW16122 into a Gateworks SBC Mini-PCIe slot that has USB support | 
          
            |  | 641 | 1. Load Gateworks SBC Ubuntu 16.04 Software | 
          
            |  | 642 | 1. Install Ubuntu Xenial 16.04 with the instructions [wiki:ventana/ubuntu#Ubuntu16.04LTSXenialXerusconsoleimage Ventana 16.04] | 
          
            |  | 643 | 1. Confirm /dev/ttyACM0 and /dev/ttyACM1 exist on the Gateworks SBC in software | 
          
            |  | 644 | 1. Confirm an ethernet cable is connected to the Gateworks SBC connected to a LAN that has internet access via a WAN | 
          
            |  | 645 | 1. Install dnsmasq{{{apt-get install dnsmasq}}} | 
          
            |  | 646 | 1. Add the following lines to the end of the /etc/dnsmasq.conf file: | 
          
            |  | 647 | {{{ | 
          
            |  | 648 | interface=sl0 | 
          
            |  | 649 | listen-address=127.0.0.1 | 
          
            |  | 650 | listen-address=172.16.0.1 | 
          
            |  | 651 | }}} | 
          
            |  | 652 | 1. Create a script or add to /etc/rc.local to be ran after the board boots each time: | 
          
            |  | 653 | {{{ | 
          
            |  | 654 | modprobe slip | 
          
            |  | 655 | stty -F /dev/ttyACM0 115200 | 
          
            |  | 656 | sleep 3 | 
          
            |  | 657 | slattach -L -s 115200 -p slip /dev/ttyACM0 & | 
          
            |  | 658 |  | 
          
            |  | 659 | sleep 10 | 
          
            |  | 660 | ifconfig sl0 172.16.0.1 dstaddr 172.16.0.2 | 
          
            |  | 661 | ifconfig sl0 mtu 600 | 
          
            |  | 662 |  | 
          
            |  | 663 | echo 1 > /proc/sys/net/ipv4/ip_forward | 
          
            |  | 664 |  | 
          
            |  | 665 | iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE | 
          
            |  | 666 | iptables -A FORWARD -i eth0 -o sl0 -j ACCEPT | 
          
            |  | 667 | iptables -A FORWARD -i sl0 -o eth0 -j ACCEPT | 
          
            |  | 668 | systemctl start dnsmasq.service | 
          
            |  | 669 | }}} | 
          
            |  | 670 | 1. Utilize the Thingsquare website to connect both sensor and Gateway to cloud with the following instructions: [http://www.thingsquare.com/docs/get-started-with-starter-kit/] | 
          
            |  | 671 | 1. Important Note: Checking the box 'Remote Access' is important to connect the device to the Thingsquare backend and available when logging into the app/browser with user account | 
          
            |  | 672 | 1. You can use the website [https://developer.thingsquare.com/web/] to access the devices from a PC browser. Create a Thingsquare account. | 
          
            |  | 673 | 1. Use the bottom menu icon, 'Nearby' to be sure you can discover the device on the LAN | 
          
            |  | 674 |  | 
          
            |  | 675 | Screenshots: | 
          
            |  | 676 |  | 
          
            |  | 677 | Troubleshooting: | 
          
            |  | 678 | 1. Verify traffic on sl0 interface with tcpdump | 
          
            |  | 679 | {{{ | 
          
            |  | 680 | root@xenial-ventana:~# tcpdump -i sl0 | 
          
            |  | 681 | tcpdump: verbose output suppressed, use -v or -vv for full protocol decode | 
          
            |  | 682 | listening on sl0, link-type RAW (Raw IP), capture size 262144 bytes | 
          
            |  | 683 | 17:04:02.516758 IP 172.16.0.2.10323 > ec2-52-211-110-245.eu-west-1.compute.amazonaws.com.https: Flags [P.], seq 12805:13034, ack 371767140, win 500, length 229 | 
          
            |  | 684 | 17:04:02.682914 IP ec2-52-211-110-245.eu-west-1.compute.amazonaws.com.https > 172.16.0.2.10323: Flags [.], ack 229, win 54500, length 0 | 
          
            |  | 685 | 17:04:02.685640 IP ec2-52-211-110-245.eu-west-1.compute.amazonaws.com.https > 172.16.0.2.10323: Flags [P.], seq 1:102, ack 229, win 54500, length 101 | 
          
            |  | 686 | 17:04:02.941381 IP 172.16.0.2.10323 > ec2-52-211-110-245.eu-west-1.compute.amazonaws.com.https: Flags [P.], seq 229:330, ack 102, win 500, length 101 | 
          
            |  | 687 | 17:04:03.148806 IP ec2-52-211-110-245.eu-west-1.compute.amazonaws.com.https > 172.16.0.2.10323: Flags [.], ack 330, win 54500, length 0 | 
          
            |  | 688 | 17:04:12.109625 IP 172.16.0.2.10323 > ec2-52-211-110-245.eu-west-1.compute.amazonaws.com.https: Flags [P.], seq 330:479, ack 102, win 500, length 149 | 
          
            |  | 689 | 17:04:12.276629 IP ec2-52-211-110-245.eu-west-1.compute.amazonaws.com.https > 172.16.0.2.10323: Flags [.], ack 479, win 55500, length 0 | 
          
            |  | 690 | 17:04:18.591617 IP 172.16.0.2.10323 > ec2-52-211-110-245.eu-west-1.compute.amazonaws.com.https: Flags [P.], seq 479:580, ack 102, win 500, length 101 | 
          
            |  | 691 | 17:04:18.756148 IP ec2-52-211-110-245.eu-west-1.compute.amazonaws.com.https > 172.16.0.2.10323: Flags [.], ack 580, win 55500, length 0 | 
          
            |  | 692 | 17:04:18.772626 IP 172.16.0.2.10323 > ec2-52-211-110-245.eu-west-1.compute.amazonaws.com.https: Flags [P.], seq 580:649, ack 102, win 500, length 69 | 
          
            |  | 693 | 17:04:18.941914 IP ec2-52-211-110-245.eu-west-1.compute.amazonaws.com.https > 172.16.0.2.10323: Flags [.], ack 649, win 55500, length 0 | 
          
            |  | 694 | ^C | 
          
            |  | 695 | 11 packets captured | 
          
            |  | 696 | 11 packets received by filter | 
          
            |  | 697 | 0 packets dropped by kernel | 
          
            |  | 698 | root@xenial-ventana:~# | 
          
            |  | 699 |  | 
          
            |  | 700 | }}} | 
          
            |  | 701 |  | 
          
            |  | 702 | References: | 
          
            |  | 703 | * Ti Thingsquare [http://www.ti.com/ww/en/internet_of_things/Thingsquare-for-TI-IoT-development-kits.html] |