Funzione WifiConfig_SetPSKWifiConfig_SetPSK Function
Intestazione: #include <applibs/wificonfig.h>Header: #include <applibs/wificonfig.h>
Imposta la chiave precondivisa (PSK) per una rete Wi-Fi.Sets the pre-shared key (PSK) for a Wi-Fi network. La chiave PSK viene usata per le reti configurate con il tipo di sicurezza WifiConfig_Security_Wpa2_Psk
.The PSK is used for networks that are configured with the WifiConfig_Security_Wpa2_Psk
security type.
L'impostazione viene applicata immediatamente, ma non viene mantenuta da un riavvio all'altro del dispositivo, a meno che non venga chiamata la funzione WifiConfig_PersistConfig dopo questa funzione.The setting is effective immediately but won't persist across device reboots unless the WifiConfig_PersistConfig function is called after this function.
static int WifiConfig_SetPSK(int networkId, const char *psk, size_t pskLength);
ParametriParameters
networkId
ID della rete da configurare.networkId
The ID of the network to configure. WifiConfig_AddNetwork restituisce l'ID di rete.WifiConfig_AddNetwork returns the network ID.psk
Puntatore al buffer contenente la chiave PSK per la rete.psk
A pointer to the buffer that contains the PSK for the network.pskLength
Lunghezza della chiave PSK per la rete.pskLength
The length of the PSK for the network. Questo parametro deve essere minore o uguale aWIFICONFIG_WPA2_KEY_MAX_BUFFER_SIZE
.This parameter must be less than or equals toWIFICONFIG_WPA2_KEY_MAX_BUFFER_SIZE
.
ErrorsErrors
Restituisce-1 se viene rilevato un errore e imposta sul errno
valore di errore.Returns -1 if an error is encountered and sets errno
to the error value.
EACCES: il manifesto dell'applicazione non include la funzionalità WifiConfig.EACCES: the application manifest doesn't include the WifiConfig capability.
EFAULT: il parametro
psk
è NULL.EFAULT: thepsk
parameter is NULL.ERANGE: la lunghezza del parametro
pskLength
è maggiore diWIFICONFIG_WPA2_KEY_MAX_BUFFER_SIZE
.ERANGE: thepskLength
parameter is greater thanWIFICONFIG_WPA2_KEY_MAX_BUFFER_SIZE
.EAGAIN: il dispositivo Wi-Fi non è pronto.EAGAIN: the Wi-Fi device isn't ready.
ENETDOWN: l'interfaccia di rete Wi-Fi non è disponibile.ENETDOWN: the Wi-Fi network interface is unavailable.
EINVAL: il parametro
networkId
non è valido.EINVAL: thenetworkId
parameter is invalid.ENODEV: il parametro
networkId
non corrisponde a nessuno degli ID delle reti archiviate.ENODEV: thenetworkId
parameter doesn't match any of the IDs of the stored networks.
errno
È possibile specificare anche qualsiasi altro tipo di errore. tali errori non sono deterministici e lo stesso comportamento potrebbe non essere mantenuto tramite gli aggiornamenti del sistema.Any other errno
may also be specified; such errors aren't deterministic and the same behavior might not be retained through system updates.
Valore restituitoReturn value
Restituisce 0 per l'esito positivo o-1 per l'esito negativo, nel qual caso errno
viene impostato sul valore di errore.Returns 0 for success, or -1 for failure, in which case errno
is set to the error value.
Requisiti del manifesto dell'applicazioneApplication manifest requirements
Il manifesto dell'applicazione deve includere la funzionalità WifiConfig.The application manifest must include the WifiConfig capability.