The architecture of the 2Smart Cloud platform implies that IoT devices are connected to the internet, and their management occurs through the cloud. These devices can be connected via Wi-Fi, Ethernet, or GSM, directly linked to the cloud, or operate through a gateway. However, users, service providers, and corporate clients often encounter situations where cloud-based management is temporarily impossible or an alternative means of communication between the device and the interacting human is required. One solution for such situations is the use of Bluetooth protocol. In this publication, we want to share our experience in solving another task of local control and configuration of devices, using the example of our client MyBox, a manufacturer of charging stations for electric vehicles.
The primary reason for the need for this task is the scenario involving the installation of charging stations in locations with unstable/poor or completely absent internet connectivity. The necessity for local control can be relevant for end-users, installers, or service providers. Here are typical examples:
The functionality of local control addresses both of the issues described above.
We’re empower your business with our technology expertise
To address the task at hand, we conducted research into suitable technologies and concluded that the optimal solution is to utilize the mDNS (Multicast DNS) protocol. This service enables the fulfillment of two necessary tasks:
The principle of mDNS operation involves devices sending requests to discover other devices on the local network via multicast messages. When a device in the network wants to find another device, it broadcasts the request to all devices in the network using a special IP address known as the multicast address.
Every device on the network that supports the mDNS protocol listens to these multicast messages. If it responds to the request (for example, it matches the hostname or has the required service), it sends a response to all devices that sent the request. This allows devices to find each other and interact without a centralized DNS server.
The mDNS protocol is commonly used in home networks for automatic device discovery, such as printers, media players, smartphones, computers, etc., and for accessing them using names or hostnames instead of IP addresses.
Pros of mDNS:
Cons of mDNS:
The diagram below illustrates how mDNS works:
Here, we see two devices connected to the network. The first one is connected via WiFi, and the second one is connected via Ethernet. The user sends an mDNS Query to find all available devices on the network, and the WiFi Router responds with an mDNS Response containing information about the two devices. The address of the first device is device1.local, and the address of the second one is device2.local. The user sends requests to each of these devices using the obtained addresses, and the router resolves these addresses into IPv4 and forwards the requests to the devices.
The next diagram shows how interaction between devices occurs when one of them opens a WiFi access point and the other one connects to it:
Except for the absence of the router in the scheme, everything else is similar to the example in the first diagram. The device sends an mDNS Query to retrieve available devices (mDNS Response), and then communication occurs with the device using its local address (device1.local).
Within the MyBox project, charging stations utilize both of the described scenarios depending on the usage scenario of local management for these devices.
We’re empower your business with our technology expertise
For such cases, the charging station implements a special mode called service mode, which is when the charging station creates its own Wi-Fi network, allowing users to connect directly to it regardless of their existing network connection. This ensures that users can still access and interact with the charging station even when they are not connected to the same network. Once connected to the charging station’s Wi-Fi network, users can utilize mDNS to discover and communicate with the charging station seamlessly, enabling them to perform tasks such as configuration, monitoring, and control as needed. This approach enhances the flexibility and accessibility of the charging station, ensuring uninterrupted operation and user convenience in various network environments.
Within the mDNS protocol, TXT records are used. These records allow any textual information to be included, which can be useful for the identification or configuration of the device or service. For example, they can contain information about the manufacturer, software version, service description, configuration parameters, etc.
By configuring the charging stations to include specific TXT records containing identifying information such as the manufacturer’s name (MyBox), model name, or any other relevant details, devices searching for charging stations can use these records to filter and identify MyBox charging stations specifically. This ensures that only the desired devices are discovered and communicated with, enhancing the efficiency and accuracy of device discovery within the network.
The charging station has its own web admin interface, where users can monitor and modify available device settings.
Within the project, we refer to this page as “JTree” because the configuration page has a tree-like structure of data, where all device configurations are divided into groups (nodes), have their own data type (boolean, string, number, float, enum), have R or R/W permissions (read-only or read-and-write), and some current values.
Communication with the device occurs through a WebSocket server running on the charging station, and the data structure itself is self-declarative and has a JSON structure.
Local control also operates through JTree. Here’s an example of how it looks in the mobile application:
Firstly, the mobile version of the admin interface is not very well optimized for use on smartphones, while in most cases, the need for local control arises specifically via smartphones.
Secondly, the mobile application offers additional features. For example, it stores information about devices that were previously discovered and displays their current status (online or offline).
Thirdly, it was relatively easy to “reuse” the functionality since the backend part (JTree API) was already implemented for the web admin interface in the firmware. All we had to do was add this functionality to the mobile application.
The cloud platform features a fixed layout for each device, primarily designed for a simplified user experience. The device management interface in the mobile application is greatly simplified and not overloaded with specific configurations. Instead, local control is tailored specifically for advanced device configuration.
Within the MyBox project, the mDNS protocol is utilized for a range of other needs:
MyBox solution is a comprehensive product where the charging station may consist of multiple components. It could be a charging station with a solar panel controller or charging stations with a DLM system for dynamic current distribution between them. In both cases, setting up communication between two or more independent devices is necessary, and the most convenient option for us was mDNS because this protocol covers all the needs of device pairing:
Indeed, due to mDNS’s openness, malicious actors can easily find devices within a network, so any API should be additionally protected from external interference.
That’s why, within JTREE and device pairing, an additional authentication mechanism is implemented, conducted by the devices before continuing communication.
In conclusion, the integration of local control and mDNS technology marks a significant advancement in IoT device management, particularly in scenarios where internet connectivity is limited or unreliable. MyBox, with the expertise and support of 2Smart, exemplifies the seamless integration of these innovations, offering users unparalleled flexibility and efficiency in controlling and configuring their IoT devices.
By leveraging local control, users can now manage their IoT devices with ease, regardless of internet availability, ensuring uninterrupted operation and enhanced security. With 2Smart’s dedication to innovation and MyBox’s commitment to quality, the future of IoT device management is brighter than ever.
Join us in embracing this new era of connectivity and control. Explore the possibilities of local control with MyBox EV Chargers and discover the limitless potential of IoT technology. Together, let’s shape a smarter, more connected world.
For further inquiries or to discuss any IoT implementation case, don’t hesitate to reach out to us at contact@2smart.com. We’re here to help you navigate the world of IoT solutions and drive your business forward.
Share with us your business idea and expectations about the software or additional services.