Lantronix Developer Forums  

Go Back   Lantronix Developer Forums > xPico Wi-Fi > xPico Wi-Fi SDK Questions

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-08-2017, 08:58 AM
foolishsailor foolishsailor is offline
Member
 
Join Date: Apr 2017
Posts: 13
Default How to tell xPico to connect to a given visible WiFI

THe manual references Apply and Submit but I cant see how those two comands refer to the xml commands.

I am able to add/delete WLAN profiles via XML, list visible wifi and currently connected wifi - but dont see where/how I can tell the xPico to connect to a specific access point either by sending the data or by telling it to connect to visible WLAN?
Reply With Quote
  #2  
Old 04-10-2017, 03:09 PM
ed4096 ed4096 is offline
Junior Member
 
Join Date: Nov 2016
Posts: 8
Default

(1) You can do it using curl to upload an XML file using something like this in a command line:
Code:
curl -u admin:PASSWORD http://192.168.0.1/import/config -X POST --form configrecord=@c:\xml_setup\wlan0.xml
Check out the guide for that: http://wiki.lantronix.com/developer/...gConfiguration

In your case, the XML file will contain information for enabling wlan0, with correct router information, including a password, etc. Additionally, the XML file can perform a software restart to the xPico, which is needed to apply certain settings, particularly when messing around with the ap0 and wlan0 configurations. Particularly, look into the XML Import Control specific tags.

Initially I had troubles creating a correct wlan0 configuration to do this, but this was solved by fixing some parts of the XML. It's been covered in this thread (it includes a sample XML file, except for the erroneous parts in red):
http://forums.lantronix.com/showthread.php?t=1306

(2) You can do it using the SDK to "set" an XML file programmatically. For example, if you want to send an UDP packet to the device with configuration information, or some other signal, upon which the XML with data will be set. I've had success using the ltrx_xml_import_from_stream function. Something like this:
Code:
char xmlData[XML_STRING_FULL_LENGTH];
strcpy(xmlData, "<!-- Put your XML file here -->";
struct input_stream_from_const_char ifs;
ltrx_input_stream_init_from_const_char(&ifs,xmlData);
bool res_xml = ltrx_xml_import_from_stream(&ifs.inStream, NULL);

Last edited by ed4096; 04-10-2017 at 03:13 PM.
Reply With Quote
  #3  
Old 04-11-2017, 02:42 PM
foolishsailor foolishsailor is offline
Member
 
Join Date: Apr 2017
Posts: 13
Default

Thanks for the response.

Im not seeing the solution to the problem in the code you XML in the other thread.

We have no problem sending and receiving data via POST and XML its that I dont see a section in the config/status groups that allows us to tell the xpico to connect to a given visible wifi.

Im hoping to be able to send the SSID and Password in this manner and the device will auto connect and I am not seeing that functionality in this group. We can create new WLAN profiles no problem but that doesnt solve the problem either.

The outline of what we are doing is that we have an xPico in a device that is connected to an app via a socket and the app pulls the visible wifi to the xpico and allows the user to select which one the xpico connects to. This is all done via POST and XML.

We have everything working except dont see a way to "select" the visible wifi and have the xpico connect - the same manner in which you would choose the wifi on your phone for example. We also dont want to force the user to save a given selected wifi to the limited 4 profiles, just connect.
Reply With Quote
  #4  
Old 04-11-2017, 03:15 PM
mariano mariano is offline
Lantronix FAE
 
Join Date: Aug 2012
Posts: 369
Default

There is currently no way, via the WebAPI, to tell the xPico Wi-Fi to connect to a network, but not save that network as a WLAN Profile.

One option would be to save the WLAN Profile always with the same instance name (instead of using the SSID as the instance), so that every time that the you upload a new network to connect to, it modifies the existing WLAN Profile.

Mariano
Reply With Quote
  #5  
Old 04-11-2017, 03:32 PM
blee blee is offline
Super Moderator
 
Join Date: Jan 2017
Posts: 1
Default

You could use serial line to access CLI -> wlan scan and then save its SSID and password as WLAN profiles (XML/POST). You could always delete one profiles if xPico wifi connects another one. Or, always use the same profile name like Mariano said.

Brooke
Reply With Quote
  #6  
Old 04-13-2017, 01:53 PM
ed4096 ed4096 is offline
Junior Member
 
Join Date: Nov 2016
Posts: 8
Default

Quote:
Originally Posted by mariano View Post
One option would be to save the WLAN Profile always with the same instance name (instead of using the SSID as the instance), so that every time that the you upload a new network to connect to, it modifies the existing WLAN Profile.

Mariano
It works quite well in our software package too, i.e. we have only one profile and the software modifies it whenever the user wishes to connect to a different network.

By the way, we're gathering the nearby SSIDs (visible by xPico) through the serial CLI using the "wlan scan" command (to subsequently pass the list to the SDK software, and to the external device(s)), since we couldn't get the direct CLI wrapper in the SDK to work.
Reply With Quote
  #7  
Old 04-13-2017, 02:16 PM
mariano mariano is offline
Lantronix FAE
 
Join Date: Aug 2012
Posts: 369
Default

Quote:
Originally Posted by ed4096 View Post
It works quite well in our software package too, i.e. we have only one profile and the software modifies it whenever the user wishes to connect to a different network.

By the way, we're gathering the nearby SSIDs (visible by xPico) through the serial CLI using the "wlan scan" command (to subsequently pass the list to the SDK software, and to the external device(s)), since we couldn't get the direct CLI wrapper in the SDK to work.
The programmatic_scan example in the SDK does what you're looking for: utilize the CLI to do a "wlan scan" in the CLI loop, and parse the results. Did you try to start from that example?
Reply With Quote
  #8  
Old 04-21-2017, 11:59 AM
ed4096 ed4096 is offline
Junior Member
 
Join Date: Nov 2016
Posts: 8
Default

Quote:
Originally Posted by mariano View Post
The programmatic_scan example in the SDK does what you're looking for: utilize the CLI to do a "wlan scan" in the CLI loop, and parse the results. Did you try to start from that example?
We did start from the programmatic_scan example, but we weren't sure whether the newly created thread works correctly. It was hard to debug the software indirectly, the program kept freezing (couldn't pinpoint directly why at that time; thread stack size was OK), and there wasn't enough time anyway to dig deeper, so we went with the solution that worked. This serial implementation was needed anyway (by the way, both serial ports are running well at 921,600 baud). Perhaps there is some kind of an advanced SDK where you can use a debugging toolkit with breakpoints and such? So far, we've used only indirect methods to test the software by writing relevant debugging data into either serial or UDP packets.

In any case, the current solution works; it takes a couple of seconds to gather the SSIDs, which isn't that bad from the UX perspective, since it's typically done only once during a session lasting a couple of hours. It takes a couple of seconds more to associate with a new network (change the single existing profile) or create an AP (user's choice). Perhaps if we get the CLI in the SDK to work just as well as through serial, we'll change the behavior in a later software bundle version.

Last edited by ed4096; 04-21-2017 at 12:03 PM.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:06 AM.


Copyright Lantronix, Inc. 2013. All rights reserved.
Powered by vBulletin® Copyright ©2000 - 2017, vBulletin Solutions, Inc.