I have a data collection program in the field that uses the Tungsten C to send data back to a central server over the wifi link. We provide our own access points on the floor and I specify those APs in the application at compile time.

We're in the process of evaluating new devices and I can't seem to get things running on a TX. I've tested on the TC, T3/T5 (with sdio card) and it works fine there. On the TX however everything I do appears to be ignored. None of the NetServices calls generate error codes, everything appears to work properly, but when I call NetLibOpen it always connects to whatever access point was specified in the WiFi system options.

I've included the connect function below in case I've done something obviously wrong. I know that it's not really necessary to delete all the profiles in advance, but I've been trying everything in order to figure out on the TX.

I'm using the v5.1 SDK, I tried the older version that I used when the TC was popular with the same results. I can use NetServiceProfileRead to verify that the profile is being added, and it is. But when NetLibOpen is called it's completely ignored.

I'm nearing my wit's end. Any ideas or suggestions would be appreciated.

static void ConnectToAP()
{
    Err error;
    Err netError;
    NetServicesProfile profile;
    NetServicesProfileOrder order;
    UInt16 netLibRef;
    UInt32 i;
    
//    Delete all existing profiles.
    NetServicesProfileGetOrder(gGlobalsP->libRef, &order);
    for (i = 0; i < MAX_ACTIVE_PROFILES; i++)
    {
        if (order.order[i] != INVALID_INDEX)
        {
            NetServicesProfileDelete(gGlobalsP->libRef, order.order[i]);
            order.order[i] = INVALID_INDEX;
        }
    }

//    Setup Profile
    MemSet(&profile, sizeof(NetServicesProfile), NULL);
    StrCopy(profile.profileName, kWiFiProfileName);
    profile.ssidLength = kWiFiSSIDLen;
    MemMove(&(profile.SSID), kWiFiSSID, kWiFiSSIDLen);
    profile.ipAllocType = IPAllocType_DHCP;
    profile.preambleType = AUTO_PREAMBLE;
    profile.authentication = SecurityModeOpenSystem;
    profile.opMode = ESS;
    profile.dhcpRequestDNS = 1;
    
//    Add the new profile to the system
    error = NetServicesProfileAdd(gGlobalsP->libRef, &profile);
    if (error != errNone)
    {
        ErrAlertCustom(error, "Error adding profile", "", "");
    }

//    Set profile connect order to ensure we're first.
    NetServicesProfileGetOrder(gGlobalsP->libRef, &order);
    order.order[0] = NetServicesProfileFind(gGlobalsP->libRef, kWiFiProfileName);
    order.order[1] = INVALID_INDEX;
    NetServicesProfileSetOrder(gGlobalsP->libRef, &order);

//    Connect to AP    
    error = SysLibFind("Net.lib", &netLibRef);
    if (error == sysErrLibNotFound)
        error = SysLibLoad(netLibType, netCreator, &netLibRef);
    
    if (!error)
    {
        error = NetLibOpen(netLibRef, &netError);
        if (!error)
        {
            NetLibClose(netLibRef, false);
        }
    }
    return;
}

-- For information on using the PalmSource Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/

Reply via email to