1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
| // développé dans le cadre d'une application de communication ANT+
// appel d'une requête pour récupérer des éléments et création des interfaces en dynamique
AntPlusGeocachePcc.requestListAndRequestAccess(myContext,
/////////////////////////////////////////
// 1ere interface
new IPluginAccessResultReceiver<AntPlusGeocachePcc>()
{
@Override
public void onResultReceived(AntPlusGeocachePcc result, int resultCode, int initialDeviceStateCode)
{
//myTextViewG1.setText("avant switch");
switch(resultCode)
{
////////////////////
case AntPluginMsgDefines.MSG_REQACC_RESULT_whatSUCCESS:
geoPcc = result;
geoPcc.requestCurrentDeviceList();
Toast.makeText(getApplicationContext(), "Success Plugin", Toast.LENGTH_SHORT).show();
break;
////////////////
////////////
case AntPluginMsgDefines.MSG_REQACC_RESULT_whatCHANNELNOTAVAILABLE:
Toast.makeText(getApplicationContext(), "Channel not available", Toast.LENGTH_SHORT).show();
break;
////////////
///////////////
case AntPluginMsgDefines.MSG_REQACC_RESULT_whatOTHERFAILURE:
Toast.makeText(getApplicationContext(), "Other failure", Toast.LENGTH_SHORT).show();
break;
////////////
////////////////
case AntPluginMsgDefines.MSG_REQACC_RESULT_whatDEPENDENCYNOTINSTALLED:
Toast.makeText(getApplicationContext(), "Dependency not installed", Toast.LENGTH_SHORT).show();
break;
////////////////
//////////
case AntPluginMsgDefines.MSG_REQACC_RESULT_whatUSERCANCELLED:
Toast.makeText(getApplicationContext(), "User cancelled", Toast.LENGTH_SHORT).show();
break;
////////////
default:
Toast.makeText(getApplicationContext(), "Unrecognized result", Toast.LENGTH_SHORT).show();
break;
}
}
},
///////////////////////////////////////////////////
//Receives state changes and shows it on the status display line
// 2eme interface
new IDeviceStateChangeReceiver()
{
@Override
public void onDeviceStateChange(final int newDeviceState)
{
Toast.makeText(getApplicationContext(), "device state "+geoPcc.getDeviceName() + ": " + AntPlusGeocachePcc.statusCodeToPrintableString(newDeviceState), Toast.LENGTH_SHORT).show();
if(newDeviceState == AntPluginMsgDefines.DeviceStateCodes.DEAD)
geoPcc = null;
}
}
// virgule pour le parametre suivant
,
///////////////////////////////////////////////////
//Receives the device list updates and displays the current list
// 3eme interface
new IAvailableDeviceListReceiver()
{
@Override
public void onNewAvailableDeviceList(int[] deviceIDs, String[] deviceIdentifierStrings, int changeCode, int changingDeviceID)
{
Toast.makeText(getApplicationContext(), "Device list", Toast.LENGTH_SHORT).show();
// appel procédure proxy pour supprimer liste
appelProcedureWL("GResetListeDevices");
if(deviceIDs.length != 0)
{
//bDevicesInList = true;
for(int i=0; i < deviceIDs.length; ++i)
{
if(deviceIdentifierStrings[i].trim().length() == 0){
Toast.makeText(getApplicationContext(), "Unprogrammed", Toast.LENGTH_SHORT).show();
}
else if(deviceIdentifierStrings[i].contentEquals("_________")){
Toast.makeText(getApplicationContext(), "Invalid", Toast.LENGTH_SHORT).show();
}
// appel procédure pour afficher Toast avec WL appelProcedureWL("ToastDevices",deviceIdentifierStrings[i]+"/ "+ Integer.toString(deviceIDs[i]));
// appel procédure proxy pour ajouter éléments dans liste appelProcedureWL("GAjouteDeviceListe",deviceIdentifierStrings[i],Integer.toString(deviceIDs[i]));
}
}
else
{
Toast.makeText(getApplicationContext(), "No device found", Toast.LENGTH_SHORT).show ();
}
}
}
); |
Partager