-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
60 changed files
with
11,593 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1 @@ | ||
# Prerequisites | ||
*.d | ||
|
||
# Object files | ||
*.o | ||
*.ko | ||
*.obj | ||
*.elf | ||
|
||
# Linker output | ||
*.ilk | ||
*.map | ||
*.exp | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Libraries | ||
*.lib | ||
*.a | ||
*.la | ||
*.lo | ||
|
||
# Shared objects (inc. Windows DLLs) | ||
*.dll | ||
*.so | ||
*.so.* | ||
*.dylib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app | ||
*.i*86 | ||
*.x86_64 | ||
*.hex | ||
|
||
# Debug files | ||
*.dSYM/ | ||
*.su | ||
*.idb | ||
*.pdb | ||
|
||
# Kernel Module Compile Results | ||
*.mod* | ||
*.cmd | ||
.tmp_versions/ | ||
modules.order | ||
Module.symvers | ||
Mkfile.old | ||
dkms.conf | ||
build/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,222 @@ | ||
###################################### | ||
# target | ||
###################################### | ||
.PHONY:test ilopicaapp iloprawapp sdsapp | ||
|
||
###################################### | ||
# building variables | ||
###################################### | ||
# debug build? | ||
DEBUG = 1 | ||
# optimization | ||
OPT = -Og | ||
|
||
|
||
####################################### | ||
# paths | ||
####################################### | ||
# firmware library path | ||
PERIFLIB_PATH = | ||
|
||
# Build path | ||
BUILD_DIR = build | ||
|
||
###################################### | ||
# source | ||
###################################### | ||
# C sources | ||
C_SOURCES = \ | ||
platform/linux/mx_serial.c \ | ||
platform/linux/mx_stdio.c \ | ||
platform/linux/mx_tick.c \ | ||
platform/linux/mx_uart.c \ | ||
src/helper/cli/mx_cli.c \ | ||
src/helper/emhost/ATCmdParser/ATCmdParser.c \ | ||
src/helper/emhost/emh_alisds.c \ | ||
src/helper/emhost/emh_arg.c \ | ||
src/helper/emhost/emh_ilop.c \ | ||
src/helper/emhost/emh_module.c \ | ||
src/helper/emhost/emh_wlan.c \ | ||
src/helper/mx_utils/mx_ringbuffer.c | ||
|
||
|
||
# ASM sources | ||
ASM_SOURCES = | ||
|
||
|
||
###################################### | ||
# firmware library | ||
###################################### | ||
PERIFLIB_SOURCES = | ||
|
||
|
||
####################################### | ||
# binaries | ||
####################################### | ||
BINPATH = | ||
PREFIX = | ||
CC = $(PREFIX)gcc | ||
AS = $(PREFIX)gcc -x assembler-with-cpp | ||
CP = $(PREFIX)objcopy | ||
AR = $(PREFIX)ar | ||
SZ = $(PREFIX)size | ||
HEX = $(CP) -O ihex | ||
BIN = $(CP) -O binary -S | ||
|
||
####################################### | ||
# CFLAGS | ||
####################################### | ||
# cpu | ||
CPU = | ||
|
||
# fpu | ||
FPU = | ||
|
||
# float-abi | ||
FLOAT-ABI = | ||
|
||
# mcu | ||
MCU = | ||
|
||
# macros for gcc | ||
# AS defines | ||
AS_DEFS = | ||
|
||
# C defines | ||
C_DEFS = -DMX_DEBUG -DMX_CLI_ENABLE | ||
|
||
# AS includes | ||
AS_INCLUDES = | ||
|
||
|
||
# C includes | ||
C_INCLUDES = \ | ||
-Iplatform \ | ||
-Isrc/helper/cli \ | ||
-Isrc/helper/emhost/ATCmdParser \ | ||
-Isrc/helper/emhost \ | ||
-Isrc/helper/mx_utils \ | ||
-Isrc/helper | ||
|
||
|
||
# compile gcc flags | ||
ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections | ||
|
||
CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections | ||
|
||
ifeq ($(DEBUG), 1) | ||
CFLAGS += -g -gdwarf-2 | ||
endif | ||
|
||
# Generate dependency information | ||
CFLAGS += -MMD | ||
|
||
|
||
####################################### | ||
# LDFLAGS | ||
####################################### | ||
|
||
# libraries | ||
LIBS = | ||
LIBDIR = | ||
LDFLAGS = -lpthread -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections | ||
|
||
####################################### | ||
# TARGET | ||
####################################### | ||
ifeq (test,$(findstring test,$(MAKECMDGOALS))) | ||
TARGET = iot-test | ||
C_SOURCES += examples/test/test.c | ||
endif | ||
|
||
ifeq (ilopicaapp,$(findstring ilopicaapp,$(MAKECMDGOALS))) | ||
TARGET = iot-ilopicaapp | ||
C_SOURCES += examples/ilopicaapp/app_event.c \ | ||
examples/ilopicaapp/app_prop.c \ | ||
examples/ilopicaapp/app_service.c \ | ||
examples/ilopicaapp/ilopmain.c \ | ||
examples/ilopicaapp/main.c \ | ||
src/alicloud_ilop/alicloud_ilop.c \ | ||
src/alicloud_ilop/ica_protocol.c | ||
|
||
C_INCLUDES += -Iexamples/ilopicaapp -Isrc/alicloud_ilop | ||
|
||
CFLAGS += -DAT_SUPPORT_ILOP -DILOP_USE_ICA | ||
endif | ||
|
||
ifeq (iloprawapp,$(findstring iloprawapp,$(MAKECMDGOALS))) | ||
TARGET = iot-iloprawapp | ||
C_SOURCES += examples/iloprawapp/app_event.c \ | ||
examples/iloprawapp/app_prop_light.c \ | ||
examples/iloprawapp/app_prop_wifi.c \ | ||
examples/iloprawapp/app_service.c \ | ||
examples/iloprawapp/ilopmain.c \ | ||
examples/iloprawapp/main.c \ | ||
src/alicloud_ilop/alicloud_ilop.c \ | ||
src/alicloud_ilop/raw_protocol.c | ||
|
||
C_INCLUDES += -Iexamples/iloprawapp -Isrc/alicloud_ilop | ||
|
||
CFLAGS += -DAT_SUPPORT_ILOP -DILOP_USE_RAW | ||
endif | ||
|
||
ifeq (sdsapp,$(findstring sdsapp,$(MAKECMDGOALS))) | ||
TARGET = iot-sdsapp | ||
C_SOURCES += examples/sdsapp/sdsapp.c \ | ||
src/alicloud_sds/alicloud_sds.c \ | ||
src/helper/jsmn/jsmn.c \ | ||
src/helper/jsmn/json_escape_str.c \ | ||
src/helper/jsmn/json_generator.c \ | ||
src/helper/jsmn/json_utils.c \ | ||
src/helper/jsmn/json_wrappers.c | ||
|
||
C_INCLUDES += -Isrc/alicloud_sds -Isrc/helper/jsmn | ||
|
||
CFLAGS += -DAT_SUPPORT_ALISDS | ||
endif | ||
|
||
# default action: build all | ||
all test ilopicaapp iloprawapp sdsapp: $(BUILD_DIR)/$(TARGET).elf | ||
|
||
####################################### | ||
# build the application | ||
####################################### | ||
# list of objects | ||
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o))) | ||
vpath %.c $(sort $(dir $(C_SOURCES))) | ||
# list of ASM program objects | ||
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o))) | ||
vpath %.s $(sort $(dir $(ASM_SOURCES))) | ||
|
||
-include $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.d))) | ||
|
||
$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) | ||
@echo compiling $< | ||
@$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ | ||
|
||
$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR) | ||
@echo compiling $< | ||
@$(AS) -c $(CFLAGS) $< -o $@ | ||
|
||
$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile | ||
@echo generating $@ | ||
@$(CC) $(OBJECTS) $(LDFLAGS) -o $@ | ||
@$(SZ) $@ | ||
|
||
$(BUILD_DIR): | ||
mkdir $@ | ||
|
||
####################################### | ||
# clean up | ||
####################################### | ||
clean: | ||
@echo cleaning... | ||
@-rm -fR .dep $(BUILD_DIR) | ||
@echo done | ||
|
||
####################################### | ||
# dependencies | ||
####################################### | ||
# -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) | ||
|
||
# *** EOF *** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# How to use iot-sdk | ||
|
||
|
||
## 1. 简介 | ||
本 sdk 提供一个基于 Linux,通过与 Wi-Fi 模块进行 AT 指令串口通信,实现与阿里云 ILOP 和 sds 直连的 IoT 物联网典型开发应用示例源代码。 | ||
|
||
## 2. 目录结构 | ||
|
||
```c | ||
|---example | ||
| |---ilopicaapp /*ilop平台 ica标准数据格式的demo*/ | ||
| |---iloprawapp /*ilop平台 自定义数据格式的demo*/ | ||
| |---sdsapp /*sds平台的demo*/ | ||
| |---test /*测试demo*/ | ||
| | ||
|---platform | ||
| |---linux /*linux平台相关的接口实现*/ | ||
| |---mx_hal.h | ||
| | ||
|---src | ||
|---alicloud_ilop /*ilop平台的实现*/ | ||
|---alicloud_sds /*sds平台的实现*/ | ||
|---helper /*at指令解析内核*/ | ||
``` | ||
|
||
## 3. Linux 平台开发 | ||
|
||
### 3.1 准备 | ||
|
||
- 串口接入PC,并查询设备,命令:`ls -l /dev/ttyUSB*` | ||
|
||
``` | ||
parallels@parallels-vm:~/iot-sdk$ ls -l /dev/ttyUSB* | ||
crw-rw---- 1 root dialout 188, 0 Sep 3 16:15 /dev/ttyUSB0 | ||
``` | ||
|
||
### 3.2 编译 | ||
iot-sdk 提供四个demo,编译demo的命令格式 `make <demo>` | ||
|
||
- 清除上次的make命令所产生的build文件,命令:`make clean` | ||
|
||
``` | ||
parallels@parallels-vm:~/iot-sdk$ make clean | ||
cleaning... | ||
done | ||
``` | ||
|
||
- 编译测试demo,命令:`make test` | ||
|
||
``` | ||
parallels@parallels-vm:~/iot-sdk$ make test | ||
mkdir build | ||
compiling platform/linux/mx_serial.c | ||
compiling platform/linux/mx_stdio.c | ||
compiling platform/linux/mx_tick.c | ||
compiling platform/linux/mx_uart.c | ||
compiling src/helper/cli/mx_cli.c | ||
compiling src/helper/emhost/ATCmdParser/ATCmdParser.c | ||
compiling src/helper/emhost/emh_alisds.c | ||
compiling src/helper/emhost/emh_arg.c | ||
compiling src/helper/emhost/emh_ilop.c | ||
compiling src/helper/emhost/emh_module.c | ||
compiling src/helper/emhost/emh_wlan.c | ||
compiling src/helper/mx_utils/mx_ringbuffer.c | ||
compiling examples/test/test.c | ||
generating build/iot-test.elf | ||
text data bss dec hex filename | ||
16294 928 3680 20902 51a6 build/iot-test.elf | ||
``` | ||
|
||
- 编译完成后,在build目录下生成 `iot-test.elf` 文件 | ||
|
||
### 3.3 运行 | ||
|
||
- 运行build目录下的elf文件,命令:`./build/iot-test.elf <dev>` | ||
|
||
``` | ||
parallels@parallels-vm:~/iot-sdk$ sudo ./build/iot-test.elf /dev/ttyUSB0 | ||
[sudo] password for parallels: | ||
dev[/dev/ttyUSB0] | ||
open at uart succeed | ||
[APP: test.c: 19] FW version: ilop_AT_v2.1.4 | ||
[APP: test.c: 20] System tick: 757 | ||
``` | ||
|
||
## 4. IoT示例 | ||
|
||
### 4.1 阿里 ilop 平台的标准数据格式demo | ||
|
||
### 4.2 阿里 ilop 平台的透传demo | ||
|
||
## 4. 移植SDK | ||
|
||
- 只需要实现platform/mx_hal.h文件中的函数即可 |
Oops, something went wrong.