commit
41be90fbe1
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
# Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
# Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
# Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
# Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
# Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
# Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
# Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
# Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
# Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
* Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
# Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
* Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
* Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
* Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
* Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
* Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
# Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
* Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
* Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
* Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
# Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Talkweb Co.ltd.
|
||||
* Copyright (c) 2021 Talkweb Co. Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
@ -53,7 +53,7 @@ static void GryoExampleTask(void)
|
|||
}
|
||||
else
|
||||
{
|
||||
printf("MPU6050 ReadAcc Gyro_Data.Accel[0] ==%d\t Gyro_Data.Accel[1] ==%d\t Gyro_Data.Accel[2] ==%d\n",Gyro_Data.Accel[0],Gyro_Data.Accel[1],Gyro_Data.Accel[2]);
|
||||
printf("MPU6050 ReadAcc Gyro_Data.Accel[0] ==%d\t Gyro_Data.Accel[1] ==%d\t Gyro_Data.Accel[2] ==%d\n", Gyro_Data.Accel[0], Gyro_Data.Accel[1], Gyro_Data.Accel[2]);
|
||||
if (X + 100 < Gyro_Data.Accel[0] || X - 100 > Gyro_Data.Accel[0] || Y + 100 < Gyro_Data.Accel[1] || Y - 100 > Gyro_Data.Accel[1] || Z + 100 < Gyro_Data.Accel[2] || Z - 100 > Gyro_Data.Accel[2])
|
||||
{
|
||||
printf("\r\n*******************led1 off led2 on******************\r\n");
|
||||
|
@ -69,7 +69,7 @@ static void GryoExampleTask(void)
|
|||
X = (int)Gyro_Data.Accel[0];
|
||||
Y = (int)Gyro_Data.Accel[1];
|
||||
Z = (int)Gyro_Data.Accel[2];
|
||||
printf("MPU6050 ReadAcc X ==%d\t Y ==%d\t Z ==%d\n",X,Y,Z);
|
||||
printf("MPU6050 ReadAcc X ==%d\t Y ==%d\t Z ==%d\n", X, Y, Z);
|
||||
}
|
||||
usleep(1000000);
|
||||
}
|
||||
|
@ -94,4 +94,3 @@ static void GyroExampleEntry(void)
|
|||
}
|
||||
|
||||
APP_FEATURE_INIT(GyroExampleEntry);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
* Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Talkweb Co.ltd.
|
||||
* Copyright (c) 2021 Talkweb Co. Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
* Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
* Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
* Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
* Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
* Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
# Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
* Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
|
|
@ -1,12 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
// #include "hiview_log.h"
|
||||
#include "ohos_init.h"
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/netifapi.h"
|
||||
#include "lwip/ip4_addr.h"
|
||||
|
@ -14,7 +27,6 @@
|
|||
|
||||
#include "wifi_device.h"
|
||||
|
||||
|
||||
#define DEF_TIMEOUT 15
|
||||
#define ONE_SECOND 1
|
||||
|
||||
|
@ -33,9 +45,8 @@ WifiEvent g_wifiEventHandler = {0};
|
|||
int sock_fd;
|
||||
int addr_length;
|
||||
|
||||
#define STD_TIMEZONE_OFFSET +8 /* 设置中国 */
|
||||
const int timeZone = 8;
|
||||
|
||||
#define STD_TIMEZONE_OFFSET +8 /* 设置中国 */
|
||||
const int timeZone = 8;
|
||||
|
||||
static void WiFiInit(void);
|
||||
static void WaitSacnResult(void);
|
||||
|
@ -154,14 +165,13 @@ int WifiConnect(const char *ssid, const char *psk)
|
|||
}
|
||||
printf("********************\r\n");
|
||||
|
||||
|
||||
//插件指定的wifi是否存在
|
||||
for(uint8_t i = 0; i < ssid_count; i++)
|
||||
for (uint8_t i = 0; i < ssid_count; i++)
|
||||
{
|
||||
if (strcmp(ssid, wifi_info[i].ssid) == 0)
|
||||
{
|
||||
int result;
|
||||
printf("Select:%3d wireless, Waiting...\r\n", i+1);
|
||||
printf("Select:%3d wireless, Waiting...\r\n", i + 1);
|
||||
//拷贝要连接的热点信息
|
||||
strcpy(select_ap_config.ssid, wifi_info[i].ssid);
|
||||
strcpy(select_ap_config.preSharedKey, psk);
|
||||
|
@ -178,27 +188,25 @@ int WifiConnect(const char *ssid, const char *psk)
|
|||
}
|
||||
}
|
||||
|
||||
if(i == ssid_count-1)
|
||||
if (i == ssid_count - 1)
|
||||
{
|
||||
printf("ERROR: No wifi as expected\r\n");
|
||||
while(1) osDelay(100);
|
||||
while (1)
|
||||
osDelay(100);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//启动DHCP
|
||||
//启动DHCP
|
||||
if (g_lwip_netif)
|
||||
{
|
||||
dhcp_start(g_lwip_netif);
|
||||
printf("begain to dhcp");
|
||||
}
|
||||
|
||||
|
||||
//等待DHCP
|
||||
for(;;)
|
||||
for (;;)
|
||||
{
|
||||
if(dhcp_is_bound(g_lwip_netif) == ERR_OK)
|
||||
if (dhcp_is_bound(g_lwip_netif) == ERR_OK)
|
||||
{
|
||||
printf("<-- DHCP state:OK -->\r\n");
|
||||
|
||||
|
@ -212,10 +220,11 @@ int WifiConnect(const char *ssid, const char *psk)
|
|||
}
|
||||
|
||||
osDelay(100);
|
||||
if (wifi_info != NULL) {
|
||||
if (wifi_info != NULL)
|
||||
{
|
||||
free(wifi_info);
|
||||
wifi_info = NULL;
|
||||
}
|
||||
wifi_info = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -275,4 +284,3 @@ static void WaitSacnResult(void)
|
|||
printf("WaitSacnResult:timeout!\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
# Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
* Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
* Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
* Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Talkweb Co.,ltd.
|
||||
* Copyright (c) 2021 Talkweb Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
|
Loading…
Reference in New Issue