element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Bluetooth Unleashed Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Bluetooth Unleashed Design Challenge
  • More
  • Cancel
Bluetooth Unleashed Design Challenge
Blog Bluetooth Challenge - Home Security System - Blog Post IV
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: kedwards@swbell.net
  • Date Created: 2 Jun 2018 3:54 AM Date Created
  • Views 451 views
  • Likes 6 likes
  • Comments 1 comment
Related
Recommended

Bluetooth Challenge - Home Security System - Blog Post IV

kedwards@swbell.net
kedwards@swbell.net
2 Jun 2018

Hello Everyone,

 

Things did not go as planned last week so this post is late. Its also the inspiration for this post’s quote of the moment. I did complete the design of the software modules on the BeagleBone Black. I ordered the electric solenoid valve. Also, I am waiting for my second camera module. I will need to order more smart plugs. However, I want to wait until I am sure I can communicate with the one I have before ordering more.

 

Note that I used Wi-Fi for accessing the cameras. Any literature I read on steaming camera data suggested using Wi-Fi instead of Bluetooth. The logic being that Bluetooth may not be fast enough and the slow speed may cause jerky or frozen video frames.

 

In the Security section I discuss how to use PuTTY to logon to the BeagleBone Black without using a password. I only have two sections for this post, plus the Security section:

 

Section I – High Level Design for the BeagleBone Black Software

Section II - Bluetooth Data Protocol

Section III – Security

 

This week I will try to communicate with the smart plug and start working on the web server design.

 

Talk to you soon.

 

 

Quote of the Moment -

Life is what happens while you are making plans.

            -- John Lennon

 

 

 

 

Section I – High Level Design for the BeagleBone Black Software

 

There are four main software modules, the Initialization module, the Wi-Fi module, the Web Server module, and the Bluetooth module (See Figure 1). There are seven sub-modules, Natural Gas Sensor sub-module, Carbon Monoxide Sensor sub-module, Motion Sensor sub-module, Alarm sub-module, Smart Plug / Lights sub-module, Electric Solenoid Valve sub-module, and Proximity Sensor (Garage Door) sub-module.

 

The Initialization module is a standalone module. Its purpose is to ensure that the other modules are started properly.

 

The Wi-Fi module has two functions. One function is for communications between the BeagleBone Black web server and the home owner’s web browser. The second function is for accepting a camera stream from the two cameras and passing the streams to the Web Server module for displaying on the home owner’s web browser.

 

The web server module accepts data from the sub-modules and passes the data to the web browser. It will also accept the home owner’s browser responses and passes those responses back to the sub-modules for processing.

 

The Bluetooth module accepts data from the Bluetooth devices and passes the data to the appropriate sub-module. The sub-modules process the data and passes responses back to the Bluetooth module which sends the data back to the appropriate Bluetooth device.

 

The Natural Gas Sensor, Carbon Monoxide Sensor, and Motion Sensor sub-modules processes the data from its corresponding sensor. If the sensor is triggered it sends an alert. The appropriate sub-module formats a message and the message is sent to the Alarm sub-module. The Alarm sub-module sounds an alarm by making a beeping sound and speaking a message via speech-to-hardware.

 

The Smart Plug / Lights sub-module processes data from smart plugs and lights. Basically, the sub-modules will accept requests from the home owner to either turn a light / appliance on or off. The request is passed to the Bluetooth module and sent to the appropriate Bluetooth device.

 

The Electric Solenoid Valve sub-module is similar to the Smart Plug / Lights sub-module. The main difference is the Electric Solenoid Valve sub-module controls a solenoid value instead of a smart plug or light. The solenoid value will act as an on-off switch for a gas stove.

 

The Proximity Sensor sub-module will control the garage door. The proximity sensor module will send the status of the garage door (open or closed) via Bluetooth to the Proximity Sensor sub-module. The Proximity Sensor sub-module will interact with the home owner via the web browser to close or open the garage door.

 

image

  Figure 1.

 

 

Section II – Bluetooth Data Protocol

 

In this section we will define the format of the data that the sensor modules will use to pass data to the BeagleBone Black. Data is sent through the Bluetooth network will be formatted as shown in Table 1. Each Bluetooth adapter is assigned an Adapter_Id.

 

This Adapter_Id is populated into the Source_Adapter_Id of a Bluetooth data packet so that modules in the network know who sent the packet. The Adapter_Id is populated into the Destination_ Adapter_Id so that modules receiving the packet knows whether the packet is intended for the receiving module. If a module receives a data packet with its own Adapter_Id in the Destination_ Adapter_Id field it will process it.

 

To keep a packet from endlessly traversing the Bluetooth network a predetermined Max_Transmission_Count will be added to each packet. Every module that receives a data packet that does not belong to it will decrement the Max_Transmission_Count in the packet and re-transmit it. If a module receives a packet with a zero Max_Transmission_Count it will discard it. If a module receives a packet with its own Source_Adapter_Id it will discard it.

 

The Status field is used as a binary switch for the software sub-modules, such as “0” for off and “1” for on or, “0” for closed and “1” for opened.

 

The Data field is a free form field that contains custom data depending on the requirements of the sub-module.

 

 

Columns

Name

Description

1-3

Source_Adapter_Id

A 3-digit Id assigned to each Bluetooth adapter.  The Controller module uses the Id to determine which module should process the data in the packet.

4-6

Destination_ Adapter_Id

A 3-digit Id of the Bluetooth adapter that should receive this packet. If zero, the destination is the BeagleBone Black.

7-8

Max_Transmission_Count

A 2-digit number that is decremented each time this packet is received by a Bluetooth adapter. If the number is zero the packet is discarded by the Bluetooth adapter.

9

Status

Status of device that the adapter is attached to.

10-80

Data

Information to be acted upon by the destination device.

Table 1.

 

 

 

Section III – Security

 

In Post II, I showed you how to install PuTTY. PuTTY comes with a utility called PuTTYgen and another utility called Pageant. With PuTTYgen you can generate SSH key pairs. Pageant is used to help manage your private keys. Storing your private key in Pageant allows you to log onto your BeagleBone Black without a password.

 

For those unfamiliar with public key authentication here is a short description extracted from the PuTTY documentation:

 

You generate a key pair, consisting of a public key (which everybody is allowed to know) and a private key (which you keep secret and do not give to anybody). The private key is able to generate signatures. A signature created using your private key cannot be forged by anybody who does not have that key; but anybody who has your public key can verify that a particular signature is genuine.

 

So, you generate a key pair on your own computer, and you copy the public key to the server. Then, when the server asks you to prove who you are, PuTTY can generate a signature using your private key. The server can verify that signature (since it has your public key) and allow you to log in. Now if the server is hacked or spoofed, the attacker does not gain your private key or password; they only gain one signature. And signatures cannot be re-used, so they have gained nothing.

 

Here is the process to generate SSH key pairs with PuTTYgen and to use Pageant to logon without a password.

 

Start PuTTYgen on your PC (Figure 2).

 

image

  Figure 2.

 

Click on the Generate button (Figure 3).

 

image

  Figure 3.

 

Move you mouse around when prompted to create some randomness.

PuTTYgen will re-display the window with your public key populated in the top text box (Figure 4).

 

image

  Figure 4.

 

 

Enter something in the Key comment text box that identifies your PC (Figure 5).

Enter a strong password in the Key passphrase text boxes.

Click on the Save public key button.

Make sure you remember which directory you used to save the keys.

I called the public key kxelaptop.pub (Figure 6).

Click on the Save private key button

I called the private key kxelaptop.ppk.

 

image

  Figure 5.

 

image

  Figure 6.

 

 

Now we want to copy the public key we generated with PuTTYgen to the BeagleBone Black (Figure 7).

 

image

Figure 7.

 

 

Leave the Putygen window open.

Switch to your BeagleBone Black PuTTY session.

From your home directory, create a new directory called .ssh (Yes, you need the period before the ssh):

Run “mkdir .ssh”

Run “cd .ssh”

We need to create an authorized_keys file to hold PuTTY’s public key.

Run “nano authorized_keys”

In the PuTTYgen window, copy the public key in the top text box, to the system clipboard (Figure 7).

 

In the nano editor:

  • Right click on the mouse -  to paste the contents of the system clipboard (Figure 8).
  • Note that the Public key is one line long, not multiple lines.
  • Enter Ctl-O to save the file. Click the Enter key when you see the prompt (Figure 9):
  • File Name to Write: authorized_keys
  • Enter  Ctl-X to exit nano.

 

image

  Figure 8.

 

image

  Figure 9.

 

The authorized_keys file permissions must be set to read/write for owner and no permissions for group & world. To set the permissions correctly run “chmod 600 authorized_keys”:

-rw------- 1 debian debian 787 Jun  1 00:34 authorized_keys

 

Also, verify the the .ssh directory is set to read/write/execute for owner only:

drwx------  2 debian debian  4096 Jun  1 00:34 .ssh

 

Now back to your PC. The PuTTYgen window is no longer needed, therefore you can close it. At this point we could logon using the PuTTY’s private key, if we added the private key to the PuTTY Configuration. However, when we try to logon, the logon process would ask us for the PuTTY private key password instead of the BeagleBone Back user password. If we let Pageant manage our private we will not have to enter any password. So, let’s add our private key to Pageant so we can logon to the BeagleBone Black without entering any key.

 

Open Pageant (Figure 10).

 

image

Figure 10.

 

Click on the Add Key button (Figure 11).

Click on the open button and browse to your key directory and select the private key (Figure 12).

 

image

  Figure 11.

 

image

  Figure 12.

 

Enter your password for your private key (Figure 13).

 

image

  Figure 13.

 

Your private key is now stored in Pageant (Figure 14).

 

image

  Figure 14.

 

Now, start a PuTTY session as you normally would. However, this time when your PuTTY session starts the BeagleBone Black will automatically log you on (Figure 15).

 

image

  Figure 15.

 

 

Keep in mind that Pageant must be running for auto logon to work. You can add it to the startup folder so that it starts whenever you logon to your PC. The following link explains how to add a program to the startup folder if you do not know how:

https://answers.microsoft.com/en-us/windows/forum/windows_10-start/how-to-add-programs-to-startup-in-windows-10/09d4cb0a-dcd5-4521-94e8-fef293f062ce

 

There is one caveat with Pageant. When you exit Pageant, the private keys stored in Pageant are deleted out of Pageant. Therefore, the next time you start Pageant you have to re-enter the private key. If you have your private key password protected it will ask you for the password. However, you only have to do this once every Pageant session. The keys are only deleted out of Pageant if you exit Pageant. If you close Pageant it is minimized into the System tray and is still running.

 

You could get around the problem by not password protecting your private key. However, it is a less secure solution. If you do not password protect your private key you could specify the path for your key in the PuTTY configuration. Just add the path in the text box next to the Browse button (Figure 16) in the SSH/Auth Category in the PuTTY configuration. Now you can logon without a password and without running Pageant. Just keep in mind that if the private key is not password protected anyone hacking into your PC will be able to see your private key since it will be stored in plaintext.

 

image

  Figure 16.

 

You can also execute PuTTY from a batch file. I created a PuTTY configuration file called “BeagleBone Black - debian 2”. The configuration file for BeagleBone Black - debian 2 contains the path to the private key that is not password protected. I then created a batch file called Logon BBBW.bat Which contains one line (Figure 17). If I double click on the logon BBBW.dat file it logs me on to the BeagleBone Black (Figure 18).

 

image

  Figure 17.

 

image

  Figure 18.

  • Sign in to reply

Top Comments

  • genebren
    genebren over 7 years ago +1
    Very nice update on your design challenge project. This was a very detailed description of the steps in your process. I look forward to your future updates and wish you success in getting your project…
  • genebren
    genebren over 7 years ago

    Very nice update on your design challenge project.  This was a very detailed description of the steps in your process.

    I look forward to your future updates and wish you success in getting your project completed.

     

    Also, anytime to you quote John Lennon you have my full attention.

    Gene

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube