Skip to content

Commit

Permalink
获取4G模块信息;升级核心库,支持reader.ReadFixedString(-1)获取剩余字符串
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Jan 24, 2024
1 parent 402831c commit 2562514
Show file tree
Hide file tree
Showing 17 changed files with 72 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Samples/BuzzerTest/BuzzerTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NewLife.IoT" Version="2.0.2023.1212-beta0413" />
<PackageReference Include="NewLife.IoT" Version="2.0.2024.101" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Samples/DatabaseTest/DatabaseTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NewLife.XCode" Version="11.10.2023.1201" />
<PackageReference Include="NewLife.XCode" Version="11.10.2024.101" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Samples/KeyTest/KeyTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NewLife.IoT" Version="2.0.2023.1212-beta0413" />
<PackageReference Include="NewLife.IoT" Version="2.0.2024.101" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Samples/LedTest/LedTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NewLife.IoT" Version="2.0.2023.1212-beta0413" />
<PackageReference Include="NewLife.IoT" Version="2.0.2024.101" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Samples/NetClientTest/NetClientTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NewLife.Core" Version="10.6.2023.1201" />
<PackageReference Include="NewLife.Core" Version="10.6.2024.101" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Samples/NetServerTest/NetServerTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NewLife.Core" Version="10.6.2023.1201" />
<PackageReference Include="NewLife.Core" Version="10.6.2024.101" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Samples/Serial2NetClientTest/Serial2NetClientTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NewLife.Core" Version="10.6.2023.1201" />
<PackageReference Include="NewLife.Core" Version="10.6.2024.101" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Samples/Serial2NetServerTest/Serial2NetServerTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NewLife.Core" Version="10.6.2023.1201" />
<PackageReference Include="NewLife.Core" Version="10.6.2024.101" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions Samples/SerialTest/SerialTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NewLife.Core" Version="10.6.2023.1201" />
<PackageReference Include="NewLife.IoT" Version="2.0.2023.1212-beta0413" />
<PackageReference Include="NewLife.Core" Version="10.6.2024.101" />
<PackageReference Include="NewLife.IoT" Version="2.0.2024.101" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Samples/UsbPowerTest/UsbPowerTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NewLife.IoT" Version="2.0.2023.1212-beta0413" />
<PackageReference Include="NewLife.IoT" Version="2.0.2024.101" />
</ItemGroup>

</Project>
22 changes: 22 additions & 0 deletions SmartA2/Net/ErrorCodes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace SmartA2.Net;

/// <summary>错误代码</summary>
public enum ErrorCodes : UInt16
{
/// <summary>成功</summary>
Success = 0,

Fail = 1,

Check warning on line 9 in SmartA2/Net/ErrorCodes.cs

View workflow job for this annotation

GitHub Actions / build-publish

Missing XML comment for publicly visible type or member 'ErrorCodes.Fail'

Check warning on line 9 in SmartA2/Net/ErrorCodes.cs

View workflow job for this annotation

GitHub Actions / build-test

Missing XML comment for publicly visible type or member 'ErrorCodes.Fail'

执行过程信息输出 = 5,

Check warning on line 11 in SmartA2/Net/ErrorCodes.cs

View workflow job for this annotation

GitHub Actions / build-publish

Missing XML comment for publicly visible type or member 'ErrorCodes.执行过程信息输出'

Check warning on line 11 in SmartA2/Net/ErrorCodes.cs

View workflow job for this annotation

GitHub Actions / build-test

Missing XML comment for publicly visible type or member 'ErrorCodes.执行过程信息输出'

参数错误 = 10,

Check warning on line 13 in SmartA2/Net/ErrorCodes.cs

View workflow job for this annotation

GitHub Actions / build-publish

Missing XML comment for publicly visible type or member 'ErrorCodes.参数错误'

Check warning on line 13 in SmartA2/Net/ErrorCodes.cs

View workflow job for this annotation

GitHub Actions / build-test

Missing XML comment for publicly visible type or member 'ErrorCodes.参数错误'

当前模式错误 = 11,

Check warning on line 15 in SmartA2/Net/ErrorCodes.cs

View workflow job for this annotation

GitHub Actions / build-publish

Missing XML comment for publicly visible type or member 'ErrorCodes.当前模式错误'

Check warning on line 15 in SmartA2/Net/ErrorCodes.cs

View workflow job for this annotation

GitHub Actions / build-test

Missing XML comment for publicly visible type or member 'ErrorCodes.当前模式错误'

Busy = 12,

Check warning on line 17 in SmartA2/Net/ErrorCodes.cs

View workflow job for this annotation

GitHub Actions / build-publish

Missing XML comment for publicly visible type or member 'ErrorCodes.Busy'

Check warning on line 17 in SmartA2/Net/ErrorCodes.cs

View workflow job for this annotation

GitHub Actions / build-test

Missing XML comment for publicly visible type or member 'ErrorCodes.Busy'

模块复位中 = 13,

Check warning on line 19 in SmartA2/Net/ErrorCodes.cs

View workflow job for this annotation

GitHub Actions / build-publish

Missing XML comment for publicly visible type or member 'ErrorCodes.模块复位中'

Check warning on line 19 in SmartA2/Net/ErrorCodes.cs

View workflow job for this annotation

GitHub Actions / build-test

Missing XML comment for publicly visible type or member 'ErrorCodes.模块复位中'

无此命令 = 20,

Check warning on line 21 in SmartA2/Net/ErrorCodes.cs

View workflow job for this annotation

GitHub Actions / build-publish

Missing XML comment for publicly visible type or member 'ErrorCodes.无此命令'

Check warning on line 21 in SmartA2/Net/ErrorCodes.cs

View workflow job for this annotation

GitHub Actions / build-test

Missing XML comment for publicly visible type or member 'ErrorCodes.无此命令'
}
4 changes: 4 additions & 0 deletions SmartA2/Net/NetInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ public class NetInfo

public String ICCID { get; set; }

Check warning on line 10 in SmartA2/Net/NetInfo.cs

View workflow job for this annotation

GitHub Actions / build-test

Missing XML comment for publicly visible type or member 'NetInfo.ICCID'

public String COPS { get; set; }

public Int32 CSQ { get; set; }

public String LACCI { get; set; }
}
31 changes: 23 additions & 8 deletions SmartA2/Net/NetModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ public NetResult Send(UInt16 cmd, Byte[] args)
if (reader.ReadFixedString(3) != "HTR") return null;

var cmd2 = reader.ReadUInt16();
var code = reader.ReadUInt16();
var code = (ErrorCodes)reader.ReadUInt16();
var str = reader.ReadFixedString(-1);
#if DEBUG
XTrace.WriteLine("cmd={0} code={1} message={2}", cmd2, code, str);
#endif

return new NetResult { Cmd = cmd2, Code = code, Message = str };
}
Expand Down Expand Up @@ -167,13 +170,25 @@ public String GetState()
/// <returns></returns>
public NetInfo GetNetInfo()
{
var inf = new NetInfo
{
IMEI = GetIMEI(),
IMSI = GetIMSI(),
ICCID = GetICCID(),
CSQ = GetCSQ().ToInt(),
};
var inf = new NetInfo();

inf.IMEI = GetIMEI();

Thread.Sleep(100);
inf.IMSI = GetIMSI();

Thread.Sleep(100);
inf.ICCID = GetICCID();

Thread.Sleep(100);
inf.COPS = GetCOPS();

Thread.Sleep(100);
inf.CSQ = GetCSQ().ToInt();

Thread.Sleep(100);
inf.LACCI = GetLACCI();

return inf;
}
#endregion
Expand Down
2 changes: 1 addition & 1 deletion SmartA2/Net/NetResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public class NetResult
{
public UInt16 Cmd { get; set; }

public UInt16 Code { get; set; }
public ErrorCodes Code { get; set; }

public String Message { get; set; }
}
2 changes: 1 addition & 1 deletion SmartA2/SmartA2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NewLife.IoT" Version="2.0.2023.1212-beta0413" />
<PackageReference Include="NewLife.IoT" Version="2.0.2024.101" />
<PackageReference Include="NewLife.ModbusRTU" Version="1.8.2023.1212-beta0414" />
</ItemGroup>

Expand Down
18 changes: 9 additions & 9 deletions Test/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,28 +71,28 @@ static void Test3()

XTrace.WriteLine("Info:\t{0}", module.GetInfo());

//Thread.Sleep(1000);
Thread.Sleep(1000);
XTrace.WriteLine("Version:\t{0}", module.GetVersion());
//Thread.Sleep(1000);
Thread.Sleep(1000);
XTrace.WriteLine("State:\t{0}", module.GetState());

//Thread.Sleep(1000);
Thread.Sleep(1000);
XTrace.WriteLine("IMEI:\t{0}", module.GetIMEI());
//Thread.Sleep(1000);
Thread.Sleep(1000);
XTrace.WriteLine("IMSI:\t{0}", module.GetIMSI());

//Thread.Sleep(1000);
Thread.Sleep(1000);
XTrace.WriteLine("CSQ:\t{0}", module.GetCSQ());
//Thread.Sleep(1000);
Thread.Sleep(1000);
XTrace.WriteLine("COPS:\t{0}", module.GetCOPS());

//Thread.Sleep(1000);
Thread.Sleep(1000);
XTrace.WriteLine("ICCID:\t{0}", module.GetICCID());

//Thread.Sleep(1000);
Thread.Sleep(1000);
XTrace.WriteLine("LACCI:\t{0}", module.GetLACCI());

//Thread.Sleep(1000);
Thread.Sleep(1000);
XTrace.WriteLine("LBS:\t{0}", module.GetLBS());

module.Close();
Expand Down
2 changes: 1 addition & 1 deletion XUnitTest/XUnitTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="NewLife.UnitTest" Version="1.0.2023.1204" />
<PackageReference Include="System.Speech" Version="8.0.0" />
<PackageReference Include="xunit" Version="2.6.4" />
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down

0 comments on commit 2562514

Please sign in to comment.