GetDeviceID Function

Discussions about creating CAPI applications to run on Android devices
Forum rules
New release: CSPro 8.0
Post Reply
SieAIP
Posts: 24
Joined: April 7th, 2020, 5:57 pm

GetDeviceID Function

Post by SieAIP »

Hello CSPro Users Forum!
can you guys please help me set up "GetDeviceID" function for my application? Here is my Application....
CAPI - Study Exercise.zip
(33.28 KiB) Downloaded 193 times
I have read about it in the CSPro manual and have even seen an example about it as below but I don't know where to set it up so I have attached my application here so that I can receive guide on it directly

Example

Code: Select all

PROC USER_NAME 
	if not loadcase(USER_PERMISSIONS_DICT,USER_NAME) then
		errmsg("The entered user name is not in the database of users.");
		reenter;
	elseif USER_ALLOWED_DEVICE <> getdeviceid() then
		errmsg("You, %s, do not have permission to use device %s.",strip(USER_NAME),getdeviceid());
		reenter;
	endif; 
Thank you all as I anticipate your help!
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: GetDeviceID Function

Post by josh »

What exactly do you want to do with GetDeviceId?
SieAIP
Posts: 24
Joined: April 7th, 2020, 5:57 pm

Re: GetDeviceID Function

Post by SieAIP »

I have about 10 devices and they are all syncing in the same place (location). I want to be able to trace the entries submitted from each device.
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: GetDeviceID Function

Post by josh »

The easiest way to do that is to add an alpha item to your dictionary to store the device id and assign it to the value of the GetDeviceID() function in your logic. No need to put the item on a form. Just add it to the dictionary and then somewhere in your logic add:

DEVICE_ID = GetDeviceId();

You could add that for example to the preproc of the questionnaire.
SieAIP
Posts: 24
Joined: April 7th, 2020, 5:57 pm

Re: GetDeviceID Function

Post by SieAIP »

Please Josh I'm a statistician but not a good programmer...
I've attached an application to this post initially, can you guide me on how to assig the logic to the dictionary item using the attached application?
Or can you at least explain more from you previous response so that I can get it better?
Thanks!
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: GetDeviceID Function

Post by josh »

Add an item to your dictionary named DEVICE_ID that is type alpha and length 36 (the device id is never more than 36 characters).

In the logic view click on STUDYEXERCISE_LEVEL in the tree on the left to show the PROC STUDYEXERCISE_LEVEL and then add the following to that proc:

Code: Select all

preproc
DEVICE_ID = GetDeviceId();
That logic will run when you start a questionnaire and it will save the the device id to the variable you added to the dictionary.
SieAIP
Posts: 24
Joined: April 7th, 2020, 5:57 pm

Re: GetDeviceID Function

Post by SieAIP »

Thanks loads Josh! I'm on track now.
I do not take your help for granted, I'm grateful...
khurshid.arshad
Posts: 571
Joined: July 9th, 2012, 11:32 am
Location: Islamabad, Pakistan

Re: GetDeviceID Function

Post by khurshid.arshad »

Please keep in your mind that if enumerator or anyone do the factory reset, the tablet at any stage the Deveice ID will be changed.

a.
SieAIP
Posts: 24
Joined: April 7th, 2020, 5:57 pm

Re: GetDeviceID Function

Post by SieAIP »

Ok, taken, thanks!
Post Reply