BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lvgl
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
lvgl
Commits
25fb3e36
Commit
25fb3e36
authored
Jul 12, 2017
by
Gabor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lv_app_wifi/gsm: save/load config.
parent
81138609
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
184 additions
and
24 deletions
+184
-24
lv_app_gsm.c
lv_appx/lv_app_gsm.c
+77
-6
lv_app_wifi.c
lv_appx/lv_app_wifi.c
+82
-6
lv_conf_templ.h
lv_conf_templ.h
+25
-12
No files found.
lv_appx/lv_app_gsm.c
View file @
25fb3e36
...
@@ -79,6 +79,8 @@ static void tcp_transf_cb(gsm_state_t state, const char * txt);
...
@@ -79,6 +79,8 @@ static void tcp_transf_cb(gsm_state_t state, const char * txt);
static
void
win_title_refr
(
void
);
static
void
win_title_refr
(
void
);
static
void
save_conf
(
lv_app_inst_t
*
app
);
/**********************
/**********************
* STATIC VARIABLES
* STATIC VARIABLES
**********************/
**********************/
...
@@ -100,6 +102,10 @@ static lv_app_dsc_t my_app_dsc =
...
@@ -100,6 +102,10 @@ static lv_app_dsc_t my_app_dsc =
static
lv_app_inst_t
*
app_act_com
;
static
lv_app_inst_t
*
app_act_com
;
static
char
def_apn
[
128
];
static
char
def_ip
[
32
];
static
char
def_port
[
16
];
/**********************
/**********************
* MACROS
* MACROS
**********************/
**********************/
...
@@ -114,10 +120,58 @@ static lv_app_inst_t * app_act_com;
...
@@ -114,10 +120,58 @@ static lv_app_inst_t * app_act_com;
*/
*/
const
lv_app_dsc_t
*
lv_app_gsm_init
(
void
)
const
lv_app_dsc_t
*
lv_app_gsm_init
(
void
)
{
{
#ifdef LV_APP_GSM_CONF_PATH
fs_file_t
f
;
fs_res_t
res
;
res
=
fs_open
(
&
f
,
LV_APP_GSM_CONF_PATH
,
FS_MODE_RD
);
if
(
res
==
FS_RES_NOT_EX
)
{
res
=
fs_open
(
&
f
,
LV_APP_GSM_CONF_PATH
,
FS_MODE_WR
|
FS_MODE_RD
);
if
(
res
==
FS_RES_OK
)
{
const
char
*
def_conf
=
"apn
\n
100.101.102.103
\n
1234"
;
fs_write
(
&
f
,
def_conf
,
strlen
(
def_conf
)
+
1
,
NULL
);
fs_seek
(
&
f
,
0
);
}
}
gsmmng_set_last_apn
(
LV_APP_GSM_APN_DEF
);
if
(
res
==
FS_RES_OK
)
{
gsmmng_set_last_tcp
(
LV_APP_GSM_IP_DEF
,
LV_APP_GSM_PORT_DEF
);
volatile
char
buf
[
256
];
volatile
uint32_t
rn
;
fs_read
(
&
f
,
(
char
*
)
buf
,
sizeof
(
buf
)
-
1
,
(
uint32_t
*
)
&
rn
);
volatile
uint16_t
i
;
volatile
uint16_t
j
=
0
;
volatile
uint8_t
line_cnt
=
0
;
for
(
i
=
0
;
i
<
rn
;
i
++
)
{
if
(
buf
[
i
]
!=
'\n'
)
{
if
(
line_cnt
==
0
)
def_apn
[
j
]
=
buf
[
i
];
if
(
line_cnt
==
1
)
def_ip
[
j
]
=
buf
[
i
];
if
(
line_cnt
==
2
)
def_port
[
j
]
=
buf
[
i
];
j
++
;
}
else
{
if
(
line_cnt
==
0
)
def_apn
[
j
]
=
'\0'
;
if
(
line_cnt
==
1
)
def_ip
[
j
]
=
'\0'
;
if
(
line_cnt
==
2
)
def_port
[
j
]
=
'\0'
;
j
=
0
;
line_cnt
++
;
}
}
fs_close
(
&
f
);
}
else
{
lv_app_notice_add
(
"SD card error"
);
}
#else
strcpy
(
def_apn
,
LV_APP_GSM_APN_DEF
);
strcpy
(
def_ip
,
LV_APP_GSM_IP_DEF
);
strcpy
(
def_port
,
LV_APP_GSM_PORT_DEF
);
#endif
#if LV_APP_GSM_AUTO_CONNECT != 0
gsmmng_set_last_apn
(
def_apn
);
gsmmng_set_last_tcp
(
def_ip
,
def_port
);
#endif
ptask_create
(
gsm_state_monitor_task
,
GSM_MONITOR_PERIOD
,
PTASK_PRIO_LOW
,
NULL
);
ptask_create
(
gsm_state_monitor_task
,
GSM_MONITOR_PERIOD
,
PTASK_PRIO_LOW
,
NULL
);
return
&
my_app_dsc
;
return
&
my_app_dsc
;
...
@@ -137,9 +191,9 @@ static void my_app_run(lv_app_inst_t * app, void * conf)
...
@@ -137,9 +191,9 @@ static void my_app_run(lv_app_inst_t * app, void * conf)
{
{
/*Initialize the application*/
/*Initialize the application*/
my_app_data_t
*
adata
=
app
->
app_data
;
my_app_data_t
*
adata
=
app
->
app_data
;
strcpy
(
adata
->
set_apn
,
LV_APP_GSM_APN_DEF
);
strcpy
(
adata
->
set_apn
,
def_apn
);
strcpy
(
adata
->
set_ip
,
LV_APP_GSM_IP_DEF
);
strcpy
(
adata
->
set_ip
,
def_ip
);
strcpy
(
adata
->
set_port
,
LV_APP_GSM_PORT_DEF
);
strcpy
(
adata
->
set_port
,
def_port
);
}
}
/**
/**
...
@@ -293,7 +347,8 @@ static lv_action_res_t netw_con_rel_action(lv_obj_t * btn, lv_dispi_t* dispi)
...
@@ -293,7 +347,8 @@ static lv_action_res_t netw_con_rel_action(lv_obj_t * btn, lv_dispi_t* dispi)
gsmmng_set_last_apn
(
adata
->
set_apn
);
gsmmng_set_last_apn
(
adata
->
set_apn
);
gsmmng_set_last_tcp
(
adata
->
set_ip
,
adata
->
set_port
);
gsmmng_set_last_tcp
(
adata
->
set_ip
,
adata
->
set_port
);
gsmmng_reconnect
();
gsmmng_reconnect
();
lv_app_notice_add
(
"Connecting to GSM network
\n
%s, %s:%s"
,
save_conf
(
app
);
lv_app_notice_add
(
"Connecting to GSM network
\n
%s
\n
%s:%s"
,
adata
->
set_apn
,
adata
->
set_ip
,
adata
->
set_port
);
adata
->
set_apn
,
adata
->
set_ip
,
adata
->
set_port
);
return
LV_ACTION_RES_OK
;
return
LV_ACTION_RES_OK
;
}
}
...
@@ -402,5 +457,21 @@ static void win_title_refr(void)
...
@@ -402,5 +457,21 @@ static void win_title_refr(void)
}
}
}
}
static
void
save_conf
(
lv_app_inst_t
*
app
)
{
#ifdef LV_APP_GSM_CONF_PATH
my_app_data_t
*
adata
=
app
->
app_data
;
fs_file_t
f
;
fs_res_t
res
;
res
=
fs_open
(
&
f
,
LV_APP_GSM_CONF_PATH
,
FS_MODE_WR
);
if
(
res
==
FS_RES_OK
)
{
char
buf
[
256
];
sprintf
(
buf
,
"%s
\n
%s
\n
%s"
,
adata
->
set_apn
,
adata
->
set_ip
,
adata
->
set_port
);
fs_write
(
&
f
,
buf
,
strlen
(
buf
)
+
1
,
NULL
);
fs_close
(
&
f
);
}
#endif
}
#endif
/*LV_APP_ENABLE != 0 && USE_LV_APP_EXAMPLE != 0*/
#endif
/*LV_APP_ENABLE != 0 && USE_LV_APP_EXAMPLE != 0*/
lv_appx/lv_app_wifi.c
View file @
25fb3e36
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
#include "misc/os/ptask.h"
#include "misc/os/ptask.h"
#include "hal/systick/systick.h"
#include "hal/systick/systick.h"
#include "misc/comm/wifimng.h"
#include "misc/comm/wifimng.h"
#include "misc/fs/fat32/integer.h"
#include <stdio.h>
#include <stdio.h>
/*********************
/*********************
...
@@ -89,6 +90,8 @@ static void tcp_transf_cb(wifi_state_t state, const char * txt);
...
@@ -89,6 +90,8 @@ static void tcp_transf_cb(wifi_state_t state, const char * txt);
static
void
win_title_refr
(
void
);
static
void
win_title_refr
(
void
);
static
void
save_conf
(
lv_app_inst_t
*
app
);
/**********************
/**********************
* STATIC VARIABLES
* STATIC VARIABLES
**********************/
**********************/
...
@@ -108,6 +111,11 @@ static lv_app_dsc_t my_app_dsc =
...
@@ -108,6 +111,11 @@ static lv_app_dsc_t my_app_dsc =
.
win_data_size
=
sizeof
(
my_win_data_t
),
.
win_data_size
=
sizeof
(
my_win_data_t
),
};
};
static
char
def_ssid
[
64
];
static
char
def_pwd
[
64
];
static
char
def_ip
[
32
];
static
char
def_port
[
16
];
static
char
ssid_list
[
SSID_LIST_MAX_LENGTH
];
static
char
ssid_list
[
SSID_LIST_MAX_LENGTH
];
static
lv_app_inst_t
*
app_act_com
;
static
lv_app_inst_t
*
app_act_com
;
...
@@ -126,10 +134,61 @@ static lv_app_inst_t * app_act_com;
...
@@ -126,10 +134,61 @@ static lv_app_inst_t * app_act_com;
const
lv_app_dsc_t
*
lv_app_wifi_init
(
void
)
const
lv_app_dsc_t
*
lv_app_wifi_init
(
void
)
{
{
strcpy
(
ssid_list
,
""
);
strcpy
(
ssid_list
,
""
);
#ifdef LV_APP_WIFI_CONF_PATH
fs_file_t
f
;
fs_res_t
res
;
res
=
fs_open
(
&
f
,
LV_APP_WIFI_CONF_PATH
,
FS_MODE_RD
);
if
(
res
==
FS_RES_NOT_EX
)
{
res
=
fs_open
(
&
f
,
LV_APP_WIFI_CONF_PATH
,
FS_MODE_WR
|
FS_MODE_RD
);
if
(
res
==
FS_RES_OK
)
{
const
char
*
def_conf
=
"ssid
\n
pwd
\n
100.101.102.103
\n
1234"
;
fs_write
(
&
f
,
def_conf
,
strlen
(
def_conf
)
+
1
,
NULL
);
fs_seek
(
&
f
,
0
);
}
}
if
(
res
==
FS_RES_OK
)
{
volatile
char
buf
[
256
];
volatile
uint32_t
rn
;
fs_read
(
&
f
,
(
char
*
)
buf
,
sizeof
(
buf
)
-
1
,
(
uint32_t
*
)
&
rn
);
volatile
uint16_t
i
;
volatile
uint16_t
j
=
0
;
volatile
uint8_t
line_cnt
=
0
;
for
(
i
=
0
;
i
<
rn
;
i
++
)
{
if
(
buf
[
i
]
!=
'\n'
)
{
if
(
line_cnt
==
0
)
def_ssid
[
j
]
=
buf
[
i
];
if
(
line_cnt
==
1
)
def_pwd
[
j
]
=
buf
[
i
];
if
(
line_cnt
==
2
)
def_ip
[
j
]
=
buf
[
i
];
if
(
line_cnt
==
3
)
def_port
[
j
]
=
buf
[
i
];
j
++
;
}
else
{
if
(
line_cnt
==
0
)
def_ssid
[
j
]
=
'\0'
;
if
(
line_cnt
==
1
)
def_pwd
[
j
]
=
'\0'
;
if
(
line_cnt
==
2
)
def_ip
[
j
]
=
'\0'
;
if
(
line_cnt
==
3
)
def_port
[
j
]
=
'\0'
;
j
=
0
;
line_cnt
++
;
}
}
fs_close
(
&
f
);
}
else
{
lv_app_notice_add
(
"SD card error"
);
}
#else
strcpy
(
def_ssid
,
LV_APP_WIFI_SSID_DEF
);
strcpy
(
def_pwd
,
LV_APP_WIFI_PWD_DEF
);
strcpy
(
def_ip
,
LV_APP_WIFI_IP_DEF
);
strcpy
(
def_port
,
LV_APP_WIFI_PORT_DEF
);
#endif
#if LV_APP_WIFI_AUTO_CONNECT != 0
#if LV_APP_WIFI_AUTO_CONNECT != 0
wifimng_set_last_netw
(
LV_APP_WIFI_SSID_DEF
,
LV_APP_WIFI_PWD_DEF
);
wifimng_set_last_netw
(
def_ssid
,
def_pwd
);
wifimng_set_last_tcp
(
LV_APP_WIFI_IP_DEF
,
LV_APP_WIFI_PORT_DEF
);
wifimng_set_last_tcp
(
def_ip
,
def_port
);
#endif
#endif
ptask_create
(
wifi_state_monitor_task
,
WIFI_MONITOR_PERIOD
,
PTASK_PRIO_LOW
,
NULL
);
ptask_create
(
wifi_state_monitor_task
,
WIFI_MONITOR_PERIOD
,
PTASK_PRIO_LOW
,
NULL
);
...
@@ -151,10 +210,10 @@ static void my_app_run(lv_app_inst_t * app, void * conf)
...
@@ -151,10 +210,10 @@ static void my_app_run(lv_app_inst_t * app, void * conf)
{
{
/*Initialize the application*/
/*Initialize the application*/
my_app_data_t
*
adata
=
app
->
app_data
;
my_app_data_t
*
adata
=
app
->
app_data
;
strcpy
(
adata
->
set_ssid
,
LV_APP_WIFI_SSID_DEF
);
strcpy
(
adata
->
set_ssid
,
def_ssid
);
strcpy
(
adata
->
set_pwd
,
LV_APP_WIFI_PWD_DEF
);
strcpy
(
adata
->
set_pwd
,
def_pwd
);
strcpy
(
adata
->
set_ip
,
LV_APP_WIFI_IP_DEF
);
strcpy
(
adata
->
set_ip
,
def_ip
);
strcpy
(
adata
->
set_port
,
LV_APP_WIFI_PORT_DEF
);
strcpy
(
adata
->
set_port
,
def_port
);
adata
->
last_msg_dp
=
NULL
;
adata
->
last_msg_dp
=
NULL
;
adata
->
last_msg_size
=
0
;
adata
->
last_msg_size
=
0
;
}
}
...
@@ -340,6 +399,7 @@ static lv_action_res_t netw_con_rel_action(lv_obj_t * btn, lv_dispi_t* dispi)
...
@@ -340,6 +399,7 @@ static lv_action_res_t netw_con_rel_action(lv_obj_t * btn, lv_dispi_t* dispi)
wifimng_set_last_netw
(
adata
->
set_ssid
,
adata
->
set_pwd
);
wifimng_set_last_netw
(
adata
->
set_ssid
,
adata
->
set_pwd
);
wifimng_set_last_tcp
(
adata
->
set_ip
,
adata
->
set_port
);
wifimng_set_last_tcp
(
adata
->
set_ip
,
adata
->
set_port
);
wifimng_reconnect
();
wifimng_reconnect
();
save_conf
(
app
);
lv_app_notice_add
(
"Connecting to WiFi network
\n
%s, %s:%s"
,
lv_app_notice_add
(
"Connecting to WiFi network
\n
%s, %s:%s"
,
adata
->
set_ssid
,
adata
->
set_ip
,
adata
->
set_port
);
adata
->
set_ssid
,
adata
->
set_ip
,
adata
->
set_port
);
return
LV_ACTION_RES_OK
;
return
LV_ACTION_RES_OK
;
...
@@ -513,5 +573,21 @@ static void win_title_refr(void)
...
@@ -513,5 +573,21 @@ static void win_title_refr(void)
}
}
}
}
static
void
save_conf
(
lv_app_inst_t
*
app
)
{
#ifdef LV_APP_WIFI_CONF_PATH
my_app_data_t
*
adata
=
app
->
app_data
;
fs_file_t
f
;
fs_res_t
res
;
res
=
fs_open
(
&
f
,
LV_APP_WIFI_CONF_PATH
,
FS_MODE_WR
);
if
(
res
==
FS_RES_OK
)
{
char
buf
[
256
];
sprintf
(
buf
,
"%s
\n
%s
\n
%s
\n
%s"
,
adata
->
set_ssid
,
adata
->
set_pwd
,
adata
->
set_ip
,
adata
->
set_port
);
fs_write
(
&
f
,
buf
,
strlen
(
buf
)
+
1
,
NULL
);
fs_close
(
&
f
);
}
#endif
}
#endif
/*LV_APP_ENABLE != 0 && USE_LV_APP_EXAMPLE != 0*/
#endif
/*LV_APP_ENABLE != 0 && USE_LV_APP_EXAMPLE != 0*/
lv_conf_templ.h
View file @
25fb3e36
...
@@ -244,31 +244,44 @@
...
@@ -244,31 +244,44 @@
#define LV_APP_FILES_CHUNK_MAX_SIZE 1024 /*Max chunk size when the user sets it*/
#define LV_APP_FILES_CHUNK_MAX_SIZE 1024 /*Max chunk size when the user sets it*/
#endif /*USE_LV_APP_FILES != 0*/
#endif /*USE_LV_APP_FILES != 0*/
/*Benchmark*/
/*Benchmark*/
#define USE_LV_APP_BENCHMARK 1
#define USE_LV_APP_BENCHMARK 1
#if USE_LV_APP_BENCHMARK != 0
#if USE_LV_APP_BENCHMARK != 0
/*No settings*/
/*No settings*/
#endif
#endif
/*WiFi
(requires hal/wifi)
*/
/*WiFi*/
#define USE_LV_APP_WIFI
0
#define USE_LV_APP_WIFI
1
#if USE_LV_APP_WIFI != 0
#if USE_LV_APP_WIFI != 0
#define LV_APP_WIFI_SSID_DEF "my_ssid"
#define LV_APP_WIFI_CONF_PATH "S:/wifi_conf.txt" /*Save config. here. Comment to use def. value*/
#define LV_APP_WIFI_PWD_DEF "my_pasword"
#ifndef LV_APP_WIFI_CONF_PATH
#define LV_APP_WIFI_IP_DEF "10.11.12.13"
#define LV_APP_WIFI_SSID_DEF "ssid"
#define LV_APP_WIFI_PORT_DEF "5555"
#define LV_APP_WIFI_PWD_DEF "pwd"
#define LV_APP_WIFI_IP_DEF "100.101.102.103"
#define LV_APP_WIFI_PORT_DEF "1234"
#endif /*LV_APP_WIFI_CONF_PATH*/
#define LV_APP_WIFI_AUTO_CONNECT 1 /*Try to connect at start up to the deafult SSID and IP:PORT*/
#define LV_APP_WIFI_AUTO_CONNECT 1 /*Try to connect at start up to the deafult SSID and IP:PORT*/
#endif /*USE_LV_APP_WIFI != 0*/
#endif /*USE_LV_APP_WIFI != 0*/
/*GSM
(requires hal/gsm)
*/
/*GSM*/
#define USE_LV_APP_GSM
0
#define USE_LV_APP_GSM
1
#if USE_LV_APP_GSM != 0
#if USE_LV_APP_GSM != 0
#define LV_APP_GSM_APN_DEF "my_apn"
#define LV_APP_GSM_CONF_PATH "S:/gsm_conf.txt" /*Save config. here. Comment to use def. value*/
#define LV_APP_GSM_IP_DEF "10.11.12.13"
#ifndef LV_APP_GSM_CONF_PATH
#define LV_APP_GSM_PORT_DEF "5555"
#define LV_APP_GSM_APN_DEF "apn"
#define LV_APP_GSM_AUTO_CONNECT 1 /*Try to connect at start up with the deafult APN and IP:PORT*/
#define LV_APP_GSM_IP_DEF "101.102.103.104"
#define LV_APP_GSM_PORT_DEF "1234"
#endif /*LV_APP_GSM_CONF_PATH*/
#define LV_APP_GSM_AUTO_CONNECT 1 /*Try to connect at start up with the deafult APN and IP:PORT*/
#endif /*USE_LV_APP_GSM != 0*/
#endif /*USE_LV_APP_GSM != 0*/
/*Ethernet*/
#define USE_LV_APP_ETHERNET 1
#if USE_LV_APP_ETHERNET != 0
/*No settings*/
#endif /*USE_LV_APP_ETHERNET != 0*/
#endif /*LV_APP_ENABLE != 0*/
#endif /*LV_APP_ENABLE != 0*/
#endif /*LV_CONF_H*/
#endif /*LV_CONF_H*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment