主要来体验一下基于机智云平台的物联网应用开发流程。
话不多说, 现在就开始吧!
首先要在你必须先有一个机智云开发者账号,注册好之后就可以进行开发了。 1、创建新产品,用来与我们的GoKit2进行对应。

2、填写设备产品基本信息,这里选择WIFI连接方式,因为我们的板子上只有wifi模块,然后点击保存。

3、然后会跳转到开发向导界面,这里我们要先添加一个数据点,不然没有办法和我们的设备进行数据通信。

4、点击新建数据点。在弹出的页面中进行数据的相关配置。


5、这里我们修改一下“显示名称”,显示名称可以填写中文。显示名称用于在Demo App界面中显示数据点名称。


6、接下来就是重点来了,自动生成应用代码包,这里我们选择对应GoKit2的独立MCU方案。


7、下载生成好的代码。

8、解压好之后,我们来看看目录结构。

9、添加RGB灯驱动文件。这里可以直接从机智云宠物物的历程中直接复制RGB灯驱动文件来使用。粘贴位置如下:

然后打开工程,机智云生工的代码工程使用的是Keil4。我们添加RGB灯驱动文件到工程中。

10、下面我们来修改程序,来实现最终的功能。

在userInit函数中添加RGB灯初始化函数。别忘了添加头文件。

在gizwitsEventProcess函数中添加执行函数。实现RGB灯的亮灭。然后下载程序到开发板,因为我有jlink这里就可以直接下载了!!!

这里说一下代码执行流程吧
main->gizwitsHandle->gizwitsEventProcess
在main函数主循环中不停的调用gizwitsHandle函数,在gizwitsHandle函数里面检查是否有wifi数据包,如果有进行解析,如果有事件信息就执行gizwitsEventProcess函数,我们在gizwitsEventProcess函数中根据接受到的报文进行点灯关灯操作。
11、使用dome_app进行绑定,这里的绑定过程和我上篇里的绑定宠物屋dome的过程一样的,就不一一贴图了,这里直接展示一下效果吧。

