element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • 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 & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • 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
Industrial Automation
  • Technologies
  • More
Industrial Automation
Blog Connect to AVNET iotconnect.io with Python IoTConnectSDK and BLE - part 7: Register a Gateway and Client Devices
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Industrial Automation to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 1 Nov 2021 7:22 PM Date Created
  • Views 1395 views
  • Likes 1 like
  • Comments 0 comments
  • iiot
  • avnet
  • smartedge
  • gateway
  • iot
  • iotconnect.io
Related
Recommended

Connect to AVNET iotconnect.io with Python IoTConnectSDK and BLE - part 7: Register a Gateway and Client Devices

Jan Cumps
Jan Cumps
1 Nov 2021

AVNET's iotconnect.io cloud platform is an online service that you can use to send data to, and then show it on a dashboard. In this blog series I'm learning the Python SDK and integrating BLE devices.

In this post: create a Gateway template, register a gateway device, dynamically register children.

image

image: a gateway device with two BLE children

 

My previous post reviews what a gateway is, in a cloud context. Check it out if you're looking for a definition.

In this post, I review the internals of the example that Avnet and OnSemi made.

The photo at the top of this blog shows an Avnet IIoT gateway, with two OnSemi IoT devices.

The gateway is cloud savvy. The two clients are just BLE capable.

The example teaches the gateway how to exchange data of the OnSemi satellites to the cloud. It 'll even be able to send commands to one of the clients.

 

image

image source: the demo device's children listed on the iotconnect.io portal

 

 

Gateway Template

 

this is a revisit and extend of a topic handled earlier when I registered a simple device.

An iotconnect.io device can be connected if it complies with a known template.

A template is something you set up on the cloud. You can see it as an agreement or API. It defines what your remote device(s) can do.

 

image

image source: the different types of devices (and templates) on the iotconnect.io portal

 

iotconnect.io has a range of template types. The Device template (used in the 5 first posts) can manage things that have attributes and/or can handle commands directly. It's one self-contained object.

The Gateway template we're using here can do different things. It's goal is not to handle its own attributes*. The goal is to safely exchange data from the IoT devices surrounding it.

When you use a gateway template, your unit will be be able to exchange the template-defined data and commands from/with any object that it decides to support.

It's your duty to learn the gateway how to detect, accept and register trusted devices.

reminder: If a device is smart enough to connect to the cloud by itself, you typically don't use a gateway in-between.

The gateway is your tool to exchange data from devices that aren't cloud-capable, like BLE , sub-1 GHz, LoRaWan, ...

 

image

image source: create a gateway template on iotconnect.io portal

 

When creating a template, take care that at least one attribute is created, and that it's of type Int.

*An Edge Gateway template can do the combination: have its own attributes and manage child devices.

 

Register Gateway Device and Children

 

The example program that runs on the gateway validates the template name registered in the ~/IoTConnectSDKonboard.py Python script.

It checks if it can authenticate with the user info you provided in the config.

Then it checks if the template for our device exists

    AUTH_BASEURL = my_config_parser_dict["CloudSystemControl"]["http_auth_token"]
    TEMPLATE_BASEURL = my_config_parser_dict["CloudSystemControl"]["http_device_template"]
    DEVICE_BASEURL= my_config_parser_dict["CloudSystemControl"]["http_device_create"]
    username = my_config_parser_dict["CloudSystemControl"]["username"]
    password = my_config_parser_dict["CloudSystemControl"]["password"]
    solution_key = my_config_parser_dict["CloudSystemControl"]["solution-key"]
    ACCESS_TOKEN = get_auth(username, password, solution_key)
    if ACCESS_TOKEN == None:
        myprint("authentication failed")
        return 0
    #---------------------------------------------------------------------
    template_name = "zt" + str(serial_number)
    available_name = str(my_config_parser_dict["CloudSystemControl"]["template_name"])
    if (available_name != ""):
        template_name = available_name
    header = {
        "Content-type": "application/json",
        "Accept": "*/*",
        "Authorization": ACCESS_TOKEN
    }
    #---------------------------------------------------------------------
    # Get template attribute by searchText
    myprint(template_name)
    template = get_template(template_name)
    if template != None:
        myprint("Device template already exist...")
        deviceTemplateGuid = template['guid']
    return 1

 

 

If the template does not exist, the example will generate one in CloudConfigureDevice().

This will only work if the user you provide is allowed to create a template.

A typical application will have the template prepared and deployed before the first devices try to connect.

 

Once the application is running, it will check for registered client types (children).

Avnet has added a discovery function in the child library's _init_py script, named handleDiscovery().

As example, the OnSemi library contains discovery functions that can detect an OnSemi RLS10 sensor tag and an RSL10 Camera tag.

When one of these devices is in the neighbourhood, and the firmware is recognised, the dynamic registration of the device happens.

Shown here for the OnSemi RSL10 camera kit:

 

                            CameraType = (result['applicationversion'][:6] == "SS_COL") + 1
                            myprint("CameraType " + str(CameraType))
                            if CameraType == 1:
                                result1 = OnBoard.AddChildDevice("SmartShotBlackWhite", "smartshot", dev.addr.replace(':',''))
                            else:
                                result1 = OnBoard.AddChildDevice("SmartShotColor", "smartshot", dev.addr.replace(':',''))
                            if CameraType == 1:
                                data = {
                                    'addr':dev.addr,
                                    'guid':str(result1),
                                    'type': CameraType,
                                    'name': "SmartShotBlackWhite" + dev.addr.replace(':',''),
                                    'bootloaderversion': result['bootloaderversion'],
                                    'fotastackversion': result['fotastackversion'],
                                    'applicationversion': result['applicationversion'],
                                    'buildid': result['buildid'],
                                    'supportsfota': result['supportsfota']
                                }

 

That's not the only thing that happens. A data exchange task is registered to tell the Gateway to deliver the child's data to the cloud at a defined interval.

 

If you want to validate this, check these files in the avnet user home directory:

IoTConnectSDKengine.py
IoTConnectSDK.conf
IoTConnectSDKonboard.py
IoTPluginSmartSense\__init__.py
IoTPluginSmartSense\IoTConnectSDK.conf

 

This post may be lean on the way the SDK runs, gets configured and how it uses the iotconnect.io REST api.

That's handled in other posts of this series.

 

 

The Python SDK with On Semiconductor RSL10 BLE article seriesIndustry
part 1: overview and goal
part 2: WiFi Provisioning
part 3: Adding a Module (RSL10)
part 4: Talk BLE to the On Semi RSL10 Sensor Kit
part 5: A Cloud User Experience Example
part 6: Register as a Gateway Device
part 7: Register a Gateway and Client Devices
part 8: Get BLE Image from Camera and Send to Cloud
The NODE-Red SDK article seriesIndustry
part 1: overview and goal
register a Thing and connect to IoTConnect.io cloud
part 2: create an account and log on to the portal
part 3: set up the thing and its interface in the cloud
part 4: set up Node-RED and first exchange
interact with IoTConnect.io cloud
part 5: online dashboard
part 6: rules and alerts
part 7: messages and commands from the cloud
safer connections with certificates
part 8a: safer connect with Self Signed Certificates
part 8b: safer connect with CA certificatesY
commercial and industrial scale: outsource certificate generation and programming to subcontractors and suppliers
part 9a: Outsource Certificate Signing in IIoT Supply ChainY
part 9b: IIoT supply chain and Certificates - Create Ca Root certificate, Load to IoTConnect Cloud and ValidateY
part 9c: IIoT supply chain and Certificates - Create an Intermediate CA Certificate for your SubcontractorY
part 9d: IIoT supply chain and Certificates - Subcontractor Generates a Thing Certificate for Your DeviceY
part 9e: IIoT supply chain and Certificates - Test!Y
commercial and industrial scale: Trusted Platform Module (TPM) Authentication
part 10: Trusted Platform Module (TPM) SecurityY
Infineon SLx9670 Trusted Platform Module (TPM) for IoT SecurityY
The Automate Device Provisioning and Cloud Configuration article seriesIndustry
Automatic Provisioning with REST APIY
  • Sign in to reply
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