22using HeboTech . ATLib . DTOs ;
33using HeboTech . ATLib . Events ;
44using HeboTech . ATLib . Modems ;
5- using HeboTech . ATLib . Modems . D_LINK ;
5+ using HeboTech . ATLib . Modems . Cinterion ;
6+ using HeboTech . ATLib . Modems . Generic ;
67using HeboTech . ATLib . Parsers ;
78using System ;
89using System . Collections . Generic ;
@@ -19,7 +20,7 @@ public static async Task RunAsync(System.IO.Stream stream, string pin)
1920
2021 using AtChannel atChannel = AtChannel . Create ( stream ) ;
2122 //atChannel.EnableDebug((string line) => Console.WriteLine(line));
22- using IModem modem = new DWM222 ( atChannel ) ;
23+ using IMC55i modem = new MC55i ( atChannel ) ;
2324 atChannel . Open ( ) ;
2425 await atChannel . ClearAsync ( ) ;
2526
@@ -32,23 +33,23 @@ public static async Task RunAsync(System.IO.Stream stream, string pin)
3233 modem . ErrorReceived += Modem_ErrorReceived ;
3334 modem . GenericEvent += Modem_GenericEvent ;
3435
35- // Configure modem with required settings
36- await modem . SetRequiredSettingsAsync ( ) ;
37-
38- await modem . SetSmsMessageFormatAsync ( smsTextFormat ) ;
36+ // Configure modem with required settings before PIN
37+ var requiredSettingsBeforePin = await modem . SetRequiredSettingsBeforePinAsync ( ) ;
38+ Console . WriteLine ( $ "Successfully set required settings before PIN: { requiredSettingsBeforePin } " ) ;
39+ await Task . Delay ( TimeSpan . FromSeconds ( 2 ) ) ;
3940
4041 var simStatus = await modem . GetSimStatusAsync ( ) ;
4142 Console . WriteLine ( $ "SIM Status: { simStatus } ") ;
4243
43- await modem . ReInitializeSimAsync ( ) ;
44+ // await modem.ReInitializeSimAsync();
4445
4546 simStatus = await modem . GetSimStatusAsync ( ) ;
4647 Console . WriteLine ( $ "SIM Status: { simStatus } ") ;
4748
48- if ( simStatus . IsSuccess && simStatus . Result == SimStatus . SIM_READY )
49+ if ( simStatus . Success && simStatus . Result == SimStatus . SIM_READY )
4950 {
5051 }
51- else if ( simStatus . IsSuccess && simStatus . Result == SimStatus . SIM_PIN )
52+ else if ( simStatus . Success && simStatus . Result == SimStatus . SIM_PIN )
5253 {
5354 var simPinStatus = await modem . EnterSimPinAsync ( new PersonalIdentificationNumber ( pin ) ) ;
5455 Console . WriteLine ( $ "SIM PIN Status: { simPinStatus } ") ;
@@ -57,9 +58,9 @@ public static async Task RunAsync(System.IO.Stream stream, string pin)
5758 {
5859 simStatus = await modem . GetSimStatusAsync ( ) ;
5960 Console . WriteLine ( $ "SIM Status: { simStatus } ") ;
60- if ( simStatus . IsSuccess && simStatus . Result == SimStatus . SIM_READY )
61+ if ( simStatus . Success && simStatus . Result == SimStatus . SIM_READY )
6162 break ;
62- await Task . Delay ( TimeSpan . FromMilliseconds ( 1000 ) ) ;
63+ await Task . Delay ( TimeSpan . FromSeconds ( 1 ) ) ;
6364 }
6465 }
6566 else
@@ -68,21 +69,33 @@ public static async Task RunAsync(System.IO.Stream stream, string pin)
6869 return ;
6970 }
7071
72+ await Task . Delay ( TimeSpan . FromSeconds ( 2 ) ) ;
73+
7174 for ( int i = 0 ; i < 10 ; i ++ )
7275 {
7376 var imsi = await modem . GetImsiAsync ( ) ;
7477 Console . WriteLine ( $ "IMSI: { imsi } ") ;
75- if ( imsi . IsSuccess )
78+ if ( imsi . Success )
7679 break ;
7780 await Task . Delay ( TimeSpan . FromMilliseconds ( 1000 ) ) ;
7881 }
7982
83+ // Configure modem with required settings after PIN
84+ var requiredSettingsAfterPin = await modem . SetRequiredSettingsAfterPinAsync ( ) ;
85+ Console . WriteLine ( $ "Successfully set required settings after PIN: { requiredSettingsAfterPin } ") ;
86+
87+ var smsMessageFormat = await modem . SetSmsMessageFormatAsync ( smsTextFormat ) ;
88+ Console . WriteLine ( $ "Setting SMS message format: { smsMessageFormat } ") ;
89+
8090 var signalStrength = await modem . GetSignalStrengthAsync ( ) ;
8191 Console . WriteLine ( $ "Signal Strength: { signalStrength } ") ;
8292
8393 var batteryStatus = await modem . GetBatteryStatusAsync ( ) ;
8494 Console . WriteLine ( $ "Battery Status: { batteryStatus } ") ;
8595
96+ //var mc55iBatteryStatus = await modem.MC55i_GetBatteryStatusAsync();
97+ //Console.WriteLine($"MC55i Battery Status: {mc55iBatteryStatus}");
98+
8699 var productInfo = await modem . GetProductIdentificationInformationAsync ( ) ;
87100 Console . WriteLine ( $ "Product Information:{ Environment . NewLine } { productInfo } ") ;
88101
@@ -92,34 +105,21 @@ public static async Task RunAsync(System.IO.Stream stream, string pin)
92105 var dateTime = await modem . GetDateTimeAsync ( ) ;
93106 Console . WriteLine ( $ "Date and time: { dateTime } ") ;
94107
95- var newSmsIndicationResult = await modem . SetNewSmsIndication ( 2 , 1 , 0 , 0 , 0 ) ;
108+ var newSmsIndicationResult = await modem . SetNewSmsIndication ( 2 , 1 , 0 , 0 , 1 ) ;
96109 Console . WriteLine ( $ "Setting new SMS indication: { newSmsIndicationResult } ") ;
97110
98111 var supportedStorages = await modem . GetSupportedPreferredMessageStoragesAsync ( ) ;
99112 Console . WriteLine ( $ "Supported storages:{ Environment . NewLine } { supportedStorages } ") ;
100113 var currentStorages = await modem . GetPreferredMessageStoragesAsync ( ) ;
101114 Console . WriteLine ( $ "Current storages:{ Environment . NewLine } { currentStorages } ") ;
102- var setPreferredStorages = await modem . SetPreferredMessageStorageAsync ( "ME" , "ME" , "ME" ) ;
115+ var setPreferredStorages = await modem . SetPreferredMessageStorageAsync ( MessageStorage . SM , MessageStorage . SM , MessageStorage . SM ) ;
103116 Console . WriteLine ( $ "Storages set:{ Environment . NewLine } { setPreferredStorages } ") ;
104117
105- //var singleSms = await modem.ReadSmsAsync(2, smsTextFormat);
106- //Console.WriteLine($"Single SMS: {singleSms}");
107-
108- var smss = await modem . ListSmssAsync ( SmsStatus . ALL ) ;
109- if ( smss . IsSuccess )
110- {
111- foreach ( var sms in smss . Result )
112- {
113- Console . WriteLine ( $ "SMS: { sms } ") ;
114- var smsDeleteStatus = await modem . DeleteSmsAsync ( sms . Index ) ;
115- Console . WriteLine ( $ "Delete SMS #{ sms . Index } - { smsDeleteStatus } ") ;
116- }
117- }
118-
119- Console . WriteLine ( "Done. Press 'a' to answer call, 'd' to dial, 'h' to hang up, 's' to send SMS, 'r' to read an SMS, 'u' to send USSD code, '+' to enable debug, '-' to disable debug and 'q' to exit..." ) ;
118+ Console . WriteLine ( "Done. Press 'a' to answer call, 'd' to dial, 'h' to hang up, 's' to send SMS, 'r' to read an SMS, 'l' to list all SMSs, 'u' to send USSD code, '+' to enable debug, '-' to disable debug and 'q' to exit..." ) ;
120119 ConsoleKey key ;
121120 while ( ( key = Console . ReadKey ( ) . Key ) != ConsoleKey . Q )
122121 {
122+ Console . WriteLine ( ) ;
123123 switch ( key )
124124 {
125125 case ConsoleKey . A :
@@ -186,6 +186,13 @@ public static async Task RunAsync(System.IO.Stream stream, string pin)
186186 var ussdResult = await modem . SendUssdAsync ( ussd ) ;
187187 Console . WriteLine ( $ "USSD Status: { ussdResult } ") ;
188188 break ;
189+ case ConsoleKey . L :
190+ Console . WriteLine ( "List all SMSs:" ) ;
191+ var smss = await modem . ListSmssAsync ( SmsStatus . ALL ) ;
192+ if ( smss . Success )
193+ foreach ( var sms in smss . Result )
194+ Console . WriteLine ( $ "SMS: { sms } ") ;
195+ break ;
189196 case ConsoleKey . OemPlus :
190197 atChannel . EnableDebug ( ( string line ) => Console . WriteLine ( line ) ) ;
191198 Console . WriteLine ( "Debug enabled" ) ;
@@ -210,7 +217,8 @@ private static void Modem_ErrorReceived(object sender, ErrorEventArgs e)
210217
211218 private static void Modem_UssdResponseReceived ( object sender , UssdResponseEventArgs e )
212219 {
213- Console . WriteLine ( $ "USSD Response: { e . Status } - { e . Response } - ({ e . CodingScheme } )") ;
220+ if ( e != null )
221+ Console . WriteLine ( $ "USSD Response: { e . Status } - { e . Response } - ({ e . CodingScheme } )") ;
214222 }
215223
216224 private static void Modem_CallEnded ( object sender , CallEndedEventArgs e )
0 commit comments