|
9 | 9 | @using SYNCWallet.Models |
10 | 10 | @using SYNCWallet.Services |
11 | 11 | @using SYNCWallet.Services.Definitions |
| 12 | +@using SYNCWallet.Services.Implementation |
12 | 13 | @using static SYNCWallet.Models.Enums |
13 | 14 |
|
14 | 15 | @inject NavigationManager NavigationManager |
|
17 | 18 |
|
18 | 19 | <Loader BindingData="Updating firmware please wait..." ></Loader> |
19 | 20 | <div class="container FixCenter" id="LoginPanel" style="height:100vh; display:@ShowPicker;"> |
20 | | - <div class="row" style="width: 100%;display: flex;justify-content: center;align-items: center; padding:0; margin:0;"> |
| 21 | + <div class="row" style="width: 100%;display: flex;justify-content: center;align-items: center; padding:0; margin:0; height: 100vh;"> |
21 | 22 | <div class="col-md-4 col-sm-12 " style=" min-width: 500px;"> |
22 | 23 | <div class="row" style="display: flex;flex-direction: row;align-items: center;justify-content: center;"> |
23 | 24 | <img src="/logo.png" style="width: 250px;height: 200px;" alt="homepage" class="light-logo" /> |
|
27 | 28 | <h2 style="color:#EA7080; text-align:center; font-size:25pt;padding: 50px;"> |
28 | 29 | Connect and select ATmega328 compatable device. |
29 | 30 | </h2> |
| 31 | + |
| 32 | + |
30 | 33 | </div> |
31 | 34 | <a class="nav-link dropdown-toggle waves-effect waves-dark" href="#" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="color: black;font-weight: 400; text-align:center;"> |
32 | 35 | <i class="me-2 mdi mdi-access-point-network"></i> |
|
46 | 49 |
|
47 | 50 | } |
48 | 51 | </div> |
| 52 | + @if (Utilities.GetSystemOs() == 2) |
| 53 | + { |
| 54 | + <p> |
| 55 | + Important, if you have troubles connecting your board or you find that the system cannot recodnize it follow these steps. |
| 56 | + </p> |
| 57 | + <p> |
| 58 | + Make sure you add your user to dialout |
| 59 | + </p> |
| 60 | + <p> |
| 61 | + <span class="popTextWarning">sudo usermod -a -G dialout username</span> |
| 62 | + </p> |
| 63 | + <p> |
| 64 | + To show all devices: <span class="popTextWarning">sudo dmesg | tail -f</span> |
| 65 | + </p> |
| 66 | + <p> |
| 67 | + Find the connected arduino port and enable write permissions. |
| 68 | + </p> |
| 69 | + <p> |
| 70 | + <span class="popTextWarning">sudo chmod a+rw /dev/ttyUSB0</span> |
| 71 | + </p> |
| 72 | + <p> |
| 73 | + Known issue with Debian/Ubuntu based systems (nb plug and replug the arduino afterwards) it keeps pinging the rx/tx preventing the board from conencting |
| 74 | + </p> |
| 75 | + <p> |
| 76 | + <span class="popTextWarning">sudo apt remove brltty</span> |
| 77 | + </p> |
| 78 | + } |
49 | 79 | </div> |
50 | 80 | </div> |
51 | 81 | </div> |
|
54 | 84 | private ICommunication Communication { get; set; } |
55 | 85 | private IAuthenicationService AuthenicationHandler { get; set; } |
56 | 86 | private IHardwareService HardwareService { get; set; } |
| 87 | + private IUtilities Utilities { get; set; } |
57 | 88 | private string Address { get; set; } |
58 | 89 | private string Port{ get; set; } |
59 | 90 | private string ShowPicker { get; set; } |
| 91 | + int Attempts { get; set; } |
60 | 92 |
|
61 | 93 | public ArduinoModel DeviceModel { get; set; } |
62 | 94 | public List<ArduinoModel> Devices { get; set; } |
63 | 95 | TriggerLoader CurrentLoader { get; set; } |
| 96 | + public int OperatingSystem { get; set; } |
64 | 97 |
|
65 | 98 |
|
66 | 99 | System.Timers.Timer aTimer { get; set; } |
|
77 | 110 | AuthenicationHandler = ServiceHelper.GetService<IAuthenicationService>(); |
78 | 111 | HardwareService = ServiceHelper.GetService<IHardwareService>(); |
79 | 112 | Communication = ServiceHelper.GetService<ICommunication>(); |
80 | | - |
| 113 | + Utilities = ServiceHelper.GetService<IUtilities>(); |
| 114 | + Attempts = 0; |
| 115 | + |
81 | 116 |
|
82 | 117 | Communication.Init(); |
83 | 118 | //Get Supported Devices |
84 | 119 | Devices = HardwareService.GetSupportedDevices(); |
85 | 120 | Port = HardwareService.DeviceConnected(); |
| 121 | + |
| 122 | + InitTimer(); |
| 123 | + } |
| 124 | + |
| 125 | + |
| 126 | + void InitTimer() |
| 127 | + { |
86 | 128 | aTimer = new System.Timers.Timer(); |
87 | 129 | aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent); |
88 | 130 | aTimer.Interval = 5000; |
89 | 131 | aTimer.Start(); |
90 | | - |
91 | 132 | } |
92 | | - |
93 | | - |
94 | | - |
95 | 133 | // Specify what you want to happen when the Elapsed event is raised. |
96 | | - private void OnTimedEvent(object source, ElapsedEventArgs e) |
| 134 | + private async void OnTimedEvent(object source, ElapsedEventArgs e) |
97 | 135 | { |
98 | 136 |
|
99 | 137 | Port = HardwareService.DeviceConnected(); |
| 138 | + |
| 139 | + Attempts += 1; |
| 140 | + |
| 141 | + if(Attempts == 2 && string.IsNullOrEmpty(Port)) |
| 142 | + { |
| 143 | + |
| 144 | + await InvokeAsync(() => |
| 145 | + { |
| 146 | + ShowPicker = "flex"; |
| 147 | + Communication.TriggerLoader.Invoke("none"); |
| 148 | + StateHasChanged(); |
| 149 | + |
| 150 | + }); |
| 151 | + |
| 152 | + Communication.PublishError("Port not found", "Please connect atmega328 compatible device <a href='' >click here for supported devices.</a>"); |
| 153 | + KillTimer(); |
| 154 | + } |
| 155 | + |
100 | 156 | if(!string.IsNullOrEmpty(Port)) |
101 | 157 | { |
102 | | - aTimer.Stop(); |
103 | | - aTimer.Dispose(); |
| 158 | + KillTimer(); |
104 | 159 | } |
105 | 160 | } |
106 | 161 |
|
|
156 | 211 |
|
157 | 212 | private void KillTimer() |
158 | 213 | { |
159 | | - if (aTimer != null) |
160 | | - { |
161 | | - aTimer.Stop(); |
162 | | - aTimer.Dispose(); |
163 | | - } |
| 214 | + aTimer.Stop(); |
| 215 | + aTimer.Dispose(); |
164 | 216 | } |
165 | 217 |
|
166 | 218 | private async void DeviceChanged(ArduinoModel deviceType) |
|
0 commit comments