Unfortunately, you would have to use scan to check the AP's security type beforehand. Once you are connected though you can check it using the function get_ap_info(), defined in command_console_wifi.c in libraries\utilities\command_console\wifi. Hope this helps.