-
Notifications
You must be signed in to change notification settings - Fork 489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve wificfg #732
base: master
Are you sure you want to change the base?
Improve wificfg #732
Conversation
Without these, wificfg.h can fail to compile because types like uint32_t, size_t or ssize_t are not available.
FreeRTOS/Source/include/FreeRTOSConfig.h makes sure configUSE_TRACE_FACILITY is always defined. But it's defined to 0 when TRACE_FACILITY is disabled. When #ifdef is used, the guarded blocks of code are always compiled and this results in link failure when TRACE_FACILITY is in fact not enabled.
wificfg.c defines the default values for ssid, password and hostname. But because these are not weak, trying to redefine these causes a link error. This change marks the definitions in wificfg.c weak, thus making it possible for a program using the wificfg component to redefine these w/o having to touch wificfg.c.
const char *wificfg_default_hostname = "eor-%02x%02x%02x"; | ||
const char *wificfg_default_ssid __attribute__ ((weak)) = "EOR_%02X%02X%02X"; | ||
const char *wificfg_default_password __attribute__ ((weak)) = "esp-open-rtos"; | ||
const char *wificfg_default_hostname __attribute__ ((weak)) = "eor-%02x%02x%02x"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These don't need to be 'weak', they are variables that can be trivially modified, just set them in your app initialization code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. I didn't realize it's a const char*
, not a const char[]
.
I was motivated by several things:
- I thought I can't really change it (which was wrong)
- I didn't want the literals from the wificfg.c to be present in the binary at all (just a few bytes, but still needless if I'm using my own strings)
- when re-defining a weak symbol, there is no need to do anything at runtime, linker just handles that (yes, just 3 assignments, but when just a declaration can suffice, it seems nicer)
Because the type is const char*
, even the second point was not fulfilled. If the type is changed to const char[]
, then it seems to do what I wanted.
What do you think about keeping these weak and making them const char[]
? Or are the last two points from the list above not interesting to you?
@@ -1540,7 +1540,7 @@ static int handle_wificfg_challenge_post(int s, wificfg_method method, | |||
return wificfg_write_string(s, http_redirect_header); | |||
} | |||
|
|||
#ifdef configUSE_TRACE_FACILITY | |||
#if configUSE_TRACE_FACILITY |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that looks right, thanks.
Several small improvements of extras/wificfg: