문제

I am trying to write a program that makes a phone call via bluetooth and return my balance (money). I am using the 32feet.net bluetooth api.

BluetoothAddress addr = device.DeviceAddress;
BluetoothEndPoint rep = new BluetoothEndPoint(addr, BluetoothService.Handsfree);
BluetoothClient cli = new BluetoothClient();
cli.Connect(rep);

Stream peerStream = cli.GetStream();
String dialCmd4 = "ATD*100#;\r";
Byte[] sRes = new Byte[200];

Byte[] dcB = System.Text.Encoding.ASCII.GetBytes(dialCmd4);
peerStream.Write(dcB, 0, dcB.Length);

peerStream.Read(sRes, 0, 199);
string t4 = "\n\r----------\n\r" + System.Text.Encoding.ASCII.GetString(sRes);


peerStream.Close();
cli.Close();

This code make a regular call but doesn't return a message containing my balance, and in the phone I can see this message "number not assigned".

도움이 되었습니까?

해결책

Using ATD to send SS (supplementary service) USSD (Unstructured Supplementary Service Data) commands will in the very, very, very best case only work for a small subset (or not at all. When you enter those number using the MMI they are parsed by a completely different entity than the one parsing AT commands).

What you really want to do is to use those AT commands that have specifically been written to support sending SS or USSD. For USSD you use

AT+CUSD=[<n>[,<str>[,<dcs>]]]

See the 3GPP 27.007 specification for details.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top