mirror of
https://github.com/albfan/miraclecast.git
synced 2025-03-09 23:38:56 +00:00
wifi: add wfd-subelement properties
Allow dbus API users to read and modify WFD subelements. Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
This commit is contained in:
parent
61db4a1d71
commit
e624d5f81a
5 changed files with 230 additions and 2 deletions
|
|
@ -60,6 +60,7 @@ struct supplicant_peer {
|
|||
|
||||
char *friendly_name;
|
||||
char *remote_addr;
|
||||
char *wfd_subelements;
|
||||
char *prov;
|
||||
char *pin;
|
||||
char *sta_mac;
|
||||
|
|
@ -647,6 +648,7 @@ static void supplicant_peer_free(struct supplicant_peer *sp)
|
|||
free(sp->pin);
|
||||
free(sp->prov);
|
||||
free(sp->friendly_name);
|
||||
free(sp->wfd_subelements);
|
||||
free(sp);
|
||||
}
|
||||
|
||||
|
|
@ -682,6 +684,14 @@ const char *supplicant_peer_get_remote_address(struct supplicant_peer *sp)
|
|||
return sp->remote_addr;
|
||||
}
|
||||
|
||||
const char *supplicant_peer_get_wfd_subelements(struct supplicant_peer *sp)
|
||||
{
|
||||
if (!sp)
|
||||
return NULL;
|
||||
|
||||
return sp->wfd_subelements;
|
||||
}
|
||||
|
||||
int supplicant_peer_connect(struct supplicant_peer *sp,
|
||||
const char *prov_type,
|
||||
const char *pin)
|
||||
|
|
@ -779,7 +789,7 @@ static void supplicant_parse_peer(struct supplicant *s,
|
|||
struct wpas_message *m)
|
||||
{
|
||||
struct supplicant_peer *sp;
|
||||
const char *mac, *name;
|
||||
const char *mac, *name, *val;
|
||||
char *t;
|
||||
int r;
|
||||
|
||||
|
|
@ -812,6 +822,18 @@ static void supplicant_parse_peer(struct supplicant *s,
|
|||
wpas_message_get_raw(m));
|
||||
}
|
||||
|
||||
r = wpas_message_dict_read(m, "wfd_subelems", 's', &val);
|
||||
if (r >= 0) {
|
||||
t = strdup(val);
|
||||
if (!t) {
|
||||
log_vENOMEM();
|
||||
} else {
|
||||
free(sp->wfd_subelements);
|
||||
sp->wfd_subelements = t;
|
||||
peer_supplicant_wfd_subelements_changed(sp->p);
|
||||
}
|
||||
}
|
||||
|
||||
if (s->running)
|
||||
peer_supplicant_started(sp->p);
|
||||
}
|
||||
|
|
@ -1454,7 +1476,9 @@ static int supplicant_set_wifi_display_fn(struct wpas *w,
|
|||
struct wpas_message *reply,
|
||||
void *data)
|
||||
{
|
||||
_wpas_message_unref_ struct wpas_message *m = NULL;
|
||||
struct supplicant *s = data;
|
||||
int r;
|
||||
|
||||
/* SET received */
|
||||
--s->setup_cnt;
|
||||
|
|
@ -1464,8 +1488,49 @@ static int supplicant_set_wifi_display_fn(struct wpas *w,
|
|||
s->has_wfd = false;
|
||||
}
|
||||
|
||||
if (s->has_wfd) {
|
||||
/* update subelements */
|
||||
|
||||
r = wpas_message_new_request(s->bus_global,
|
||||
"WFD_SUBELEM_SET",
|
||||
&m);
|
||||
if (r < 0) {
|
||||
log_vERR(r);
|
||||
goto error;
|
||||
}
|
||||
|
||||
r = wpas_message_append(m, "s", "0");
|
||||
if (r < 0) {
|
||||
log_vERR(r);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!shl_isempty(s->l->wfd_subelements)) {
|
||||
r = wpas_message_append(m, "s", s->l->wfd_subelements);
|
||||
if (r < 0) {
|
||||
log_vERR(r);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
r = wpas_call_async(s->bus_global,
|
||||
m,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
NULL);
|
||||
if (r < 0) {
|
||||
log_vERR(r);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
supplicant_try_ready(s);
|
||||
return 0;
|
||||
|
||||
error:
|
||||
supplicant_failed(s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int supplicant_status_fn(struct wpas *w,
|
||||
|
|
@ -1718,7 +1783,7 @@ int supplicant_set_friendly_name(struct supplicant *s, const char *name)
|
|||
int r;
|
||||
|
||||
if (!s->running || !name || !*name)
|
||||
return log_EINVAL();;
|
||||
return log_EINVAL();
|
||||
|
||||
r = wpas_message_new_request(s->bus_global,
|
||||
"SET",
|
||||
|
|
@ -1745,6 +1810,45 @@ int supplicant_set_friendly_name(struct supplicant *s, const char *name)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int supplicant_set_wfd_subelements(struct supplicant *s, const char *val)
|
||||
{
|
||||
_wpas_message_unref_ struct wpas_message *m = NULL;
|
||||
int r;
|
||||
|
||||
if (!s->running || !val)
|
||||
return log_EINVAL();
|
||||
|
||||
r = wpas_message_new_request(s->bus_global,
|
||||
"WFD_SUBELEM_SET",
|
||||
&m);
|
||||
if (r < 0)
|
||||
return log_ERR(r);
|
||||
|
||||
r = wpas_message_append(m, "s", "0");
|
||||
if (r < 0)
|
||||
return log_ERR(r);
|
||||
|
||||
if (!shl_isempty(val)) {
|
||||
r = wpas_message_append(m, "s", val);
|
||||
if (r < 0)
|
||||
return log_ERR(r);
|
||||
}
|
||||
|
||||
r = wpas_call_async(s->bus_global,
|
||||
m,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
NULL);
|
||||
if (r < 0)
|
||||
return log_ERR(r);
|
||||
|
||||
log_debug("send 'WFD_SUBELEM_SET 0 %s' to wpas on %s",
|
||||
val, s->l->ifname);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int supplicant_p2p_start_scan(struct supplicant *s)
|
||||
{
|
||||
_wpas_message_unref_ struct wpas_message *m = NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue