我正在尝试从Windows Phone 8应用重命名蓝牙设备。我知道要发送到设备的AT命令,但我相信我连接到设备somhow错误。
我有一个旧的PDA程序,可以重命名我的设备,该程序是我的AT命令的来源,我很确定它们是正确的。
如果我启动数据记录器并从我的PDA重命名我的设备,日志中不会显示任何数据,如果我从手机中执行相同的操作,我将获得Datalogger中的所有命令。
以下是我在Windows Phone App中连接设备的方法:
public void Rename()
{
var info = GetPeerInfo();
/*
GetPeerInfo() gives me the PeerInformation of my device and it works as expected.
*/
if (info == null)
return;
socket = new StreamSocket();
Task.Run(async () => { await socket.ConnectAsync(info.HostName, "1"); }).Wait();
var dataWriter = new DataWriter(socket.OutputStream);
/*
Note
"to" is an internal class containg the new name of my bluetooth device, its bluetooth config etc.
"newLaneNumber" is an integer indicading a postfix to the new name
*/
UpdateDisplayName(dataWriter, to, newLaneNumber);
Task.Run(async () => { await dataWriter.StoreAsync(); }).Wait();
socket.Dispose();
socket = null;
return;
}
这是发送AT命令的方法
private void UpdateDisplayName_Other(DataWriter dataWriter, InspectionTester newDisplayname, int newLaneNumber)
{
//Login
Thread.Sleep(6000);
dataWriter.WriteString("///");
Thread.Sleep(6000);
var bluetoothDefault = new string[]
{
"AT*AGLC=0,1",
"AT*AGCM=2,1",
"AT*AGDM=3,1",
"AT*AGPM=2,1", // pairable (not pairable: "AT*AGPM=1,1")
"AT*AGFP="+'"'+"0"+'"'+",1",
"AT*AGSM=1,1",
"AT*ADDSP=0,1",
"AT*AGMSP=1,1",
"AT*ADDCP=255,1",
"AT*ADNRP=0,1",
"AT*AMSIT=1,1",
"AT*AMET=5000,5000,1",
"AT*AMLP=0,0,1",
"AT*AMMP=255,1",
"AT*AMWFM=1,6,1",
"AT*AMPM=1,1",
"AT*ACCB=1,1",
"AT*AMDS=1,1,1",
"AT*AMWS=0,0,0,0,0,1"
};
var tmpString = string.Empty;
foreach (var element in bluetoothDefault)
{
tmpString = element + "\r";
dataWriter.WriteString(tmpString);
Thread.Sleep(100);
}
//Name
tmpString = "AT*AGLN=\"" + to.BluetoothName + newLaneNumber.ToString("D2") + "\",1\r";
dataWriter.WriteString(tmpString);
Thread.Sleep(100);
//Baudrate
tmpString = "AT*AMRS=" + to.BluetoothConfig + "\r";
dataWriter.WriteString(tmpString);
//Logout
tmpString = "AT*AMWS=0,0,0,0,1,0\r";
dataWriter.WriteString(tmpString);
}
有些地方我做错了什么,我相信我连接错误的方式,但我找不到任何关于如何做的信息。
以下是从手机更新尝试中获取的日志:
///AT*AGLC=0,1
AT*AGCM=2,1
AT*AGDM=3,1
AT*AGPM=2,1
AT*AGFP="0",1
AT*AGSM=1,1
AT*ADDSP=0,1
AT*AGMSP=1,1
AT*ADDCP=255,1
AT*ADNRP=0,1
AT*AMSIT=1,1
AT*AMET=5000,5000,1
AT*AMLP=0,0,1
AT*AMMP=255,1
AT*AMWFM=1,6,1
AT*AMPM=1,1
AT*ACCB=1,1
AT*AMDS=1,1,1
AT*AMWS=0,0,0,0,0,1
AT*AGLN="BMGTMGA1-01",1
AT*AMRS=5,1,2,2,2,1,1
AT*AMWS=0,0,0,0,1,0
如果您需要更多信息,请说明。
答案 0 :(得分:-1)
1分:大部分设备都不支持重命名。他们中的一些人只是通过将信息保存在RAM而不是闪存或EEPROM中来支持它。