私は OpenNetCF.Telephony (ここから入手可能http://tapi.codeplex.com ) を使用してきました。このラッパーを使用すると、TAPI を使用して USSD メッセージを送受信するのは非常に簡単です。今まで多くの GSM デバイスで使用してきましたが、問題なく動作しました!!!
最近、Motorola MC65 と ES400 (両方とも 3.5G HSDPA デバイス) でプログラムをテストし、USSD 要求を問題なく送信できましたが、メッセージ読み取り関数によって応答がキャッチされませんでした。奇妙なことに、私が使用した他のすべての GSM デバイスで完全に機能したのと同じコードです。USSD が応答するとポップアップ ウィンドウが表示されるため、キャリアのサーバーがかなり迅速に応答していることはわかっていますが、LineGetMessage 呼び出しがヒットします。応答が受信されたことに気付かずにタイムアウト...
これは、機能をテストするために私が作成した小さなサンプルの抜粋です。送信されたメッセージが予期されていない場合、キャリアのプラットフォームは「UNKNOWN APPLICATION」または同様のメッセージで応答するため、どこでもテストできますが、この応答でさえ捕まるな…
private void btnUSSDSend_Click(object sender, EventArgs e)
{
int ret = 0;
for (int i = 0; i < m_tapi.NumberOfDevices; i++)
{
DeviceCapabilities dc = new DeviceCapabilities(LINE_DEV_CAPS_INITIAL_SIZE); //LINEDEVCAPS
dc.Store();
int dwVersion = m_tapi.NegotiateVersion(i);
ret = NativeMethods.lineGetDevCaps(m_tapi.hLineApp, i, dwVersion, 0, dc.Data); //NativeTapi.lineGetDevCaps
if (ret < 0)
{
MessageBox.Show(((ErrorCode)ret).ToString()); //LINEERR
}
if ((ErrorCode)ret == ErrorCode.StructureTooSmall) //LINEERR STRUCTURETOOSMALL
{
dc.Data = new byte[dc.NeededSize]; //dc.dwNeededSize
ret = NativeMethods.lineGetDevCaps(m_tapi.hLineApp, i, dwVersion, 0, dc.Data); //NativeTapi
}
dc.Load();
DeviceCaps.Add( i, dc);
AddressStatus ac = new AddressStatus(1024);
ac.Store();
ret = NativeMethods.lineGetAddressCaps(m_tapi.hLineApp, i, 0, dwVersion, 0, ac.Data); //NativeTapi
ac.Load();
ac = null;
}
bool found = false;
foreach (KeyValuePair<int, DeviceCapabilities> entry in DeviceCaps) //LINEDEVCAPS
{
DeviceCapabilities dc = entry.Value; //LINEDEVCAPS
found = true;
if (dc != null && dc.ProviderName.StartsWith(NativeMethods.CELLTSP_PROVIDERINFO_STRING)) //CellTSP.CELLTSP_PROVIDERINFO_STRING
{
m_line = m_tapi.CreateLine(entry.Key, MediaMode.DataModem | MediaMode.InteractiveVoice, CallPrivilege.Monitor |CallPrivilege.Owner ); //LINEMEDIAMODE LINECALLPRIVILEGE
byte[] dialArray;
LineMessage msg; //LINEMESSAGE
int flags = 0;
byte[] chResponse;
string Mensaje="";
string dial = "*888#";
int continuetonext = 0;
needtosendanother:
dialArray= Encoding.Unicode.GetBytes(dial);
int length = dialArray.Length;
int result = NativeMethods.lineSendUSSD(m_line.hLine, dialArray, dialArray.Length, 0);
AddMessage(dial, 0);
while ( NativeMethods.lineGetMessage(m_tapi.hLineApp, out msg,10000)==0 ) //NativeTapi
{
if (msg.MessageID == LineMessages.LINE_DEVSPECIFIC && (int)(msg.Param1) == (int)LineMessages.LINE_USSD) //msg.dwMessageID | LINEMESSAGES | LINEDEVSPECIFIC_CELLTSP
{
flags = 0;
chResponse = new byte[(int)(msg.Param3)]; //msg.dwParam3
result = NativeMethods.lineGetUSSD(m_line.hLine, (int)(msg.Param2), chResponse, chResponse.Length, out flags);
Mensaje = Encoding.Unicode.GetString(chResponse, 0, chResponse.Length);
AddMessage(Mensaje, 1);
break;
}
}
//in case I have to respond to another message
if (Mensaje.ToUpper().Contains("ENTER PIN:"))
{
continuetonext = 1;
dial = "1234";
}
//some more conditions here...
//
if (Mensaje.ToUpper().Contains("TRANSFERED"))
{
continuetonext = 0;
dial = "TRANSFERED";
}
if (Mensaje.ToUpper().Contains("FAILED") || Mensaje.ToUpper().Contains("ERROR"))
{
continuetonext = 0;
dial = "ERROR";
}
if (continuetonext==1) goto needtosendanother;
}
}
if (!found)
{
MessageBox.Show("Error - line not found");
return;
}
}
これは、応答を取得しないコードです。毎回タイムアウトになります:(
while ( NativeMethods.lineGetMessage(m_tapi.hLineApp, out msg,10000)==0 )
イベントに登録するパラメーターを送信したので、TAPI を正しく初期化したことがわかります。実際には、TAPI ラッパーでインスタンス化された別のスレッドによって処理される USSD 要求の送信から、確認の Linemessage を受け取ることができますが、実際のイベントこれらのデバイスで応答が発生することはありません。
3/3.5G デバイスを動作させるために必要な変更はありますか? 私は2Gデバイスが行うことすべてを(コードで)比較してきましたが、すべてがまったく同じように機能しているようです。応答を読むだけが問題です。それを機能させる方法の手がかりが本当にありません...
試してみる他のアイデアや変更するパラメーターについて、事前に感謝します...