PDA

View Full Version : detect if phone is plugged in.



nad46
10-08-2009, 03:52 AM
is there anyway to kno if a phone or device is plugged in , any dlls or plugins ??

thanks.

IdeasVacuum
10-08-2009, 05:21 AM
Depends what it is plugged into. If it is a USB device, then Windows should see it as a drive. If so, you can simply search a reasonable range of drive letters for a known filename. For example

bFileExists = File.DoesExist("G:\\MyFile.txt");

if (bFileExists == true) -- the device is there

pabloko
10-08-2009, 05:25 AM
If your mobile generates a SerialPort, you can use serial port action plugin to detects it, also if this is connected by usb you can get all devices in a list with vid&pid with dll, this unique numbers of usb descriptors can help you

nad46
10-08-2009, 05:55 PM
Well, what if say i didnt know the same of the phone as it could have been renamed, may i say find the phone modela and if its connect or not using these?

thanks for your reply:yes

IdeasVacuum
10-08-2009, 10:03 PM
That's where it becomes tricky - if the phone device itself "knows" it's name, you will need to know how to collect that info. Windows can display the name of the device (which it sees as a drive) if the manufacturer has indeed named it. Remember, a phone is not specifically a computer device, it therefore does not need to comply with computer device conventions. Different manufacturers may have different ways of storing such info, and it is not necessarily stored in the memory that the computer automatically sees via USB, since that is reserved for the User's stuff. To cut a long story short, you will need to find out more from the phone manufacturers - most of whom will offer info on their websites, look for a mention of API or SDK.

Create an AMS project with a Paragraph Object and experiment with these functions:

sAllInfo = "";
tDrives = {};

tDrives = Drive.Enumerate();

for i,k in tDrives do

iDriveType = Drive.GetType(k);

if (iDriveType == 0) then sDriveType = " Drive Type: Unknown\r\n"; end
if (iDriveType == 1) then sDriveType = " Drive Type: Invalid\r\n"; end
if (iDriveType == 2) then sDriveType = " Drive Type: Removable\r\n"; end
if (iDriveType == 3) then sDriveType = " Drive Type: Fixed\r\n"; end
if (iDriveType == 4) then sDriveType = " Drive Type: Remote\r\n"; end
if (iDriveType == 5) then sDriveType = " Drive Type: CD ROM\r\n"; end
if (iDriveType == 6) then sDriveType = " Drive Type: RAM Disk\r\n"; end

sDrive = "Drive: " .. k .. sDriveType;
sAllInfo = sAllInfo .. sDrive;

tDriveInfo = {};
tDriveInfo = Drive.GetInformation(k);

if (tDriveInfo) then

sDriveLabel = "Drive Label: " .. tDriveInfo.Label .. "\r\n";
sDriveFileSys = "Drive Format: " .. tDriveInfo.FileSystem .. "\r\n";
sDriveSerialNum = "Drive Serial Number: " .. tDriveInfo.SerialNumber .. "\r\n";
sDriveDisplay = "Drive Display: " .. tDriveInfo.DisplayName .. "\r\n";

sAllInfo = sAllInfo .. sDriveLabel .. sDriveFileSys .. sDriveSerialNum .. sDriveDisplay;

end

sAllInfo = sAllInfo .. "----------------------------------------------------\r\n";

end

Paragraph.SetText("Paragraph1", sAllInfo);

nad46
10-09-2009, 02:47 AM
mm thanks vaccum using ur code i was able to retrieve all the drives except the phone

alright wat if say i kno the manfacture , in this case lets keep it as the popular iphone windows detects its model name as Apple iphone

nad46
10-09-2009, 03:47 AM
could we some how weave that in there?
also the manfacture is given as Apple Inc
could that help?

IdeasVacuum
10-09-2009, 05:28 AM
Sounds like Windows does detect the phone, but the question is, does Windows detect it as a drive? Sounds as though the answer is no and thus comms may be dependent on manufacturer-supplied software. Have you tried File.DoesExist to see if you can at least read-write? What do the Apple people say?

nad46
10-09-2009, 09:46 PM
Sounds like Windows does detect the phone, but the question is, does Windows detect it as a drive? Sounds as though the answer is no and thus comms may be dependent on manufacturer-supplied software. Have you tried File.DoesExist to see if you can at least read-write? What do the Apple people say?

windows detects it as a portable device so no i dont think its detected as a drive, and then again i cant use file.DoesExist because if they have renamed thier phone that means the location path will change, Apple uses itunes to reconginze if the phone is plugged in,

So i dont think Autoplay can find if there is a detected phone plugged in without the name???
thank you for your help anyway:yes

rexzooly
10-10-2009, 05:26 AM
windows detects it as a portable device so no i dont think its detected as a drive, and then again i cant use file.DoesExist because if they have renamed thier phone that means the location path will change, Apple uses itunes to reconginze if the phone is plugged in,

So i dont think Autoplay can find if there is a detected phone plugged in without the name???
thank you for your help anyway:yes

i think iturn will a miniter the com ports knowing the ID tag for a ipod or then a ipod/iphone is pluged in they are in strage mode just not seeable to windows
there are many programs out there.