Hi,
I have a big problem. I need to create a new connection using Net Libraty
Functions ( Name >> IR to Phone / Connect to Modem / Via Infrared ) . I should
to set IR to Phone to connect a palm with an IR Modem, however, there is not
that option at TE by default.
IÂve tried to set this in my code but when I try to connect to IR Modem - when
calls err = NetLibOpen(libRefNum, &intfErrs); - Palm OS shows this dialog
"Error (0x1F07)". When there is a connection IR to Phone created, it works
perfectly, but if there isn't this error is showed.
This is my code:
...
NetConfigNamePtr pConfigName = (NetConfigNamePtr)"Activia Sync";
err = SysLibFind("Net.lib", &libRefNum);
if(err)
retutn;
valueLen = sizeof(pValue);
pValue[0] = 0;
if (!err){
err = NetLibIFSettingGet(libRefNum, ifCreator, ifInstance,
netIFSettingServiceName, &pValue, &valueLen);
FrmCustomAlert(MainErrorAlert, pValue ,NULL, NULL);
}
valueLen = sizeof(pValue);
pValue[0] = 0;
if (!err){
err = NetLibIFSettingGet(libRefNum, ifCreator, ifInstance,
netIFSettingConnectionName , &pValue, &valueLen);
FrmCustomAlert(MainErrorAlert, pValue ,NULL, NULL);
}
//if no service, create one before trying to set it.
if(err)
{
err = 0;
// Reset settings
NetLibSettingSet(libRefNum, netSettingResetAll, NULL, NULL)
;
NetLibIFSettingSet(libRefNum, ifCreator, 0,
netIFSettingResetAll,0,0);
// Attach interfaces we'll be using.
NetLibIFAttach(libRefNum, ifCreator, ifInstance, timeout);
// Attach loopback interface as well
NetLibIFAttach(libRefNum, netIFCreatorLoop, ifInstance,
sysTicksPerSecond*2);
//Set all the new settings here. See NetIFSettingEnum for more
options to set.
NetLibIFSettingSet(libRefNum, ifCreator, ifInstance,
netIFSettingServiceName, SERVICENAME, sizeof(SERVICENAME));
NetLibIFSettingSet(libRefNum,ifCreator , ifInstance,
netIFSettingConnectionName, CONNECTIONNAME, StrLen(CONNECTIONNAME) + 1);
NetLibIFSettingSet(libRefNum,ifCreator, ifInstance,
netIFSettingModemPhone, MODEMPHONE, StrLen(MODEMPHONE)+1);
// Seta Usuario
NetLibIFSettingSet(libRefNum,ifCreator, ifInstance,
netIFSettingUsername, USERNAME, StrLen(USERNAME)+1);
// Seta Senha
NetLibIFSettingSet(libRefNum,ifCreator, ifInstance,
netIFSettingPassword, PASSWORD, StrLen(PASSWORD)+1);
// Save this configuration
NetLibConfigSaveAs(libRefNum, pConfigName);
/*******Steps that needs to be done before the new setting can
be used*******/
//Find the index of the new setting
NetLibConfigIndexFromName(libRefNum,pConfigName,
&localCfgIndexNetPanel);
//Make the new setting active setting
NetLibConfigMakeActive(libRefNum, localCfgIndexNetPanel);
//Find the index of the .default setting from the system
NetLibConfigIndexFromName(libRefNum,
(NetConfigNamePtr) netCfgNameDefault,
&localCfgIndexDefault);
//Set the new setting as an alias to the system's default
setting
NetLibConfigAliasSet(libRefNum, localCfgIndexDefault,
localCfgIndexNetPanel);
}
else
{ //if there is a service, edit the values and save.
valueLen = StrLen(SERVICENAME) + 1;
if (!err)
err = NetLibIFSettingSet(libRefNum, ifCreator, ifInstance,
netIFSettingServiceName, SERVICENAME, valueLen);
// set connection manager name (Palm OS 3.3 or higher only)
valueLen = StrLen(CONNECTIONNAME) + 1;
if (!err)
err = NetLibIFSettingSet(libRefNum, ifCreator, ifInstance,
netIFSettingConnectionName, CONNECTIONNAME, valueLen);
// seta telefone
valueLen = StrLen(MODEMPHONE) + 1;
if (!err)
err = NetLibIFSettingSet(libRefNum, ifCreator, ifInstance,
netIFSettingModemPhone, MODEMPHONE, valueLen);
// seta telefone
valueLen = StrLen(USERNAME) + 1;
if (!err)
err = NetLibIFSettingSet(libRefNum, ifCreator, ifInstance,
netIFSettingUsername, USERNAME, valueLen);
// seta telefone
valueLen = StrLen(PASSWORD) + 1;
if (!err)
err = NetLibIFSettingSet(libRefNum, ifCreator, ifInstance,
netIFSettingPassword, PASSWORD, valueLen);
// save new settings to the default settings under the name
"NetPanel"
if (!err)
err = NetLibConfigSaveAs(libRefNum, pConfigName);
}
//Find the index of the new setting
NetLibConfigIndexFromName(libRefNum,pConfigName,
&localCfgIndexNetPanel);
//Make the new setting active setting
NetLibConfigMakeActive(libRefNum, localCfgIndexNetPanel);
//Find the index of the .default setting from the system
// NetLibConfigIndexFromName(libRefNum,
// (NetConfigNamePtr) netCfgNameDefault,
&localCfgIndexDefault);
//Set the new setting as an alias to the system's default setting
NetLibConfigAliasSet(libRefNum, localCfgIndexDefault,
localCfgIndexNetPanel);
//Test only code, open the NetLib with new settings.
if (!err)
{
//Anything you want to do...
UInt16 intfErrs;
err = NetLibOpen(libRefNum, &intfErrs);
if (intfErrs)
{
switch(intfErrs)
...
As you can see, I'm trying to set the connection but it dosenÂt work as I want.
Can anybody help me?
Regards,
Leonardo RJ BR
--
For information on using the Palm Developer Forums, or to unsubscribe, please
see http://www.palmos.com/dev/support/forums/