-
Notifications
You must be signed in to change notification settings - Fork 560
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
Add the initial version of Wi-Fi Manager #528
Conversation
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.
There are too many violations of coding rule.
framework/Makefile
Outdated
@@ -42,6 +42,11 @@ ifeq ($(CONFIG_NETUTILS_MQTT), y) | |||
include src$(DELIM)mqtt$(DELIM)Make.defs | |||
endif | |||
|
|||
ifeq ($(CONFIG_WIFI_MANAGER), y) | |||
#CFLAGS += -I$(TOPDIR)$(DELIM)..$(DELIM)framework$(DELIM)src$(DELIM)wifi_manager |
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.
Let's remove unnecessary codes.
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.
Done
@@ -0,0 +1,129 @@ | |||
/**************************************************************************** | |||
* | |||
* Copyright 2016 Samsung Electronics All Rights Reserved. |
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.
Year of copyright should be 2017.
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.
Done
// SOFT AP mode status | ||
CLIENT_CONNECTED, | ||
CLIENT_DISCONNECTED | ||
} connect_status; |
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.
How about add _e postfix to know easily what this is an enum structure?
connect_status_e
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.
Done
void (*sta_disconnected) (void); | ||
void (*softap_sta_join) (void); | ||
void (*softap_sta_leave) (void); | ||
} wifi_manager_cb; |
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.
same as previous.
wifi_manager_cb_s
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.
Done
typedef struct { | ||
char ip4_address[18]; | ||
char ssid[32]; | ||
int rssi; |
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.
Here are violations of coding rule. Please use tab as an indention.
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.
I did apply fomatter.sh
|
||
wifi_utils_result wifi_mutex_create(wifi_mutex* mutex) | ||
{ | ||
return wifi_semaphore_create((wifi_semaphore *) mutex, 1); |
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.
Let' remove space after type casting.
(wifi_semaphore *)mutex
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.
I did go through fomatter.sh
#include "wifi_mutex.h" | ||
#include "wifi_semaphore.h" | ||
|
||
wifi_utils_result wifi_mutex_create(wifi_mutex* mutex) |
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.
(wifi_mutex *mutex)
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.
I did go through fomatter.sh
* @return WIFI_UTILS_FAIL : fail | ||
* @return WIFI_UTILS_INVALID_ARGS : input parameter invalid | ||
*/ | ||
wifi_utils_result wifi_mutex_create( wifi_mutex* mutex ); |
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.
xxx yyy(wifi_mutex *mutex);
Need same at belows
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.
I did go through fomatter.sh
#include "wifi_net.h" | ||
|
||
#define ptr2uint32(ptr) (uint32_t)ptr[3] | \ | ||
((uint32_t)ptr[2] << 8) | \ |
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.
use tabs intead of spaces as an indentation
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.
I did go through fomatter.sh
} wifi_manager_ap_config; | ||
|
||
|
||
wifi_manager_result wifi_manager_init(wifi_manager_cb *wmcb); |
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.
Even though this file shows public APIs, you didn't add comments for doxygen. But you added doxygen comments at local header file. Please check it.
And when you add doxygen comments at public APIs, since option should be there at end of comments.
* @since Tizen RT v1.1
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.
Added api description
Wi-Fi Manager is introduced to provide easy APIs for applications to easily manipulate Wi-Fi features
322c82c
to
c3bbc4d
Compare
framework/src/wifi_manager/Make.defs
Outdated
@@ -0,0 +1,23 @@ | |||
########################################################################### | |||
# | |||
# Copyright 2016 Samsung Electronics All Rights Reserved. |
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.
2016 -> 2017
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.
Done
os/net/Kconfig
Outdated
@@ -133,6 +133,20 @@ endif #NET_SECURITY_TLS | |||
|
|||
endmenu #Protocols | |||
|
|||
menu "Wireless" | |||
|
|||
config WIFI_MANAGER |
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.
This is not under network folder so that let's make a new Kconfig at wifi_manager and include it here.
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.
wifi_manager/Kconfig is created
@@ -148,7 +148,7 @@ int cmd_dhcpd(int argc, char *argv[]) | |||
} | |||
} | |||
|
|||
if (dhcpd_start(argv[2]) != 0) { | |||
if (dhcpd_start(argv[2], NULL) != 0) { |
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.
Is there any releation between WiFi Manager and DHCPD stubs?
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, wifi manager needs to be informed of join of a new station in softap mode.
external/dhcpd/dhcpd.c
Outdated
|
||
ret = select(sockfd+1, &sockfd_set, NULL, NULL, &g_select_timeout); | ||
if ((ret > 0) && FD_ISSET(sockfd, &sockfd_set)) { | ||
ret = select(g_dhcpd_sockfd+1, &sockfd_set, NULL, NULL, &g_select_timeout); |
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.
Please add spaces around +.
g_dhcpd_sockfd + 1
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.
I go through fomatter.
external/dhcpd/dhcpd.c
Outdated
} | ||
/* Create a socket to listen for requests from DHCP clients */ | ||
/* TODO : Need to add cancellation point */ | ||
if (g_dhcpd_sockfd < 0) { |
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 always put -1 to g_dhcpd_sockfd at line 1552. This if condition is redundant.
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.
I think so. if statement is removed.
* | ||
****************************************************************************/ | ||
|
||
#pragma once |
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.
#pragma once is not a standard so that some compiler can not understand this command.
Let's change this like belows.
#ifndef XXX
#define
...
#endif
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.
Done
return WIFI_UTILS_INVALID_ARGS; | ||
} | ||
|
||
if (sem_destroy((sem_t *) semaphore)) { |
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.
(sem_t *) semaphore => (sem_t *)semaphore
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.
formatter doesn't fix this problem. I mannually fix it.
} | ||
} | ||
|
||
ret = WiFiNetworkJoin((uint8_t *) ap_connect_config->ssid, ap_connect_config->ssid_length, NULL, config); |
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.
remove space
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.
Done
config = (slsi_security_config_t *)zalloc(sizeof(slsi_security_config_t)); | ||
if (!config) { | ||
ndbg("Memory allocation failed!\n"); | ||
goto connect_ap_fail; |
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.
In this case, we don't need to check config so that let's change this to "return result;"
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.
from the viewpoint of readability, this statement seems to be fine.
WIFI_UTILS_AUTH_WPA2_PSK, /**< WPA2_PSK mode */ | ||
WIFI_UTILS_AUTH_WPA_AND_WPA2_PSK, /**< WPA_PSK and WPA_PSK mixed mode */ | ||
WIFI_UTILS_AUTH_UNKNOWN, /**< unknown type */ | ||
} wifi_utils_ap_auth_type; |
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.
how about _e
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.
Done
} wifi_manager_ap_config_s; | ||
|
||
/** | ||
* @brief Initialize Wi-Fi Manager including starting Wi-Fi interface. |
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.
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.
Done
wifi_manager_result_e wifi_manager_init(wifi_manager_cb_s *wmcb); | ||
|
||
/** | ||
* @brief Deinitialize Wi-Fi Manager including stoping Wi-Fi interface. |
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.
check the indent for doxygen comment(space is needed before *)
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.
Done
|
||
/** | ||
@} | ||
*/// end mutex group |
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.
remove unnecessary tab
|
||
/** | ||
@} | ||
*/// end net work utility group |
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.
check the indent
return WIFI_UTILS_INVALID_ARGS; | ||
} | ||
|
||
if (sem_post((sem_t *) semaphore)) { |
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.
remove space after type casting
*/ | ||
|
||
/** | ||
* @defgroup semaphore semaphore |
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.
Those APIs are related with wifi semaphore.
but if you define this group to "semaphore", then category name in doxygen is set to semaphore.
that makes some confusion to users. isn't it?
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.
This is not public APIs. Anyway, change to Wi-Fi Manager group.
|
||
/** | ||
@} | ||
*/// end semaphore group |
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.
check the indent
6044413
to
deb69fb
Compare
* @since Tizen RT v1.1 | ||
*/ | ||
wifi_manager_result_e wifi_manager_set_softap_config(wifi_manager_softap_config_s *config); | ||
|
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 opened the "Wi-Fi_Manager ingroup" brace, but not close.
please add below.
/**
- @}
*/
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.
Done
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 didn't close the }. please check this
*/ | ||
|
||
/** | ||
* @defgroup Wi-Fi_Manager Wi-Fi_Manager |
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 already made defgroup Wi-Fi_Manager in wifi_manager.h
if you want to add below APIs to that group, you can just do ingroup, not making again.
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.
this file doesn't include public apis so that related comments are removed.
external/dhcpd/dhcpd.c
Outdated
@@ -610,15 +622,15 @@ static inline bool dhcpd_parseoptions(void) | |||
optlen = ptr[DHCPD_OPTION_LENGTH] + 2; | |||
if (optlen >= 4 && optlen < remaining) { | |||
memcpy(&tmp, &ptr[DHCPD_OPTION_DATA], 4); | |||
g_state.ds_optreqip = (in_addr_t)ntohl(tmp); | |||
g_state.ds_optreqip = (in_addr_t) ntohl(tmp); |
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.
Let's revert this line change.
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.
Done
external/dhcpd/dhcpd.c
Outdated
} | ||
break; | ||
|
||
case DHCP_OPTION_LEASE_TIME: /* IP address lease time */ | ||
optlen = ptr[DHCPD_OPTION_LENGTH] + 2; | ||
if (optlen >= 4 && optlen < remaining) { | ||
memcpy(&tmp, &ptr[DHCPD_OPTION_DATA], 4); | ||
g_state.ds_optleasetime = (time_t)ntohl(tmp); | ||
g_state.ds_optleasetime = (time_t) ntohl(tmp); |
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.
Let's revert this line change.
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.
Done
external/dhcpd/dhcpd.c
Outdated
@@ -633,7 +645,7 @@ static inline bool dhcpd_parseoptions(void) | |||
optlen = ptr[DHCPD_OPTION_LENGTH] + 2; | |||
if (optlen >= 4 && optlen < remaining) { | |||
memcpy(&tmp, &ptr[DHCPD_OPTION_DATA], 4); | |||
g_state.ds_optserverip = (in_addr_t)ntohl(tmp); | |||
g_state.ds_optserverip = (in_addr_t) ntohl(tmp); |
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.
Let's revert this line change.
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.
Done
external/dhcpd/dhcpd.c
Outdated
@@ -942,38 +917,35 @@ static int dhcpd_sendpacket(int bbroadcast) | |||
if (bbroadcast) { | |||
ipaddr = INADDR_BROADCAST; | |||
} else if (memcmp(g_state.ds_outpacket.ciaddr, g_anyipaddr, 4) != 0) { | |||
dhcpd_arpupdate((uint16_t *)g_state.ds_outpacket.ciaddr, g_state.ds_outpacket.chaddr); | |||
dhcpd_arpupdate((uint16_t *) g_state.ds_outpacket.ciaddr, g_state.ds_outpacket.chaddr); |
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.
Let's revert this line change.
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.
Done
external/dhcpd/dhcpd.c
Outdated
memcpy(&ipaddr, g_state.ds_outpacket.ciaddr, 4); | ||
} else if (g_state.ds_outpacket.flags & HTONS(BOOTP_BROADCAST)) { | ||
ipaddr = INADDR_BROADCAST; | ||
} else { | ||
dhcpd_arpupdate((uint16_t *)g_state.ds_outpacket.yiaddr, g_state.ds_outpacket.chaddr); | ||
dhcpd_arpupdate((uint16_t *) g_state.ds_outpacket.yiaddr, g_state.ds_outpacket.chaddr); |
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.
Let's revert this line change.
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.
Done
external/dhcpd/dhcpd.c
Outdated
g_dhcp_sta_joined = dhcp_join_cb; | ||
} | ||
|
||
status = pthread_create(&g_tid, &attr, (pthread_startroutine_t) dhcpd_run, NULL); |
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.
Let's remove space after type casting.
(pthread_startroutine_t) dhcpd_run => (pthread_startroutine_t)dhcpd_run
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.
Done
} | ||
|
||
if (!g_wifi_softap_config) { | ||
g_wifi_softap_config = (wifi_manager_softap_config_s *)malloc(sizeof(wifi_manager_softap_config_s)); |
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.
I can't find codes to free g_wifi_softap_config. Only allocation is here. Is it intended?
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.
Very good comment!
Actually this api is not required if softap configuration information is delivered when wifi_manager_set_mode() is called.
external/include/protocols/dhcpd.h
Outdated
@@ -88,6 +88,8 @@ extern "C" { | |||
#define EXTERN extern | |||
#endif | |||
|
|||
typedef void (*dhcp_sta_joined) (void); |
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.
remove the space between (*dhcp_sta_joined) and (void);
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.
Done
|
||
static wifi_utils_result_e stop_dhcp_server(void) | ||
{ | ||
struct in_addr in = {.s_addr = INADDR_NONE }; |
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.
space is needed after '{'
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.
Done
|
||
/** | ||
@} | ||
*/// end mutex group |
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.
remove unnecessary tab
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.
this file doesn't include public apis so that related comments are removed.
wifi_utils_result_e wifi_mutex_destroy(wifi_mutex *mutex); | ||
|
||
/** | ||
@} |
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.
add '*' infront of @
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.
this file doesn't include public apis so that related comments are removed.
28b0101
to
cd3eb9a
Compare
Wi-Fi Manager is introduced to provide easy APIs for applications to easily manipulate Wi-Fi features