//------------------------------------------------------------ // definition used in the whole of this package //------------------------------------------------------------ // // software version // Constant kMyAppVersionString := "1.08b"; //------------------------------------------------------------ // PCMCIA CIS list //------------------------------------------------------------ // display name DefConst( 'kStrListCISDisplayName, [ // "1234567890123456789012345678901" "MELCO WLI-PCM-L11", "MELCO WLI-PCM-L11G", "Lucent WaveLAN/IEEE", "COREGA PCCB-11", "Planex GW-NS110", "Planex GW-NS11S", "Planex GW-NS11H", "IO DATA WN-B11/PCM", "ADTEC ADLINK340C", "Farallon Skyline 11Mbps", "ELSA AirLancer MC-11", "AVAYA Wireless PC Card", "Tekram PCF200 (v2.5)", "Tekram PCF200 (v3.0)", "DELL TrueMobile 1150", "Intel PRO/Wireless 2011", "Linksys WPC11", "SMC 2632W", "D-Link DWL-650", "Addtron 802.11b", "US Robotics USR022410", "Cabletron RoamAbout", "NetGear MA401", "Buffalo WLI-CF-S11G", "ELSA Vianect WLAN MC-11", "Agere Systems Model 0110", //------------ these have long product name // "Belkin F5D6020", // "3Com 3CRWE62092A", // "3Com 3CRWE737A", //------------ failed // "PERSOL PBW001", // "Nokia D211", ]); // CIS product name string // // must be less than 31 chars ? // DefConst( 'kStrListCISProductName, [ // "1234567890123456789012345678901" "WLI-PCM-L11", "WLI-PCM-L11G", "WaveLAN/IEEE", "Wireless_LAN_PCCB-11", "GeoWave/GW-NS110", "GeoWave/GW-NS11S", "GW-NS11H Wireless LAN PC Card", "WNB11PCM", "ADLINK/340C", "HFA384x/IEEE", "AirLancer MC-11", "Avaya Wireless PC Card", "11M WLAN Card v2.5", "11M WLAN Card v3.0", "TrueMobile 1150 Series PC Card", "PRO/Wireless 2011 LAN PC Card", " Network PC CARD", "SMC2632W", "Link DWL-650 11Mbps WLAN Card", "802.11b Wireless Product", "IEEE 802.11b PC-CARD", "RoamAbout 802.11 DS", "Card", "WLI-CF-S11G", "Vianect WLAN MC-11", "Wireless PC Card Model 0110", //------------ these have long product name // "1234567890123456789012345678901" // // "11Mbps Wireless Notebook Networ", // "3CRWE62092A Wireless LAN PC Car", // "3CRWE737A AirConnect Wireless L", //------------ failed // "PBW001 Wireless LAN PC Card", // "D211" ]); // // long product name list over 31 chars // DefConst( 'kStrListCISProductNameLong, [ "11Mbps Wireless Notebook Network Adapter", "3CRWE62092A Wireless LAN PC Card", "3CRWE737A AirConnect Wireless LAN PC Card", ]); //------------------------------------------------------------- // //------------------------------------------------------------- DefConst( 'kFuncRegisterDeviceLong, func() begin foreach value in kStrListCISProductNameLong do begin call LanternPatch.RegisterLongNameOfDevice with ( value ); end; end); DefConst( 'kFuncUnregisterDeviceLong, func() begin foreach value in kStrListCISProductNameLong do begin call LanternPatch.UnRegisterLongNameOfDevice with ( value ); end; end); Constant kDeviceType := "wi11"; //-------------------------------- // device specific event defs. //-------------------------------- DefConst( 'kevSetConfig, [kDeviceType, "scfg"] ); DefConst( 'kevGetConfig, [kDeviceType, "gcfg"] ); //DefConst( 'kevEvent3, [kDeviceType, "rgck"] ); DefConst('kWaveLANEvents, [ [ 'evSetConfig, kevSetConfig, [kULong, kULong, kBinary], [] ], [ 'evGetConfig, kevGetConfig, [kULong], [kULong, kBinary] ], // [ 'evEvent3, kevEvent3, [kBinary, kBinary], [kULong] ] ] ); DefConst( 'kConfigViewName, kAppName && "setup" ); //------------------------------------------------------------- // //------------------------------------------------------------- DefConst( 'kFuncSetConfig, func( driverObj, itemID, argVal, argBin ) begin local ret; if not argVal then begin argVal := 0; end; if not argBin then begin argBin := ""; end; ret := driverObj:PostDriverEvent( 'evSetConfig, [itemID, argVal, argBin] ); ret.error and Throw( '|evt.ex.PostDriverEvent|, ret.error ); end); //------------------------------------------------------------- // //------------------------------------------------------------- DefConst( 'kFuncGetConfig, func( driverObj, itemID ) begin local ret; ret := driverObj:PostDriverEVent( 'evGetConfig, [itemID] ); print( ret.data ); ret; end); //------------------------------------------------------------- // //------------------------------------------------------------- DefConst( 'kClientInitFunc, func( client ) begin // // parse each entry of CIS name list, because number of cards is plural. // foreach value in deviceRegistry.(kAppSymbol).DeviceCISProductName do begin err := client:Instantiate( { appSymbol: kAppSymbol, CISProductName: value } ); if not err then begin err := client:init( nil ); if not err then begin break; end else begin client:Delete(); end; end; end; if err then begin print( "failed at instantiate or init, error = " & err ); return err; end; nil; end); //------------------------------------------------------------------ // //------------------------------------------------------------------ DefConst( 'kFuncGetMyPkgInfo, func() begin local tmpStores; local pkgRef; local refInfo; tmpStores := GetStores(); if not tmpStores then begin return nil; end; refInfo := nil; foreach value in tmpStores do begin pkgRef := GetPkgRef( kAppString, value ); if pkgRef then begin refInfo := GetPkgRefInfo( pkgRef ); if refInfo then begin break; end; end; end; refInfo; end); // // slot names in preference // DefConst( 'kPrefRegKeyword, 'RegKeyword ); DefConst( 'kPrefRegCode, 'RegCode ); DefConst( 'kPrefFirstTime, 'FirstTime ); // // expiration time = 30 days (by minutes) // Constant kExpirationMin := 30 * 24 * 60; //------------------------------------------------------------------ // function to check registration code //------------------------------------------------------------------ DefConst( 'kFuncCheckRegCode, func( flagCheckTime ) begin return 0; end); //------------------------------------------------------------------ // convert hexa-decimal format string to binary data array //------------------------------------------------------------------ DefConst( 'kFuncConvHexStrToBin, func( inStr ) begin local len; local binLen; local val; local sumval; local shift; local binObj; local retFrame := { length: 0, obj: nil }; if not inStr then begin return retFrame; end; len := StrLen( inStr ); if len <= 0 then begin return retFrame; end; binLen := ((len - 1) div 2) + 1; binObj := MakeBinary( binLen + 1, 'binary ); inStr := Upcase( inStr ); sumval := 0; shift := 0; for ii := 0 to (len - 1) do begin val := Ord( inStr[len - ii - 1] ); if Ord( $A ) <= val and val <= Ord( $F ) then begin val := (val - Ord( $A ) + 10); end else begin val := val - Ord( $0 ); end; sumval := sumval + (val << shift); if (ii mod 2 = 1) or (ii = len - 1) then begin StuffByte( binObj, binLen - 1 - (ii div 2), sumval ); sumval := 0; shift := 0; end else begin shift := 4; end; end; retFrame.length := binLen; retFrame.obj := binObj; return retFrame; end); // DefConst( 'kWEPKeyFormatString, 0 ); DefConst( 'kWEPKeyFormatHex, 1 ); // DefConst( 'kWEPKeyMaxLength, 13 ); // DefConst( 'kWEPConvErrTooLong, 1 ); DefConst( 'kWEPCOnvErrInvalidChar, 2 ); //------------------------------------------------------------------ // //------------------------------------------------------------------ DefConst( 'kFuncMakeWEPKeyObject, func( inStr, formatSel ) begin local binObj; local len; local str1; local str2; local retFrame := { err: nil, length: 0, obj: nil }; if formatSel = kWEPKeyFormatString then begin if not inStr then begin return retFrame; end; if StrLen( inStr ) > kWEPKeyMaxLength then begin retFrame.err := kWEPConvErrTooLong; return retFrame; end; len := StrLen( inStr ); binObj := MakeBinary( len + 2, 'binary ); StuffCString( binObj, 0, inStr ); retFrame.length := len; retFrame.obj := binObj; return retFrame; end; if formatSel = kWEPKeyFormatHex then begin str2 := Upcase( inStr ); str1 := StringFilter( str2, "0123456789ABCDEF", 'rejectAll ); if str1 and StrLen( str1 ) > 0 then begin retFrame.err := kWEPConvErrInvalidChar; return retFrame; end; if StrLen( str2 ) > (kWEPKeyMaxLength * 2) then begin retFrame.err := kWEPConvErrTooLong; return retFrame; end; tmpret := call kFuncConvHexStrToBin with ( str2 ); retFrame.length := tmpret.length; retFrame.obj := tmpret.obj; end; return retFrame; end); //------------------------------------------------------------------ // function to show notify slip with delay //------------------------------------------------------------------ DefConst( 'kFuncShowNotify, func() begin view1 := BuildContext( deviceRegistry.(kAppSymbol).NotifyView ); view1:Open(); end); //---------------------------------------- DefConst( 'kConfIDValChannel, 1 ); DefConst( 'kConfIDStrSSID, 2 ); DefConst( 'kConfIDValMode, 3 ); DefConst( 'kConfIDValWEPEna, 4 ); DefConst( 'kConfIDStrWEPKey, 5 ); DefConst( 'kConfIDValRoaming, 6 ); DefConst( 'kConfIDValPower, 7 ); DefConst( 'kConfIDValRegistOK, 8 ); // DefConst( 'kWaveLANModeInfra, 0 ); DefConst( 'kWaveLANModeAdhoc, 1 ); DefConst( 'kWaveLANModeAdhocOld, 2 ); // DefConst( 'kNetNameStrMaxLength, 32 ); //---------------------------------------- DefConst( 'kConfSlotMode, 'Mode ); DefConst( 'kConfSlotChannel, 'Channel ); DefConst( 'kConfSlotNetName, 'NetName ); DefConst( 'kConfSlotWEPOn, 'WEPOn ); DefConst( 'kConfSlotWEPKey, 'WEPKey ); DefConst( 'kConfSlotWEPFormat, 'WEPKeyFormat ); DefConst( 'kConfSlotPower, 'PowerManagement ); DefConst( 'kConfSlotRoaming, 'Roaming ); //------------------------------------------------------------------ // //------------------------------------------------------------------ DefConst( 'kConfigFunc, func( confInfo, flagEnforced ) begin local client; local err; local binObj; local tmpval; local ret1; // print( confInfo ); if not confInfo then begin print( "config frame == nil" ); return nil; end; // allocate and initialize client object // client := { _proto: UR( kUnitSymbol, 'ClientProto ) }; err := call kClientInitFunc with ( client ); if err then begin return nil; end; ret1 := call kFuncCheckRegCode with ( true ); if flagEnforced = true then begin // // check whether already registered // show notification slip // if ret1 <> 0 then begin AddDelayedCall( kFuncShowNotify, nil, 500 ); end; end; try // channel call kFuncSetConfig with ( client, kConfIDValChannel, confInfo.(kConfSlotChannel) + 1, nil ); // connecting mode call kFuncSetConfig with ( client, kConfIDValMode, confInfo.(kConfSlotMode) + 1, nil ); // SSID: as string, need to convert to C language string format // binObj := MakeBinary( kNetNameStrMaxLength + 1, 'binary ); StuffCString( binObj, 0, confInfo.(kConfSlotNetName) ); call kFuncSetConfig with ( client, kConfIDStrSSID, 0, binObj ); // WEP ON/OFF if HasSlot( confInfo, kConfSlotWEPOn ) and confInfo.(kConfSlotWEPOn) = true then begin tmpval := 1; end else begin tmpval := 0; end; call kFuncSetConfig with ( client, kConfIDValWEPEna, tmpval, nil ); // WEP key: as string retFrame := call kFuncMakeWEPKeyObject with ( confInfo.(kConfSlotWEPKey), confInfo.(kConfSlotWEPFormat) ); call kFuncSetConfig with ( client, kConfIDStrWEPKey, retFrame.length, retFrame.obj ); // power management ON/OFF if HasSlot( confInfo, kConfSlotPower ) and confInfo.(kConfSlotPower) = true then begin tmpval := 1; end else begin tmpval := 0; end; call kFuncSetConfig with ( client, kConfIDValPower, tmpval, nil ); // roaming ON/OFF if HasSlot( confInfo, kConfSlotRoaming ) and confInfo.(kConfSlotRoaming) = true then begin tmpval := 1; end else begin tmpval := 0; end; call kFuncSetConfig with ( client, kConfIDValRoaming, tmpval, nil ); // result of registration check call kFuncSetConfig with ( client, kConfIDValRegistOK, ret1, nil ); onexception |evt.ex| do begin Print( CurrentException() ); if HasSlot( CurrentException(), 'error ) then begin GetRoot():Notify( 3, "WaveLAN", "Error" ); end else begin GetRoot():Notify( 3, "WaveLAN", "Exception" ); end; end; client:Delete(); end); //------------------------------------------------------------------ // //------------------------------------------------------------------ DefConst( 'kConfigChangedFunc, func( confInfo ) begin :Config( confInfo, nil ); end); //------------------------------------------------------------------ // //------------------------------------------------------------------ DefConst( 'kFuncMakeAboutString, func() begin local refInfo; local str1; // search package information from store. // parse only internal store, because a driver must be installed into internal store. refInfo := call kFuncGetMyPkgInfo with (); if not refInfo then begin return; end; str1 := "Package Name: " & "\n" & " " & kAppString & "\n" & "Version: " & kMyAppVersionString & "\n\n" & refInfo.copyright & "\n"; end); //------------------------------------------------------------------ // Script to show "About" slip // Will be called: // - when tapping package icon // - from info button //------------------------------------------------------------------ DefConst( 'kFuncShowAbout, func() begin local str1; str1 := call kFuncMakeAboutString with (); GetRoot():Notify( 4, kAppName, str1 ); nil; end ); //--------------- // end of file //---------------