当前位置:首页 > 通信资讯 > 正文

openharmony手机版开源社区(openharmony 应用开发)

openharmony手机版开源社区(openharmony 应用开发)

一.前面的话

说实话,腾讯云物联网平台一直是我比较喜欢的物联网云太平,除了有腾讯大厂作为品质背书之外,提供的sdk也是相当好用,更有腾讯连连小程序可以帮助做界面,调试功能,后端的API有java,c++,Golang,js,python等等语言版本,非常方便,简直是上云首选.

二.首先下载sdk

我们首先来找官方sdk,茫茫文档中给我看到了那熟悉的身影:

openharmony手机版开源社区(openharmony 应用开发)

不得不提一下,2.x版本的OpenHarmony比1.x版本的代码结构清晰多了.

1.实现几个重要接口

这个时候依然要看文档,因为有些函数需要自己实现,具体是哪些呢,在这里:

https://cloud.tencent.com/document/product/1081/48389

这篇文档写了,我们要实现里面的这些接口,此处列举一二:

openharmony手机版开源社区(openharmony 应用开发)

仔细一看,霍,好家伙还不少呢,但是不怕,都是打工人,谁怕谁啊,二话不说我就写,结果就给我给写出来了:

openharmony手机版开源社区(openharmony 应用开发)

自己写好BUILD.gn,跟之前华为云对接一个套路,大家这么聪明,不用我多说了:

  1. # Copyright (c) 2020 Nanjing Xiaoxiongpai Intelligent Technology Co., Ltd.
  2. # Licensed under the Apache License, Version 2.0 (the "License");
  3. # you may not use this file except in compliance with the License.
  4. # You may obtain a copy of the License at
  5. #
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. #
  8. # Unless required by applicable law or agreed to in writing, software
  9. # distributed under the License is distributed on an "AS IS" BASIS,
  10. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. # See the License for the specific language governing permissions and
  12. # limitations under the License.
  13. static_library("qcloud_demo") {
  14. sources = [
  15. # "iot_thread.c",
  16. "light.c",
  17. "light_data_template_sample.c"
  18. ]
  19. cflags = [ "-Wno-unused-variable" ]
  20. cflags += [ "-Wno-unused-but-set-variable" ]
  21. include_dirs = [
  22. ".",
  23. "//foundation/communication/softbus_lite/os_adapter/include",
  24. "//utils/native/lite/include",
  25. "//kernel/liteos_m/components/cmsis/2.0",
  26. "//base/iot_hardware/peripheral/interfaces/kits",
  27. "//third_party"
  28. ]
  29. deps = [
  30. "//third_party/qcloud-iot-explorer-sdk-embedded-c-3.2.0:qcloud_sdk_static",
  31. # "//third_party/qcloud-iot-explorer-sdk-embedded-c-3.2.0/external_libs/mbedtls:mbedtls_static",
  32. ]
  33. }

然后在sample里面的sdk把这个文件夹开启编译:

openharmony手机版开源社区(openharmony 应用开发)

阿不对,下面这个候哥才对,大家可以去他主页关注一下:

https://harmonyos.51cto.com/user/posts/13519852

候哥真大神也,短短一两句话就帮我搞定了,在此特别感谢侯哥的帮助:

openharmony手机版开源社区(openharmony 应用开发)

六.总结

其实对接腾讯云还是蛮简单的,最新版的sdk在打印上也比以前好多了.OpenHarmony的2.x版本优化了不少东西,记得去年这时候用1.x版本对接的时候还是很费劲的,给OpenHarmony团队点赞,也给腾讯云团队点赞

大家赶紧玩起来吧

原文链接:https://harmonyos.51cto.com

如果您对该产品感兴趣,请填写办理(客服微信:xiaoxiongyidong)

为您推荐:

发表评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。