This commit is contained in:
openshwprojects
2022-02-02 21:21:53 +01:00
18 changed files with 142 additions and 83 deletions

View File

@@ -241,7 +241,7 @@ int httpclient_get_info(httpclient_t *client, char *send_buf, int *send_idx, cha
return SUCCESS_RETURN;
}
void httpclient_set_custom_header(httpclient_t *client, char *header)
void httpclient_set_custom_header(httpclient_t *client, const char *header)
{
client->header = header;
}
@@ -353,7 +353,7 @@ int httpclient_send_header(httpclient_t *client, const char *url, int method, ht
}
if (client_data->post_buf != NULL) {
snprintf(buf, HTTPCLIENT_SEND_BUF_SIZE, "Content-Length: %d\r\n", client_data->post_buf_len);
snprintf(buf, HTTPCLIENT_SEND_BUF_SIZE, "Content-Length: %u\r\n", (unsigned int)client_data->post_buf_len);
httpclient_get_info(client, send_buf, &len, buf, os_strlen(buf));
if (client_data->post_content_type != NULL) {
@@ -454,14 +454,14 @@ int httpclient_recv(httpclient_t *client, char *buf, int min_len, int max_len, i
int httpclient_retrieve_content(httpclient_t *client, char *data, int len, uint32_t timeout_ms,
httpclient_data_t *client_data)
{
int count = 0;
int templen = 0;
int crlf_pos;
iotx_time_t timer;
char * b_data = NULL;
//int count = 0;
//int templen = 0;
//int crlf_pos;
//iotx_time_t timer;
//char * b_data = NULL;
iotx_time_init(&timer);
utils_time_countdown_ms(&timer, timeout_ms);
//iotx_time_init(&timer);
//utils_time_countdown_ms(&timer, timeout_ms);
/* Receive data */
log_debug("Current data len: %d\r\n", len);
@@ -481,6 +481,7 @@ int httpclient_retrieve_content(httpclient_t *client, char *data, int len, uint3
#ifdef INCLUDE_OLD_FUNCTION
// called with data and len from header parser.
// called with len = 0 when getting more
int httpclient_retrieve_content_old(httpclient_t *client, char *data, int len, uint32_t timeout_ms,
@@ -687,6 +688,8 @@ int httpclient_retrieve_content_old(httpclient_t *client, char *data, int len, u
return SUCCESS_RETURN;
}
#endif
int httpclient_response_parse(httpclient_t *client, char *data, int len, uint32_t timeout_ms,
httpclient_data_t *client_data)
@@ -769,7 +772,7 @@ int httpclient_response_parse(httpclient_t *client, char *data, int len, uint32_
if (n == 2) {
log_debug("Read header : %s: %s\r\n", key, value);
if (!os_strcmp(key, "Content-Length")) {
sscanf(value, "%d", &(client_data->response_content_len));
sscanf(value, "%d", (int *)&(client_data->response_content_len));
client_data->retrieve_len = client_data->response_content_len;
} else if (!os_strcmp(key, "Transfer-Encoding")) {
if (!os_strcmp(value, "Chunked") || !os_strcmp(value, "chunked")) {
@@ -977,7 +980,7 @@ static void httprequest_thread( beken_thread_arg_t arg )
const char *header = request->header;
int port = request->port;
const char *ca_crt = request->ca_crt;
uint32_t timeout = request->timeout;
//uint32_t timeout = request->timeout;
httpclient_data_t *client_data = &request->client_data;
int method = request->method;
int timeout_ms = request->timeout;

View File

@@ -64,7 +64,7 @@ typedef struct {
int remote_port; /**< HTTP or HTTPS port. */
utils_network_t net;
int response_code; /**< Response code. */
char *header; /**< Custom header. */
const char *header; /**< Custom header. */
char *auth_user; /**< Username for basic authentication. */
char *auth_password; /**< Password for basic authentication. */
} httpclient_t;
@@ -143,6 +143,7 @@ typedef struct httprequest_t_tag{
* @endcode
*/
int async_request(httprequest_t *request);
void httpclient_set_custom_header(httpclient_t *client, const char *header);
#ifdef __cplusplus
}

View File

@@ -94,7 +94,7 @@ uint32_t utils_time_get_ms(void)
uint64_t utils_time_left(uint64_t t_end, uint64_t t_now)
{
uint64_t t_left;
//uint64_t t_left;
return (1!=(hal_machw_time_past(t_end*1000)));
}

View File

@@ -1,8 +1,11 @@
#include "../new_common.h"
#include "ctype.h"
#include "lwip/sockets.h"
#include "lwip/ip_addr.h"
#include "lwip/inet.h"
#include "../logging/logging.h"
#include "new_http.h"
#include "str_pub.h"
static void tcp_server_thread( beken_thread_arg_t arg );
static void tcp_client_thread( beken_thread_arg_t arg );
@@ -29,11 +32,11 @@ static void tcp_client_thread( beken_thread_arg_t arg )
OSStatus err = kNoErr;
int fd = (int) arg;
int len = 0;
fd_set readfds, errfds, readfds2;
//fd_set readfds, errfds, readfds2;
char *buf = NULL;
char *reply = NULL;
int replyBufferSize = 10000;
int res;
//int res;
//char reply[8192];
//my_fd = fd;

View File

@@ -1,8 +1,13 @@
#include "../new_common.h"
#include "ctype.h"
#include "str_pub.h"
#include "new_http.h"
#include "../new_pins.h"
#include "../new_cfg.h"
#include "../ota/ota.h"
#include "tuya_hal_storge.h"
/*
GET / HTTP/1.1
@@ -114,8 +119,9 @@ const char *http_checkArg(const char *p, const char *n) {
}
return p;
}
void http_copyCarg(const char *at, char *to, int maxSize) {
char a, b;
void http_copyCarg(const char *atin, char *to, int maxSize) {
int a, b;
const unsigned char *at = (unsigned char *)atin;
while(*at != 0 && *at != '&' && *at != ' ' && maxSize > 1) {
#if 0
@@ -181,13 +187,15 @@ const char *htmlIndex = "<select name=\"cars\" id=\"cars\">\
<option value=\"1\">qqqqqq</option>\
<option value=\"2\">qqq</option>\
</select>";
//const char *htmlPinRoles = "<option value=\"1\">Relay</option>\
//<option value=\"2\">Relay_n</option>\
//<option value=\"3\">Button</option>\
//<option value=\"4\">Button_n</option>\
//<option value=\"5\">LED</option>\
//<option value=\"6\">LED_n</option>\
//</select>";
/*
const char *htmlPinRoles = "<option value=\"1\">Relay</option>\
<option value=\"2\">Relay_n</option>\
<option value=\"3\">Button</option>\
<option value=\"4\">Button_n</option>\
<option value=\"5\">LED</option>\
<option value=\"6\">LED_n</option>\
</select>";
*/
const char *htmlPinRoleNames[] = {
" ",
@@ -253,7 +261,7 @@ int HTTP_ProcessPacket(const char *recvbuf, char *outbuf, int outBufSize) {
char tmpA[128];
char tmpB[64];
char tmpC[64];
int bChanged = 0;
//int bChanged = 0;
const char *urlStr;
*outbuf = '\0';

View File

@@ -8,6 +8,7 @@ extern const char htmlEnd[];
extern const char htmlReturnToMenu[];
int HTTP_ProcessPacket(const char *recvbuf, char *outbuf, int outBufSize);
void http_setup(char *o, const char *type);
// callback function for http

View File

@@ -2,6 +2,7 @@
#include "../new_common.h"
#include "../logging/logging.h"
#include "../httpserver/new_http.h"
#include "str_pub.h"
static int http_getlog(const char *payload, char *outbuf, int outBufSize);
@@ -208,7 +209,7 @@ void log_server_thread( beken_thread_arg_t arg )
}
if ( err != kNoErr )
tcp_server_log( "Server listerner thread exit with err: %d", err );
addLog( "Server listerner thread exit with err: %d", err );
close( tcp_listen_fd );
rtos_delete_thread( NULL );
@@ -218,16 +219,8 @@ void log_server_thread( beken_thread_arg_t arg )
static char tcplogbuf[TCPLOGBUFSIZE];
static void log_client_thread( beken_thread_arg_t arg )
{
OSStatus err = kNoErr;
int fd = (int) arg;
int len = 0;
fd_set readfds, errfds, readfds2;
char *buf = NULL;
char *reply = NULL;
int replyBufferSize = 128;
int res;
while ( 1 ){
int count = getTcp(tcplogbuf, TCPLOGBUFSIZE);
if (count){
@@ -240,9 +233,7 @@ static void log_client_thread( beken_thread_arg_t arg )
rtos_delay_milliseconds(10);
}
exit:
if ( err != kNoErr )
addLog( "TCP client thread exit with err: %d", err );
addLog( "TCP client thread exit with err: %d", len );
close( fd );
rtos_delete_thread( NULL );

View File

@@ -1,7 +1,4 @@
#include "new_common.h"
#include "httpserver/new_http.h"
#include "new_pins.h"
@@ -34,7 +31,7 @@ const char *CFG_GetShortDeviceName(){
}
void CFG_CreateDeviceNameUnique()
{
u8 mac[32];
char mac[32];
#if WINDOWS
#else
@@ -100,7 +97,7 @@ void CFG_SaveWiFi() {
ITEM_NEW_WIFI_CONFIG container;
strcpy_safe(container.ssid, g_wifi_ssid, sizeof(container.ssid));
strcpy_safe(container.pass, g_wifi_pass, sizeof(container.pass));
save_info_item(NEW_WIFI_CONFIG,&container, 0, 0);
save_info_item(NEW_WIFI_CONFIG,(UINT8 *)&container, 0, 0);
#endif
}
void CFG_LoadWiFi() {
@@ -108,7 +105,7 @@ void CFG_LoadWiFi() {
#else
ITEM_NEW_WIFI_CONFIG container;
if(get_info_item(NEW_WIFI_CONFIG,&container, 0, 0) != 0) {
if(get_info_item(NEW_WIFI_CONFIG,(UINT8 *)&container, 0, 0) != 0) {
strcpy_safe(g_wifi_ssid,container.ssid,sizeof(g_wifi_ssid));
strcpy_safe(g_wifi_pass,container.pass,sizeof(g_wifi_pass));
}
@@ -125,7 +122,7 @@ void CFG_SaveMQTT() {
strcpy_safe(container.hostName, g_mqtt_host, sizeof(container.hostName));
strcpy_safe(container.brokerName, g_mqtt_brokerName, sizeof(container.brokerName));
container.port = g_mqtt_port;
save_info_item(NEW_MQTT_CONFIG,&container, 0, 0);
save_info_item(NEW_MQTT_CONFIG,(UINT8 *)&container, 0, 0);
#endif
}
@@ -134,7 +131,7 @@ void CFG_LoadMQTT() {
#else
ITEM_NEW_MQTT_CONFIG container;
if(get_info_item(NEW_MQTT_CONFIG,&container, 0, 0) != 0) {
if(get_info_item(NEW_MQTT_CONFIG,(UINT8 *)&container, 0, 0) != 0) {
strcpy_safe(g_mqtt_userName,container.userName,sizeof(g_mqtt_userName));
strcpy_safe(g_mqtt_pass,container.pass,sizeof(g_mqtt_pass));
strcpy_safe(g_mqtt_host,container.hostName,sizeof(g_mqtt_host));

View File

@@ -0,0 +1,24 @@
const char *CFG_GetDeviceName();
const char *CFG_GetShortDeviceName();
void CFG_CreateDeviceNameUnique();
int CFG_GetMQTTPort();
void CFG_SetMQTTPort(int p);
void CFG_SetOpenAccessPoint();
const char *CFG_GetWiFiSSID();
const char *CFG_GetWiFiPass();
void CFG_SetWiFiSSID(const char *s);
void CFG_SetWiFiPass(const char *s);
const char *CFG_GetMQTTHost();
const char *CFG_GetMQTTBrokerName();
const char *CFG_GetMQTTUserName();
const char *CFG_GetMQTTPass();
void CFG_SetMQTTHost(const char *s);
void CFG_SetMQTTBrokerName(const char *s);
void CFG_SetMQTTUserName(const char *s);
void CFG_SetMQTTPass(const char *s);
void CFG_SaveWiFi();
void CFG_LoadWiFi();
void CFG_SaveMQTT();
void CFG_LoadMQTT();

View File

@@ -1,5 +1,5 @@
#include "new_common.h"
#include "ctype.h"
// returns amount of space left in buffer (0=overflow happened)
int strcat_safe(char *tg, const char *src, int tgMaxLen) {
@@ -49,10 +49,12 @@ int strcpy_safe(char *tg, const char *src, int tgMaxLen) {
return tgMaxLen-curOfs;
}
void urldecode2_safe(char *dst, const char *src, int maxDstLen)
void urldecode2_safe(char *dst, const char *srcin, int maxDstLen)
{
int curLen = 1;
char a, b;
int a, b;
// avoid signing issues in conversion to int for isxdigit(int c)
const unsigned char *src = (const unsigned char *)srcin;
while (*src) {
if(curLen>=maxDstLen)
break;

View File

@@ -48,5 +48,6 @@ typedef unsigned char byte;
int strcat_safe(char *tg, const char *src, int tgMaxLen);
int strcpy_safe(char *tg, const char *src, int tgMaxLen);
void urldecode2_safe(char *dst, const char *srcin, int maxDstLen);

View File

@@ -12,6 +12,8 @@
#else
#include "../../beken378/func/include/net_param_pub.h"
#include "../../beken378/func/user_driver/BkDriverPwm.h"
#undef PR_DEBUG
#undef PR_NOTICE
#define PR_DEBUG addLog
#define PR_NOTICE addLog
@@ -79,14 +81,14 @@ void (*g_doubleClickCallback)(int pinIndex) = 0;
void PIN_SaveToFlash() {
#if WINDOWS
#else
save_info_item(NEW_PINS_CONFIG,&g_pins, 0, 0);
save_info_item(NEW_PINS_CONFIG,(UINT8 *)&g_pins, 0, 0);
#endif
}
void PIN_LoadFromFlash() {
int i;
#if WINDOWS
#else
get_info_item(NEW_PINS_CONFIG,&g_pins, 0, 0);
get_info_item(NEW_PINS_CONFIG,(UINT8 *)&g_pins, 0, 0);
#endif
for(i = 0; i < GPIO_MAX; i++) {
PIN_SetPinRoleForPinIndex(i,g_pins.roles[i]);
@@ -158,7 +160,7 @@ void PIN_SetPinRoleForPinIndex(int index, int role) {
#else
{
BUTTON_S *bt = &g_buttons[index];
//BUTTON_S *bt = &g_buttons[index];
// TODO: disable button
}
#endif
@@ -177,7 +179,7 @@ void PIN_SetPinRoleForPinIndex(int index, int role) {
case IOR_PWM:
{
int pwmIndex;
int channelIndex;
//int channelIndex;
pwmIndex = PIN_GetPWMIndexForPinIndex(index);
#if WINDOWS

View File

@@ -21,6 +21,7 @@ enum IORole {
#define GPIO_MAX 27
#define CHANNEL_MAX 32
void PIN_Init(void);
void PIN_ClearPins();
int PIN_GetPinRoleForPinIndex(int index);
int PIN_GetPinChannelForPinIndex(int index);

View File

@@ -2,6 +2,7 @@
#include "../new_common.h"
#include "typedef.h"
#include "flash_pub.h"
//#include "flash.h"
#include "../logging/logging.h"
#include "../httpclient/http_client.h"
@@ -11,12 +12,20 @@ int sectorlen = 0;
unsigned int addr = 0xff000;
#define SECTOR_SIZE 0x1000
static void store_sector(unsigned int addr, unsigned char *data);
extern void flash_protection_op(UINT8 mode,PROTECT_TYPE type);
// from wlan_ui.c
void bk_reboot(void);
// from flash.c
extern UINT32 flash_read(char *user_buf, UINT32 count, UINT32 address);
extern UINT32 flash_write(char *user_buf, UINT32 count, UINT32 address);
extern UINT32 flash_ctrl(UINT32 cmd, void *parm);
int init_ota(unsigned int startaddr){
flash_init();
flash_protection_op(FLASH_XTX_16M_SR_WRITE_ENABLE, FLASH_PROTECT_NONE);
flash_protection_op(FLASH_XTX_16M_SR_WRITE_ENABLE, FLASH_PROTECT_NONE);
if (startaddr > 0xff000){
if (sector){
addLog("aborting OTS, sector already non-null\n");
@@ -46,7 +55,7 @@ void close_ota(){
os_free(sector);
sector = (void *)0;
flash_protection_op(FLASH_XTX_16M_SR_WRITE_ENABLE, FLASH_UNPROTECT_LAST_BLOCK);
flash_protection_op(FLASH_XTX_16M_SR_WRITE_ENABLE, FLASH_UNPROTECT_LAST_BLOCK);
}
void add_otadata(unsigned char *data, int len){
@@ -81,7 +90,7 @@ static void store_sector(unsigned int addr, unsigned char *data){
flash_ctrl(CMD_FLASH_WRITE_ENABLE, (void *)0);
flash_ctrl(CMD_FLASH_ERASE_SECTOR, &addr);
flash_ctrl(CMD_FLASH_WRITE_ENABLE, (void *)0);
flash_write(data , SECTOR_SIZE, addr);
flash_write((char *)data , SECTOR_SIZE, addr);
}
@@ -90,7 +99,7 @@ int total_bytes = 0;
int myhttpclientcallback(httprequest_t* request){
httpclient_t *client = &request->client;
//httpclient_t *client = &request->client;
httpclient_data_t *client_data = &request->client_data;
// NOTE: Called from the client thread, beware
@@ -104,7 +113,7 @@ int myhttpclientcallback(httprequest_t* request){
break;
case 1: // data
if (request->client_data.response_buf_filled){
unsigned char *d = request->client_data.response_buf;
unsigned char *d = (unsigned char *)request->client_data.response_buf;
int l = request->client_data.response_buf_filled;
add_otadata(d, l);
}
@@ -134,7 +143,7 @@ int myhttpclientcallback(httprequest_t* request){
// NOTE: these MUST persist
// note: url must have a '/' after host, else it can;t parse it..
static char url[256] = "http://raspberrypi:1880/firmware";
static char *header = "";
static const char *header = "";
static char *content_type = "text/csv";
static char *post_data = "";
#define BUF_SIZE 1024
@@ -165,7 +174,7 @@ void otarequest(const char *urlin){
}
client_data->response_buf = http_buf; //Sets a buffer to store the result.
client_data->response_buf_len = BUF_SIZE; //Sets the buffer size.
httpclient_set_custom_header(&client, header); //Sets the custom header if needed.
httpclient_set_custom_header(client, header); //Sets the custom header if needed.
client_data->post_buf = post_data; //Sets the user data to be posted.
client_data->post_buf_len = strlen(post_data); //Sets the post data length.
client_data->post_content_type = content_type; //Sets the content type.

View File

@@ -8,3 +8,5 @@ void add_otadata(unsigned char *data, int len);
// finalise OTA flash (write last sector if incomplete)
int close_ota();
void otarequest(const char *urlin);

View File

@@ -1,4 +1,9 @@
#include "../new_common.h"
#include "str_pub.h"
#include "wlan_ui_pub.h"
#include "net.h"
#include "../logging/logging.h"
#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]

View File

@@ -0,0 +1 @@
void print_network_info();

View File

@@ -29,18 +29,29 @@
#include "lwip/ip_addr.h"
#include "lwip/inet.h"
#include "mem_pub.h"
#include "str_pub.h"
#include "ethernet_intf.h"
/* Private includes ----------------------------------------------------------*/
#include "tuya_device.h"
#include "httpserver/new_http.h"
#include "new_pins.h"
#include "new_cfg.h"
#include "logging/logging.h"
#include "httpserver/http_tcp_server.h"
#include "printnetinfo/printnetinfo.h"
#include "../../beken378/func/key/multi_button.h"
#include "../../beken378/app/config/param_config.h"
#include "lwip/apps/mqtt.h"
#undef os_printf
#undef PR_DEBUG
#undef PR_NOTICE
#undef Malloc
#undef Free
#define os_printf addLog
#define PR_DEBUG addLog
#define PR_NOTICE addLog
@@ -55,6 +66,10 @@ int g_my_reconnect_mqtt_after_time = -1;
#define tcp_server_log(M, ...) os_printf("TCP", M, ##__VA_ARGS__)
// from wlan_ui.c, no header
void bk_wlan_status_register_cb(FUNC_1PARAM_PTR cb);
int unw_recv(const int fd, void *buf, u32 nbytes)
{
fd_set readfds, errfds;
@@ -90,7 +105,7 @@ void connect_to_wifi(const char *oob_ssid,const char *connect_key)
os_memset( &wNetConfigAdv, 0x0, sizeof(network_InitTypeDef_adv_st) );
os_strcpy((char*)wNetConfigAdv.ap_info.ssid, oob_ssid);
hwaddr_aton("48:ee:0c:48:93:12", wNetConfigAdv.ap_info.bssid);
hwaddr_aton("48:ee:0c:48:93:12", (u8 *)wNetConfigAdv.ap_info.bssid);
wNetConfigAdv.ap_info.security = SECURITY_TYPE_WPA2_MIXED;
wNetConfigAdv.ap_info.channel = 5;
@@ -204,11 +219,13 @@ int g_incoming_channel_mqtt = 0;
static void mqtt_incoming_data_cb(void *arg, const u8_t *data, u16_t len, u8_t flags)
{
int iValue;
const struct mqtt_connect_client_info_t* client_info = (const struct mqtt_connect_client_info_t*)arg;
// unused - left here as example
//const struct mqtt_connect_client_info_t* client_info = (const struct mqtt_connect_client_info_t*)arg;
//PR_NOTICE("MQTT client in mqtt_incoming_data_cb\n");
PR_NOTICE("MQTT client in mqtt_incoming_data_cb data is %s for ch %i\n",data,g_incoming_channel_mqtt);
iValue = atoi(data);
iValue = atoi((char *)data);
CHANNEL_Set(g_incoming_channel_mqtt,iValue,0);
// PR_NOTICE(("MQTT client \"%s\" data cb: len %d, flags %d\n", client_info->client_id, (int)len, (int)flags));
@@ -217,7 +234,9 @@ static void mqtt_incoming_data_cb(void *arg, const u8_t *data, u16_t len, u8_t f
static void mqtt_incoming_publish_cb(void *arg, const char *topic, u32_t tot_len)
{
const char *p;
const struct mqtt_connect_client_info_t* client_info = (const struct mqtt_connect_client_info_t*)arg;
// unused - left here as example
//const struct mqtt_connect_client_info_t* client_info = (const struct mqtt_connect_client_info_t*)arg;
//PR_NOTICE("MQTT client in mqtt_incoming_publish_cb\n");
PR_NOTICE("MQTT client in mqtt_incoming_publish_cb topic %s\n",topic);
// TODO: better
@@ -239,7 +258,7 @@ mqtt_request_cb(void *arg, err_t err)
{
const struct mqtt_connect_client_info_t* client_info = (const struct mqtt_connect_client_info_t*)arg;
PR_NOTICE(("MQTT client \"%s\" request cb: err %d\n", client_info->client_id, (int)err));
PR_NOTICE("MQTT client \"%s\" request cb: err %d\n", client_info->client_id, (int)err);
}
static void mqtt_sub_request_cb(void *arg, err_t result)
{
@@ -251,7 +270,6 @@ static void mqtt_sub_request_cb(void *arg, err_t result)
void example_do_connect(mqtt_client_t *client);
static void mqtt_connection_cb(mqtt_client_t *client, void *arg, mqtt_connection_status_t status)
{
int i;
char tmp[64];
const char *baseName;
err_t err = ERR_OK;
@@ -302,11 +320,9 @@ static void mqtt_connection_cb(mqtt_client_t *client, void *arg, mqtt_connection
void example_do_connect(mqtt_client_t *client)
{
err_t err;
const char *mqtt_userName, *mqtt_host, *mqtt_pass, *mqtt_clientID;
int mqtt_port;
mqtt_userName = CFG_GetMQTTUserName();
mqtt_pass = CFG_GetMQTTPass();
mqtt_clientID = CFG_GetMQTTBrokerName();
@@ -330,12 +346,6 @@ void example_do_connect(mqtt_client_t *client)
&mqtt_ip, mqtt_port,
mqtt_connection_cb, LWIP_CONST_CAST(void*, &mqtt_client_info),
&mqtt_client_info);
/* For now just print the result code if something goes wrong */
if(err != ERR_OK) {
PR_NOTICE("mqtt_connect return %d\n", err);
}
}
@@ -411,9 +421,9 @@ static int setup_wifi_open_access_point(void)
PR_NOTICE("no flash configuration, use default\r\n");
mac = (u8*)&ap_info.bssid.array;
// this is MAC for Access Point, it's different than Client one
// see wifi_get_mac_address source
wifi_get_mac_address(mac, CONFIG_ROLE_AP);
// this is MAC for Access Point, it's different than Client one
// see wifi_get_mac_address source
wifi_get_mac_address((char *)mac, CONFIG_ROLE_AP);
ap_info.chann = APP_DRONE_DEF_CHANNEL;
ap_info.cipher_suite = 0;
//os_memcpy(ap_info.ssid.array, APP_DRONE_DEF_SSID, os_strlen(APP_DRONE_DEF_SSID));
@@ -425,10 +435,10 @@ static int setup_wifi_open_access_point(void)
bk_wlan_ap_set_default_channel(ap_info.chann);
len = os_strlen(ap_info.ssid.array);
len = os_strlen((char *)ap_info.ssid.array);
os_strcpy((char *)wNetConfig.wifi_ssid, ap_info.ssid.array);
os_strcpy((char *)wNetConfig.wifi_key, ap_info.key);
os_strcpy((char *)wNetConfig.wifi_ssid, (char *)ap_info.ssid.array);
os_strcpy((char *)wNetConfig.wifi_key, (char *)ap_info.key);
wNetConfig.wifi_mode = SOFT_AP;
wNetConfig.dhcp_mode = DHCP_SERVER;
@@ -507,7 +517,7 @@ void user_main(void)
int bForceOpenAP = 0;
const char *wifi_ssid, *wifi_pass;
OPERATE_RET op_ret = OPRT_OK;
//OPERATE_RET op_ret = OPRT_OK;
CFG_CreateDeviceNameUnique();
@@ -561,6 +571,4 @@ void user_main(void)
err = rtos_start_timer(&led_timer);
ASSERT(kNoErr == err);
return op_ret;
}