Personal Insights on Developing IoT Embedded Devices with .NET Core / C#

2019年12月15日 410点热度 0人点赞 2条评论
内容目录

 

( .NET Core Dragon Balls )

1. Support of IOT Platforms

First, let's take a look at some excellent cloud computing IOT platforms in China (excluding specific product developer platforms like QQ Connect, Xiaomi IOT, etc., only listing some cloud computing vendors' IOT platforms)

Alibaba Cloud IOT

https://iot.aliyun.com/

Huawei IoT

https://developer.huawei.com/ict/cn/site-iot-next

Tencent Cloud IoT Communication

https://cloud.tencent.com/product/iothub

Baidu Cloud TianGong

https://cloud.baidu.com/solution/iot/index.html

China Mobile OneNET

https://open.iot.10086.cn

Speaking of IOT and development, there are many aspects and different models: device authentication, device access, gateways, device management, subscription, data management and analysis, application development, etc. Here, I will mainly discuss the development of embedded devices.

Among these platforms, only Alibaba Cloud provides C# SDK for the device side, and it is not open source and not cross-platform (it can only be used under .NET Framework 4.7, don't ask me how I know). The device access method is HTTP/2. For C#/.NET friendliness, Alibaba Cloud is probably the best, while Tencent Cloud's IOT doesn't seem well done.

The device-side access and application development mainly use C language and Python (C language is the king of embedded development), with communication protocols including HTTPS, MQTT/MQTTS, etc.

Alibaba Cloud IOT device SDK documentation

https://help.aliyun.com/document_detail/101488.html?spm=a2c4g.11186623.2.26.554a5b3eaMSYnh#concept-xlx-dzz-ggb

Alibaba Cloud IOT cloud SDK documentation

https://help.aliyun.com/document_detail/63638.html?spm=a2c4g.11186623.6.678.1ede4c07i0qvHR

Abroad, I will only mention Amazon Cloud and Azure Cloud.

https://www.amazonaws.cn/iot/

https://www.azure.cn/zh-cn/

They have separate Chinese and international regions, and Microsoft's Azure in China is operated by 21Vianet (which is quite uncomfortable).

 

 Looking at the picture, it indicates that Amazon does not support C#, and embedded development is only in C language; other aspects also do not support C#/.NET.

Only Azure provides extensive and uncompromising support for .NET.

 2. Embedded Devices

The device side of IOT devices is not limited to devices such as Raspberry Pi, watches, drones, Bluetooth, etc. Mobile phones, watches, computers, and others can also act as IOT device ends.

This discussion is limited to ARM32/64 embedded development boards, such as Raspberry Pi and domestic Orange Pi.

Operating systems include Win 10 IoT Core, Ubuntu, Debian, etc.

If you're going to buy, get a Raspberry Pi, don't buy other brands, or you will regret.

1. System Support

Raspberry Pi supports a large number of systems, and the system kernel is relatively new. Installing the .NET Core SDK and Runtime almost completes in one go.

On the other hand, the domestic Orange Pi is quite problematic, with an older system kernel, lower GCC version, various driver incompatibilities, and not many systems function properly; it also has significant heat generation.

Not long ago, I bought an Orange Pi 3 and attempted to install .NET Core SDK 2.2. I had to change the apt source first, update the apt list, and install the new version of gcc (the .NET Core requires gcc version greater than 5.2, and Debian system must be version 9 or higher).

(I really wanted to smash this lousy board, but I have already spent 300 bucks...)

2. Resource Documents

Raspberry Pi has a very high popularity, and many software supports Raspberry Pi. Almost all technologies related to embedded development will mention Raspberry Pi; you need not worry about a lack of learning resources or relevant sensors.

Others will not be elaborated here.

Only boards with larger memory and CPU can run programs developed in .NET; low-level C language is the way to go, as a microcontroller may only have a few KB of memory, while the ARM version of .NET Core requires at least 300 MB of memory.

3. Current Methods for Developing Embedded Applications in .NET

1. Using Dynamic Link Libraries Generated by C/C++

This is the author's article -- Cross-Platform Development -- C# using Dynamic Link Libraries Generated by C/C++

https://www.cnblogs.com/whuanle/p/10582654.html

By using C/C++ wrapped interfaces to control GPIO (the pins on the board), this method can only be used under Linux. Developing C# programs does not require direct interaction with the underlying implementation. Instead, through reserved C/C++ interfaces, indirect control is possible. C/C++ handle various communication protocols, logical processing, circuit control, etc., wrapping them into .SO libraries for C# usage. This way, project development can focus on business development without worrying about the underlying implementation.

The author has written an article .NET Core Cross-Platform Serial Communication, which uses the SerialPortStream library, an applicable library on Windows/Linux. If it is to be used in Linux, the official C project must first be compiled to generate a dynamic link library for the project before running it, using C language for development with independent communication methods.

2. Using Windows 10 IoT Core

This means developing on Windows 10 IoT Core systems.

Benefits:

- Your Highness

Let’s start with a few images

 

 

 

One complete set of C# can handle various development aspects, with official libraries directly provided to operate various device interfaces and pins. You do not need to possess extensive hardware knowledge to quickly get started with the project, directly using C#/.NET to interact with various sensors. The development support of Visual Studio, which is the universe’s top IDE, connects to excellent cloud computing platforms like Azure, has great ecological support, can use traditional WPF software interfaces, easy maintenance, visualized... In the past, using development boards required mastering the development of embedded devices, WIFI, Bluetooth, GPIO, network cards, ARM32/64, circuit protocols, and hardware knowledge, and developing the low level in the C language; now, using C# can accomplish everything.

3. Mono

When the author was learning to use development boards, he found that some libraries could be used on mono. Using Monodevelop, C# projects can be developed to manage GPIO. However, the author is unfamiliar with mono and has not attempted actual implementation.

 

Implementing embedded development in .NET Core, in the author's current limited perspective, has not revealed the advantages of developing embedded software with .NET Core.

First, .NET Core (currently the latest ARM 2.2.105) cannot directly use sensors. This might be due to the author's lack of proficiency, as examples of using .NET Core to control sensors or using GPIO under Linux have not yet been found.

Of course, there are instances of developing .NET Core projects using GPIO on Windows 10 IoT Core, but they use Windows.Devices.Gpio, and it's not on Linux.

Second, there are not many cloud computing vendors that support .NET. Here, support means supporting .NET development for accessing IOT platforms in devices; devices like Raspberry Pi with complete functionality and full hardware configuration can directly connect to servers. Other devices with no network card and very small CPU/memory must only be developed with C language and can only access IOT platforms through gateways. Even if low-level implementations for device connections are done, to connect to an IOT platform, there must be APIs, SDKs, and documentation, and resources for .NET are very, very few.

Personally, I feel that .NET Core has developed well in cloud computing, Docker, website development, etc., whereas in embedded aspects, it seems lacking. Of course, this is just a personal opinion...

If using Windows IoT Core, it doesn't matter whether it's .NET Core or .NET Framework.

Looking forward to the official release of .NET Core 3.

 

 

- - - - - - - -

The above content is only my personal understanding. I am currently a junior student and lack experience. If there are errors or incorrect viewpoints, I sincerely ask the experts for guidance.

If I said something wrong, please don't laugh at me...

- - - - - - - -

Currently interning at Shenzhen Ganwei Software Technology Co., Ltd., which is engaged in

Research and development of IoT technology; research and development of cloud computing technology;

Research and development of big data technology; research and development of blockchain technology;

Research and development of artificial intelligence technology; technical development of computer software;

Computer software system integration; data processing; IT consulting;

IT development; research and development of computer software and hardware, network technology, etc.

The company now needs a large number of .NET Core partners, interested students quickly add me~ referrals are possible~~~

WeChat whuanlex

 

痴者工良

高级程序员劝退师

文章评论