void NetworkSettings::CheckAP(NMAccessPoint *ap, NMDevice *device, const GPtrArray *deviceConnections)
{
   guint32 flags, wpa_flags, rsn_flags, freq, bitrate;
   guint8 strength;
   const GPtrArray *apConnections;
   GBytes *ssid;
   const char *hwaddr;
   NM80211Mode mode;
   const char *uuid;
   const char *ssid_str;
   char *freq_str, *bitrate_str, *strength_str, *wpa_flags_str, *rsn_flags_str;
   GString *security_str;
   ssid_str = NULL;
   // Get AP propertiesÂ
   flags = nm_access_point_get_flags(ap);
   wpa_flags = nm_access_point_get_wpa_flags(ap);
   rsn_flags = nm_access_point_get_rsn_flags(ap);
  Â
   ssid = nm_access_point_get_ssid(ap);
   hwaddr = nm_access_point_get_bssid(ap);
   // Not using these right now
   /*
   freq = nm_access_point_get_frequency(ap);
   mode = nm_access_point_get_mode(ap);
   bitrate = nm_access_point_get_max_bitrate(ap);
   strength = nm_access_point_get_strength(ap);
   */Â
   // Convert to stringsÂ
   try
   {
      if(ssid)
         ssid_str = nm_utils_ssid_to_utf8((guint8 *)g_bytes_get_data(ssid, NULL), g_bytes_get_size(ssid));
      else
         ssid_str = NULL;;
   }
   catch(const std::exception& e)
   {
      std::cout << e.what() << std::endl << std::flush;
      ssid_str = NULL;
   }
   freq_str = g_strdup_printf("%u MHz", freq);
   bitrate_str = g_strdup_printf("%u MB/s", bitrate/1000);
   strength_str = g_strdup_printf("%u", strength);
   wpa_flags_str = NetworkSettings::ap_wpa_rsn_flags_to_string(wpa_flags);
   rsn_flags_str = NetworkSettings::ap_wpa_rsn_flags_to_string(rsn_flags);
   security_str = g_string_new(NULL);
   if (!(flags & NM_802_11_AP_FLAGS_PRIVACY)
       && (wpa_flags != NM_802_11_AP_SEC_NONE)
       && (rsn_flags != NM_802_11_AP_SEC_NONE))
      g_string_append(security_str, "Encrypted: ");
   if((flags & NM_802_11_AP_FLAGS_PRIVACY)
       && (wpa_flags == NM_802_11_AP_SEC_NONE)
       && (rsn_flags == NM_802_11_AP_SEC_NONE))
      g_string_append(security_str, "WEP ");
   if(wpa_flags != NM_802_11_AP_SEC_NONE)
      g_string_append(security_str, "WPA ");
   if(rsn_flags != NM_802_11_AP_SEC_NONE)
      g_string_append(security_str, "WPA2 ");
   if((wpa_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)
       || (rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X))
      g_string_append(security_str, "Enterprise ");
   if (security_str->len > 0)
      g_string_truncate(security_str, security_str->len-1);  /* Chop off last space */
   if(ssid_str != NULL)
   {
      apConnections = nm_access_point_filter_connections(ap, deviceConnections);
      if(apConnections && apConnections->len > 0)
         std::cout << "Filter Profile Count: " << apConnections->len << std::endl << std::flush;
      for (int i = 0; apConnections && (i < apConnections->len); i++)
      {
         NMConnection *connectionProfile = reinterpret_cast<NMConnection *>(g_ptr_array_index(apConnections, i));
         NMSettingConnection *s_con;
         s_con = nm_connection_get_setting_connection(connectionProfile);
         if(s_con)Â
         {
            guint64 timestamp;
            char *timestamp_str;
            char timestamp_real_str[64];
            const char *val1, *val2, *val3, *val4, *val5;
            // Get various info from NMSettingConnection and show itÂ
            timestamp = nm_setting_connection_get_timestamp(s_con);
            timestamp_str = g_strdup_printf("%" G_GUINT64_FORMAT, timestamp);
            strftime(timestamp_real_str, sizeof(timestamp_real_str), "%c", localtime((time_t *) ×tamp));
            val1 = nm_setting_connection_get_id(s_con);
            uuid = nm_setting_connection_get_uuid(s_con);
            val3 = nm_setting_connection_get_connection_type(s_con);
            val4 = nm_connection_get_path(connectionProfile);
            val5 = timestamp ? timestamp_real_str : "never";        Â
            if(WirelessList.find(uuid) == WirelessList.end())
            {
               wirelessInfo *newEntry = new wirelessInfo();
               WirelessList.emplace(uuid, newEntry);
            }    Â
            WirelessList[uuid]->UUID = uuid;
            WirelessList[uuid]->lastTime = val5;
            WirelessList[uuid]->SSID = val1;
            WirelessList[uuid]->BSSID = hwaddr;
            WirelessList[uuid]->Security = security_str->str;
            WirelessList[uuid]->APPath = nm_object_get_path(NM_OBJECT(ap));
            WirelessList[uuid]->flags = flags;
            WirelessList[uuid]->wpa_flags = wpa_flags;
            WirelessList[uuid]->rsn_flags = rsn_flags;
            WirelessList[uuid]->freq = freq;
            WirelessList[uuid]->bitrate = bitrate;
            WirelessList[uuid]->DevicePath = nm_object_get_path((NMObject *)device);        Â
            WirelessList[uuid]->ConnectionPath = nm_connection_get_path(connectionProfile);
            if(WirelessList[uuid]->Requested == true)
            {
               std::cout << "Check Connection Setup: " << uuid << std::endl << std::flush;
               if(WirelessList[uuid]->Setup != true)
               {
                  std::cout << "Attempt to setup connection: " << val1 << std::endl << std::flush;
                  // Check to see if we need to setup the PSK
                  if(WirelessList[uuid]->PSK.length() > 0)
                  {
                     NMSettingWirelessSecurity *settingSecurity;
                     settingSecurity = (NMSettingWirelessSecurity *)nm_setting_wireless_security_new();
                     std::cout << "Attempt to update security proto." << std::endl << std::flush;
                     nm_setting_wireless_security_add_proto(settingSecurity, "rsn");
                     std::cout << "Attempt to update security settings." << std::endl << std::flush;
                     g_object_set(settingSecurity,
//                      NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open",
//                      NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk",
                        NM_SETTING_WIRELESS_SECURITY_PSK, WirelessList[uuid]->PSK.c_str(),
//                      NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS, NM_SETTING_SECRET_FLAG_NOT_SAVED,               Â
                        NULL);     Â
                     std::cout << "Attempt to add our security settings." << std::endl << std::flush;
                     nm_connection_add_setting(connectionProfile, NM_SETTING(settingSecurity));
                     // Now see if the PSK was stored in the settings
                     std::cout << "Check Security Key." << std::endl << std::flush;
                     const char* afterVal = nm_setting_wireless_security_get_psk(settingSecurity);
                     std::cout << "After Setting PSK: " << afterVal << std::endl << std::flush;      Â
                  }
                  // Try an start it up
                  nm_client_activate_connection_async(client, connectionProfile, device, WirelessList[uuid]->APPath.c_str(),
                     NULL, NetworkSettings::ConnectionActivationStarted, NULL);
                  WirelessList[uuid]->Setup = true;
               }
               else
               {
                  NMSettingWirelessSecurity *settingSecurity;
                  settingSecurity = nm_connection_get_setting_wireless_security(connectionProfile);
                  const char* afterVal = NULL;
                  afterVal = nm_setting_wireless_security_get_psk(settingSecurity);
                  if(afterVal != NULL)
                     std::cout << "PSK Check: " << afterVal << std::endl << std::flush;                    Â
               }    Â
            }    Â
         }
      }
      g_ptr_array_unref((GPtrArray *)apConnections);
      //g_slist_free(apConnections);
   }
   if(ssid_str != NULL)
      g_free((gpointer)(ssid_str));
   g_free(freq_str);
   g_free(bitrate_str);
   g_free(strength_str);
   g_free(wpa_flags_str);
   g_free(rsn_flags_str);
   g_string_free(security_str, TRUE);
}