5 using System.Threading.Tasks;
7 namespace XamarinForTizen.Tizen
9 public class ModemPage : ContentPage
16 modem = new Modem(Globals.handleModem0);
21 Log.Debug(Globals.LogTag, "Modem constructor throws exception = " + ex.ToString());
24 var processPowerCommandBtn = new Button
26 Text = "ProcessPowerCommand",
27 VerticalOptions = LayoutOptions.Start,
28 HorizontalOptions = LayoutOptions.FillAndExpand
30 processPowerCommandBtn.Clicked += processPowerBtn_Clicked;
32 var flightModeBtn = new Button
34 Text = "SetGetFlightMode",
35 VerticalOptions = LayoutOptions.Start,
36 HorizontalOptions = LayoutOptions.FillAndExpand
38 flightModeBtn.Clicked += FlightModeBtn_Clicked;
40 var miscMeVersionBtn = new Button
42 Text = "GetMiscMeVersion_async_and_sync",
43 VerticalOptions = LayoutOptions.Start,
44 HorizontalOptions = LayoutOptions.FillAndExpand
46 miscMeVersionBtn.Clicked += MiscVersionBtn_Clicked;
48 var miscMeSnBtn = new Button
50 Text = "GetMiscMeSn_async_and_sync",
51 VerticalOptions = LayoutOptions.Start,
52 HorizontalOptions = LayoutOptions.FillAndExpand
54 miscMeSnBtn.Clicked += MiscMeSnBtn_Clicked;
56 var miscMeImeiBtn = new Button
58 Text = "GetMiscMeImei_async_and_sync",
59 VerticalOptions = LayoutOptions.Start,
60 HorizontalOptions = LayoutOptions.FillAndExpand
62 miscMeImeiBtn.Clicked += MiscMeImeiBtn_Clicked;
64 var checkPowerBtn = new Button
66 Text = "CheckPowerStatus",
67 VerticalOptions = LayoutOptions.Start,
68 HorizontalOptions = LayoutOptions.FillAndExpand
70 checkPowerBtn.Clicked += CheckPowerBtn_Clicked;
72 var deviceInfoBtn = new Button
74 Text = "GetDeviceInfo",
75 VerticalOptions = LayoutOptions.Start,
76 HorizontalOptions = LayoutOptions.FillAndExpand
78 deviceInfoBtn.Clicked += DeviceInfoBtn_Clicked;
80 Content = new StackLayout
82 VerticalOptions = LayoutOptions.Center,
84 processPowerCommandBtn, flightModeBtn, miscMeVersionBtn, miscMeSnBtn, miscMeImeiBtn, checkPowerBtn, deviceInfoBtn
89 private async void DeviceInfoBtn_Clicked(object sender, EventArgs e)
93 Log.Debug(Globals.LogTag, "GetDeviceInfo call start");
94 MiscDeviceInfo info = await modem.GetDeviceInfo();
97 Log.Debug(Globals.LogTag, "MiscDeviceInfo data is -- ");
98 Log.Debug(Globals.LogTag, "DeviceName = " + info.DeviceName);
99 Log.Debug(Globals.LogTag, "VendorName = " + info.VendorName);
101 Log.Debug(Globals.LogTag, "GetDeviceInfo call end");
106 Log.Debug(Globals.LogTag, "Getdeviceinfo ,exception = " + ex.ToString());
110 private void CheckPowerBtn_Clicked(object sender, EventArgs e)
114 Log.Debug(Globals.LogTag, "CheckPowerStatus call start");
115 PhonePowerStatus status = modem.CheckPowerStatus();
116 Log.Debug(Globals.LogTag, "power status = " + status);
117 Log.Debug(Globals.LogTag, "CheckPowerStatus call end");
122 Log.Debug(Globals.LogTag, "CheckPowerStatus ,exception = " + ex.ToString());
126 private async void MiscMeImeiBtn_Clicked(object sender, EventArgs e)
130 Log.Debug(Globals.LogTag, "GetMiscMeImei async call start");
131 string info = await modem.GetMiscMeImei();
134 Log.Debug(Globals.LogTag, "MiscImei number is -- " + info);
137 Log.Debug(Globals.LogTag, "GetMiscMeImei async call end");
138 Log.Debug(Globals.LogTag, "GetMiscMeImei sync call start");
139 string infosync = modem.MiscMeImeiSync;
140 if (infosync != null)
142 Log.Debug(Globals.LogTag, "MiscImei number is -- " +infosync);
145 Log.Debug(Globals.LogTag, "GetMiscMeImei sync call end");
150 Log.Debug(Globals.LogTag, "GetMiscMeImei ,exception = " + ex.ToString());
154 private async void MiscMeSnBtn_Clicked(object sender, EventArgs e)
158 Log.Debug(Globals.LogTag, "GetMiscMeSn async call start");
159 MiscSerialNumberInformation info = await modem.GetMiscMeSn();
162 Log.Debug(Globals.LogTag, "MiscSerialNumberInformation data is -- ");
163 Log.Debug(Globals.LogTag, "Esn = " + info.Esn);
164 Log.Debug(Globals.LogTag, "Imei = " + info.Imei);
165 Log.Debug(Globals.LogTag, "ImeiSv = " + info.ImeiSv);
166 Log.Debug(Globals.LogTag, "Meid = " + info.MeId);
169 Log.Debug(Globals.LogTag, "GetMiscMeSn async call end");
170 Log.Debug(Globals.LogTag, "GetMiscMeSn sync call start");
171 MiscSerialNumberInformation infosync = modem.MiscMeSnSync;
172 if (infosync != null)
174 Log.Debug(Globals.LogTag, "MiscSerialNumberInformation data is -- ");
175 Log.Debug(Globals.LogTag, "Esn = " + infosync.Esn);
176 Log.Debug(Globals.LogTag, "Imei = " + infosync.Imei);
177 Log.Debug(Globals.LogTag, "ImeiSv = " + infosync.ImeiSv);
178 Log.Debug(Globals.LogTag, "Meid = " + infosync.MeId);
181 Log.Debug(Globals.LogTag, "GetMiscMeSn sync call end");
186 Log.Debug(Globals.LogTag, "GetMiscMeSn ,exception = " + ex.ToString());
190 private async void FlightModeBtn_Clicked(object sender, EventArgs e)
194 Log.Debug(Globals.LogTag, "Modem flightmode call start");
195 await modem.SetFlightMode(PowerFlightModeRequest.Enter);
196 Log.Debug(Globals.LogTag, "Modem flightmode set Enter success");
197 bool isFlightMode = await modem.GetFlightMode();
198 Log.Debug(Globals.LogTag, "Modem flightmode get success , flightmode = "+ isFlightMode);
199 await modem.SetFlightMode(PowerFlightModeRequest.Leave);
200 Log.Debug(Globals.LogTag, "Modem flightmode set Leave success");
201 isFlightMode = await modem.GetFlightMode();
202 Log.Debug(Globals.LogTag, "Modem flightmode get success , flightmode = " + isFlightMode);
207 Log.Debug(Globals.LogTag, "Modem flightmode ,exception = " + ex.ToString());
211 private async void processPowerBtn_Clicked(object sender, EventArgs e)
213 TapiHandle handle = Globals.handleModem0;
216 handle.NotificationChanged += Handle_NotiPowerStatusChanged;
217 handle.RegisterNotiEvent(Notification.ModemPower);
218 Log.Debug(Globals.LogTag, "Modem powercommand call start");
219 await modem.ProcessPowerCommand(PhonePowerCommand.Off);
220 Log.Debug(Globals.LogTag, "Modem powercommand call off success");
225 Log.Debug(Globals.LogTag, "Modem processpower command ,exception = " + ex.ToString());
230 handle.DeregisterNotiEvent(Notification.ModemPower);
231 handle.NotificationChanged -= Handle_NotiPowerStatusChanged;
235 private async void MiscVersionBtn_Clicked(object sender, EventArgs e)
239 Log.Debug(Globals.LogTag, "GetMiscMeVersion async call start");
240 MiscVersionInformation info = await modem.GetMiscMeVersion();
243 Log.Debug(Globals.LogTag, "MiscVersionInformation data is -- ");
244 Log.Debug(Globals.LogTag, "Version = " + info.VersionMask.ToString());
245 Log.Debug(Globals.LogTag, "CalculationDate = " + info.CalculationDate);
246 Log.Debug(Globals.LogTag, "Erinam = " + info.EriNam.ToString());
247 Log.Debug(Globals.LogTag, "EriVersion = " + info.EriVersion);
248 Log.Debug(Globals.LogTag, "Hwversion = " + info.HwVersion);
249 Log.Debug(Globals.LogTag, "Swversion = " + info.SwVersion);
250 Log.Debug(Globals.LogTag, "ModelId = " + info.ModelId);
251 Log.Debug(Globals.LogTag, "Prlnam = " + info.PrlNam.ToString());
252 Log.Debug(Globals.LogTag, "Prlversion = " + info.PrlVersion);
253 Log.Debug(Globals.LogTag, "Productcode = " + info.ProductCode);
256 Log.Debug(Globals.LogTag, "GetMiscMeVersion async call end");
257 Log.Debug(Globals.LogTag, "GetMiscMeVersion sync call start");
258 MiscVersionInformation infosync = modem.MiscMeVersionSync;
259 if (infosync != null)
261 Log.Debug(Globals.LogTag, "MiscVersionInformation data is -- ");
262 Log.Debug(Globals.LogTag, "Version = " + infosync.VersionMask.ToString());
263 Log.Debug(Globals.LogTag, "CalculationDate = " + infosync.CalculationDate);
264 Log.Debug(Globals.LogTag, "Erinam = " + infosync.EriNam.ToString());
265 Log.Debug(Globals.LogTag, "EriVersion = " + infosync.EriVersion);
266 Log.Debug(Globals.LogTag, "Hwversion = " + infosync.HwVersion);
267 Log.Debug(Globals.LogTag, "Swversion = " + infosync.SwVersion);
268 Log.Debug(Globals.LogTag, "ModelId = " + infosync.ModelId);
269 Log.Debug(Globals.LogTag, "Prlnam = " + infosync.PrlNam.ToString());
270 Log.Debug(Globals.LogTag, "Prlversion = " + infosync.PrlVersion);
271 Log.Debug(Globals.LogTag, "Productcode = " + infosync.ProductCode);
274 Log.Debug(Globals.LogTag, "GetMiscMeVersion sync call end");
279 Log.Debug(Globals.LogTag, "GetMiscMeVersion ,exception = " + ex.ToString());
283 private void Handle_PropertyPowerStatusChanged(object sender, PropertyChangedEventArgs e)
285 Log.Debug(Globals.LogTag, "Handle_PropertyPowerStatusChanged event receive");
286 //Log.Debug(Globals.LogTag, "Handle_PropertyPowerStatusChanged event receive, status = " + e.Data + e.Property);
289 private void Handle_NotiPowerStatusChanged(object sender, NotificationChangedEventArgs e)
291 Log.Debug(Globals.LogTag, "Handle_NotiPowerStatusChanged event receive, status = " + e.Data + ", Notification Value = " +e.Id);