支持语音OTA升级
This commit is contained in:
parent
99ee61b8c9
commit
7d81c0f348
@ -12,7 +12,8 @@
|
|||||||
#include "components/bk_uid.h"
|
#include "components/bk_uid.h"
|
||||||
#include "bk_genie_comm.h"
|
#include "bk_genie_comm.h"
|
||||||
#include "iot_lamp.h"
|
#include "iot_lamp.h"
|
||||||
|
//OTA
|
||||||
|
#include "modules/ota.h"
|
||||||
#include "spi_led.h"
|
#include "spi_led.h"
|
||||||
|
|
||||||
#define TAG "iot_lamp"
|
#define TAG "iot_lamp"
|
||||||
@ -24,7 +25,8 @@
|
|||||||
|
|
||||||
#define IOT_LAMP_DEVICE_NAME "lamp"
|
#define IOT_LAMP_DEVICE_NAME "lamp"
|
||||||
#define IOT_LAMP_DEVICE_FUNS_SET_BRIGHTNESS "SetBrightness"
|
#define IOT_LAMP_DEVICE_FUNS_SET_BRIGHTNESS "SetBrightness"
|
||||||
|
#define IOT_LAMP_DEVICE_GET_BATTERY "GetBattery"
|
||||||
|
#define IOT_LAMP_DEVICE_OTA "ota"
|
||||||
|
|
||||||
void lamp_init(){
|
void lamp_init(){
|
||||||
//ws2812_init();
|
//ws2812_init();
|
||||||
@ -38,7 +40,7 @@ cJSON* iot_lamp_get_device_desc(){
|
|||||||
|
|
||||||
cJSON *lamp_desc = cJSON_CreateObject();
|
cJSON *lamp_desc = cJSON_CreateObject();
|
||||||
cJSON_AddStringToObject(lamp_desc, "name", IOT_LAMP_DEVICE_NAME);
|
cJSON_AddStringToObject(lamp_desc, "name", IOT_LAMP_DEVICE_NAME);
|
||||||
cJSON_AddStringToObject(lamp_desc, "description", "这是乐小牛的灯光");
|
cJSON_AddStringToObject(lamp_desc, "description", "这是拍拍灯");
|
||||||
|
|
||||||
cJSON *properties = cJSON_CreateObject();
|
cJSON *properties = cJSON_CreateObject();
|
||||||
//定义brightness 属性
|
//定义brightness 属性
|
||||||
@ -68,12 +70,12 @@ cJSON* iot_lamp_get_device_desc(){
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
cJSON *SetBrightness = cJSON_CreateObject();
|
cJSON *SetBrightness = cJSON_CreateObject();
|
||||||
cJSON_AddStringToObject(SetBrightness, "description", "设置亮度");
|
cJSON_AddStringToObject(SetBrightness, "description", "打开关闭灯光以及设置亮度");
|
||||||
|
|
||||||
cJSON *parameters = cJSON_CreateObject();
|
cJSON *parameters = cJSON_CreateObject();
|
||||||
cJSON *p_brightness = cJSON_CreateObject();
|
cJSON *p_brightness = cJSON_CreateObject();
|
||||||
cJSON_AddStringToObject(p_brightness, "type", "number");
|
cJSON_AddStringToObject(p_brightness, "type", "number");
|
||||||
cJSON_AddStringToObject(p_brightness, "description", "0到100之间的整数 0关灯");
|
cJSON_AddStringToObject(p_brightness, "description", "0到100之间的整数 0表示关灯 非0表示打开,默认100");
|
||||||
|
|
||||||
|
|
||||||
cJSON_AddItemToObjectCS(parameters,"brightness",p_brightness);
|
cJSON_AddItemToObjectCS(parameters,"brightness",p_brightness);
|
||||||
@ -81,6 +83,16 @@ cJSON* iot_lamp_get_device_desc(){
|
|||||||
|
|
||||||
//cJSON_AddStringToObject(SetBrightness, "type", "number");
|
//cJSON_AddStringToObject(SetBrightness, "type", "number");
|
||||||
cJSON_AddItemToObjectCS(methods,IOT_LAMP_DEVICE_FUNS_SET_BRIGHTNESS,SetBrightness);
|
cJSON_AddItemToObjectCS(methods,IOT_LAMP_DEVICE_FUNS_SET_BRIGHTNESS,SetBrightness);
|
||||||
|
|
||||||
|
|
||||||
|
cJSON *methods_ota = cJSON_CreateObject();
|
||||||
|
cJSON_AddStringToObject(methods_ota, "description", "升级拍拍灯软件[必须要用户二次确认]");
|
||||||
|
|
||||||
|
|
||||||
|
//cJSON_AddStringToObject(SetBrightness, "type", "number");
|
||||||
|
cJSON_AddItemToObjectCS(methods,IOT_LAMP_DEVICE_OTA,methods_ota);
|
||||||
|
|
||||||
|
|
||||||
cJSON_AddItemToObjectCS(lamp_desc,"methods",methods);
|
cJSON_AddItemToObjectCS(lamp_desc,"methods",methods);
|
||||||
|
|
||||||
//打印一下描述
|
//打印一下描述
|
||||||
@ -94,6 +106,36 @@ void iot_lamp_report_state(int brightness){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if CONFIG_OTA_HTTPS
|
||||||
|
|
||||||
|
int bk_https_ota_download(const char *url);
|
||||||
|
void bk_https_start_download(beken_thread_arg_t arg) {
|
||||||
|
int ret;
|
||||||
|
ret = bk_http_ota_download("http://106.52.233.130:8888/ir58_ota.rbl");
|
||||||
|
//ret = bk_https_ota_download("https://xiaozhi.xa-poka.com/xiaozhi/otaMag/download/59cc091e-eaf3-417d-a524-d5e3d95883f4");
|
||||||
|
if(ret != BK_OK) {
|
||||||
|
os_printf("%s download fail, ret:%d\r\n", __func__, ret);
|
||||||
|
}
|
||||||
|
rtos_delete_thread(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void https_ota_start(void)
|
||||||
|
{
|
||||||
|
UINT32 ret;
|
||||||
|
|
||||||
|
os_printf("https_ota_start\r\n");
|
||||||
|
ret = rtos_create_thread(NULL, BEKEN_APPLICATION_PRIORITY,
|
||||||
|
"https_ota",
|
||||||
|
(beken_thread_function_t)bk_https_start_download,
|
||||||
|
5120,
|
||||||
|
0);
|
||||||
|
|
||||||
|
if (kNoErr != ret)
|
||||||
|
os_printf("https_ota_start failed\r\n");
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void iot_lamp_parser_invoke(char* cmd,char * paramters_json){
|
void iot_lamp_parser_invoke(char* cmd,char * paramters_json){
|
||||||
|
|
||||||
//设置亮度
|
//设置亮度
|
||||||
@ -108,9 +150,15 @@ void iot_lamp_parser_invoke(char* cmd,char * paramters_json){
|
|||||||
if(brightness == 0){
|
if(brightness == 0){
|
||||||
ws2812_led_clear_all();
|
ws2812_led_clear_all();
|
||||||
}else{
|
}else{
|
||||||
ws2812_set_all_led(0xFFFFFF,1);
|
//ws2812_set_all_led(0xFFFFFF,brightness);
|
||||||
|
ws2812_set_all_led_brightness(brightness);
|
||||||
}
|
}
|
||||||
cJSON_Delete(params);
|
cJSON_Delete(params);
|
||||||
}
|
}
|
||||||
|
else if (strcmp(cmd, IOT_LAMP_DEVICE_OTA) == 0){
|
||||||
|
LOGE("invoke ota !!\n");
|
||||||
|
ws2812_led_start_ota();
|
||||||
|
https_ota_start();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,8 @@ const bk_logic_partition_t bk_flash_partitions[BK_PARTITION_MAX_USER] = {
|
|||||||
.partition_owner = BK_FLASH_EMBEDDED,
|
.partition_owner = BK_FLASH_EMBEDDED,
|
||||||
.partition_description = "ota",
|
.partition_description = "ota",
|
||||||
.partition_start_addr = 0x4c8000,
|
.partition_start_addr = 0x4c8000,
|
||||||
.partition_length = 0x77000,
|
//.partition_length = 0x77000,
|
||||||
|
.partition_length = 0x31F000,
|
||||||
.partition_options = PAR_OPT_EXECUTE_DIS | PAR_OPT_READ_EN | PAR_OPT_WRITE_DIS,
|
.partition_options = PAR_OPT_EXECUTE_DIS | PAR_OPT_READ_EN | PAR_OPT_WRITE_DIS,
|
||||||
},
|
},
|
||||||
[BK_PARTITION_USR_CONFIG_USER] =
|
[BK_PARTITION_USR_CONFIG_USER] =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user