第一次参加物联网竞赛写一下参赛作品的完成流程
完成本次比赛作品大概的流程为
1,选择组委会发的板子这里我们组选的是小熊派开发板
2,对小熊派开发板进行编程使之能够完成数据收集处理上发和响应工作
3,在华为云平台上进行相应的设备注册和调试然后在平台上完成各个设备之间的通信
4,如果要开发APP或小程序端,还要使用华为云平台进行设备数据的订阅让设备数据发送到自己的服务器中
小熊派的编程软件一般为Iot studio和LiteOS Studio两者差不多
在创建项目的时候iot studio会给一些项目demo我们们选择相应的demo工程
然后找到相应的主函数如图(一般来说一个demo里面所有的demo主函数代码都有但只有相应demo的主函数代码才会被编译其他的代码不会被编译,如果要修改的话要去Makefile里去修改路径)这里不推荐这种方法要用那个工程就打开那个工程的demo就行了
#include
#include
#include
#include
#include
#include
#include
#include "E53_SF1.h"
#include "lcd.h"
#include
#include
#define cn_endpoint_id "SDK_LWM2M_NODTLS"
#define cn_app_server "49.4.85.232"
#define cn_app_port "5683"
typedef unsigned char int8u;
typedef char int8s;
typedef unsigned short int16u;
typedef short int16s;
typedef unsigned char int24u;
typedef char int24s;
typedef int int32s;
typedef char string;
typedef char array;
typedef char varstring;
typedef char variant;
#define cn_app_Smoke 0x8
#define cn_app_response_Smoke_Control_Beep 0xa
#define cn_app_Smoke_Control_Beep 0x9
#pragma pack(1)
typedef struct
{
int8u messageId;
int16u Smoke_Value;
} tag_app_Smoke;
typedef struct
{
int8u messageId;
int16u mid;
int8u errcode;
int8u Beep_State;
} tag_app_Response_Smoke_Control_Beep;
typedef struct
{
int8u messageId;
int16u mid;
string Beep[3];
} tag_app_Smoke_Control_Beep;
#pragma pack()
int8_t qr_code = 1;
extern const unsigned char gImage_Huawei_IoT_QR_Code[114720];
E53_SF1_Data_TypeDef E53_SF1_Data;
//if your command is very fast,please use a queue here--TODO
#define cn_app_rcv_buf_len 128
static int s_rcv_buffer[cn_app_rcv_buf_len];
static int s_rcv_datalen;
static osal_semp_t s_rcv_sync;
static void timer1_callback(void *arg)
{
qr_code = !qr_code;
LCD_Clear(WHITE);
if (qr_code == 1)
LCD_Show_Image(0,0,240,239,gImage_Huawei_IoT_QR_Code);
else
{
POINT_COLOR = RED;
LCD_ShowString(40, 10, 200, 16, 24, "IoTCluB BearPi");
LCD_ShowString(15, 50, 210, 16, 24, "LiteOS NB-IoT Demo");
LCD_ShowString(10, 100, 200, 16, 16, "NCDP_IP:");
LCD_ShowString(80, 100, 200, 16, 16, cn_app_server);
LCD_ShowString(10, 150, 200, 16, 16, "NCDP_PORT:");
LCD_ShowString(100, 150, 200, 16, 16, cn_app_port);
}
}
//use this function to push all the message to the buffer
static int app_msg_deal(void *usr_data, en_oc_lwm2m_msg_t type, void *data, int len)
{
unsigned char *msg;
msg = data;
int ret = -1;
if(len <= cn_app_rcv_buf_len)