In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail about the application of JavaScript in the Internet of things, the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
Fundamentals: the three levels of the Internet of things
Before we begin, let's briefly introduce the basics of the Internet of things. If you have any experience in Web development, you all know that the following figure is the CS architecture:
Compared with an Internet of things system, there is nothing more than a hardware layer and an optional coordination layer.
This hardware layer determines that Internet of things applications are more complex than Web applications. For most Web applications, the clients are mobile phones, computers, tablets and other devices, which have strong processing power and do not need to consider some additional factors.
For the application of the Internet of things, we need to consider the processing capacity of MCU on the device and use different communication protocols according to its processing capacity and environment, for example, we need to use CoAP protocol on some devices. There is no network function on some devices, so we need to consider the assistance layer that can be connected to the Internet, and we also need to use some short-distance wireless transmission protocols, such as low-power Bluetooth, infrared, Zigbee and so on.
An Internet of things system: six languages
Two and a half years ago, when I was a senior, majoring in Electronic Information Engineering, my graduation thesis was a thesis on the Internet of things-"the minimum system Design of the Internet of things based on REST Services". This is an entry-level paper on the Internet of things. If most CS students have a little hardware foundation, they can write such a paper.
This paper is a "minimization" of previous entries. The main thing used in this paper is to create RESTful services, and it is not even a technology. In this work:
We use the Django framework in Python as the Web services framework and use Django REST Framework to create RESTful services.
In order to use the mobile phone as the controller, we also need to write an Android application in Java.
We use Raspberry Pi as the coordination layer of the hardware, which is used to connect the network and transmit control signals to the hardware.
We use Arduino as the controller on the hardware side, and it is very easy to write code, which allows us to focus on the business.
Finally, we also need to make a chart on the web page to display real-time data.
All of these, we need to use Python, Java, JavaScript, C, Arduino five languages. And if we want to write the corresponding iOS application, we also need Objective-C.
! [are you kidding me?] (http://articles.phodal.com/js-iot/6359758744428735171956612167_are-you-serious-wtf-meme-baby-face.jpg)
The Development of JavaScript in the Field of Internet of things
Similarly, more than two years ago, as an intern, in our new project, we used Backbone as the core of the single-page application framework to build Web applications. At this time, I began to pay attention to the possibility of Node.js to realize the application of the Internet of things.
At that time, I already had a library of the Internet of things protocols MQTT and CoAP, so I wrote an Internet of things that supported HTTP, CoAP, WebSocket and MQTT. Due to the lack of some classic development of large-scale applications at that time, it was not done very well, but we can already see the prospect of JavaScript in this respect.
More than a year ago, before the official version of Ionic was released, I found this framework really great-it comes with a series of UI and integrates a series of plug-ins for Cordova with NgCordova. I started writing some mobile apps using Ionic and found it quite easy. Then, I began to use this framework to try to write Internet of things applications, which requires some native plug-ins, such as BLE, MQTT. Later, I also wrote a simple CoAP plug-in.
Later, instead of compiling Node.js, we can run Node.js on the ARM processor. And we already have Tessel, Espruino, Kinoma Create, Ruff and other development boards that can run JavaScript directly. Samsung also launched iot.js, which allows more embedded devices to use JavaScript as the development language.
There are many reasons why people start to use JavaScript on hardware, such as Web developers are the most, and JavaScript is easy to use.
Now, this time we can use JavaScript at all three levels, only one language.
Using a language to develop Internet of things applications: JavaScript
In my do-it-yourself book, the Internet of things, I tried to demonstrate the power of JavaScript in this respect. Use Node.js + Node-CoAP + MQTT.js + MongoDB + Express to build a multi-protocol Internet of things:
However, the picture above is a complete version of the Internet of things, and the code is naturally on GitHub: Lan. As a server, the capabilities of Node.js have been proven. On the other hand, hybrid applications can still stand the test, and it is easy for hybrid apps to make a chart on the phone (just get the data and display it):
It's also easy to be a control side (we just need to send a POST request and, more logically, get the status first):
On the hardware side, I did not use JavaScript as an example to show the use of JavaScript in the book, because this will limit the user's hardware devices.
However, we can still use libraries like Johnny-Five to do hardware programming, but it's not that fun.
If we can do it with JavaScript, why should we have a cup of coffee and wait for it to be compiled in C?
All the answers you want to know are in this book, which has been on Amazon, JD.com and Dangdang:
After all:
Anything that can be written in JavaScript will eventually be written in JavaScript.
About how the application of JavaScript in the Internet of things is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.