Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Robobin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
plw1g21
Robobin
Commits
ef2fea87
Commit
ef2fea87
authored
6 months ago
by
Paul-Winpenny
Browse files
Options
Downloads
Patches
Plain Diff
Added a bit of code in lab (No raspberry pi so have to go home)
parent
a2f655a2
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
App/RobobinApp/ViewModels/ConnectionPageViewModel.cs
+16
-10
16 additions, 10 deletions
App/RobobinApp/ViewModels/ConnectionPageViewModel.cs
with
16 additions
and
10 deletions
App/RobobinApp/ViewModels/ConnectionPageViewModel.cs
+
16
−
10
View file @
ef2fea87
...
...
@@ -140,9 +140,9 @@ namespace RobobinApp.ViewModels
TestReadOperation
=
new
Command
(
async
()
=>
await
ReadOperationAsync
());
SendWifiInfoCommand
=
new
Command
(
OnSendWifiInfo
);
TestWriteOperation
=
new
Command
(
async
()
=>
await
PingPiASync
());
TestWriteOperation
=
new
Command
(()
=>
PingPiASync
Async
());
_adapter
.
DeviceDiscovered
+=
OnDeviceDiscovered
;
IsWifiNetworkSelectionVisible
=
false
;
...
...
@@ -165,16 +165,17 @@ namespace RobobinApp.ViewModels
}
}
private
async
Task
PingPiASync
()
private
async
Task
PingPiASync
Async
()
{
if
(
tempUnit
.
Equals
(
"C"
))
{
tempUnit
=
"F"
;
}
else
}
else
{
tempUnit
=
"C"
;
}
WriteOperationAsync
(
tempUnit
);
await
WriteOperationAsync
(
tempUnit
);
}
...
...
@@ -183,7 +184,9 @@ namespace RobobinApp.ViewModels
WifiNetworks
.
Clear
();
Debug
.
WriteLine
(
"Retrieving Wifi networks from readCharacteristic"
);
const
string
command
=
"SCAN"
;
await
WriteOperationAsync
(
command
);
var
networks
=
await
ReadOperationAsync
();
//var networks = "Network1\nNetwork2\nNetwork3"; // For testing
...
...
@@ -300,7 +303,7 @@ namespace RobobinApp.ViewModels
}
}
private
void
OnDeviceDiscovered
(
object
sender
,
DeviceEventArgs
e
)
private
void
OnDeviceDiscovered
(
object
?
sender
,
DeviceEventArgs
e
)
{
Debug
.
WriteLine
(
$"Discovered device:
{
e
.
Device
.
Name
??
e
.
Device
.
Id
.
ToString
()}
"
);
...
...
@@ -462,11 +465,12 @@ namespace RobobinApp.ViewModels
private
async
Task
<
string
>
ReadOperationAsync
(
int
retryCount
=
3
)
{
if
(
Read
Characterist
ic
==
null
||
!
IsConnected
)
if
(
Read
WriteServ
ic
e
==
null
||
!
IsConnected
)
{
Debug
.
WriteLine
(
"Read characteristic is not set or device is not connected."
);
return
"Failure"
;
}
ReadCharacteristic
=
await
ReadWriteService
.
GetCharacteristicAsync
(
Guid
.
Parse
(
rxUUID
));
Debug
.
WriteLine
(
$"READ COMMAND :
{
ReadCharacteristic
.
Uuid
}
"
);
for
(
int
attempt
=
1
;
attempt
<=
retryCount
;
attempt
++)
{
...
...
@@ -496,11 +500,13 @@ namespace RobobinApp.ViewModels
private
async
Task
<
string
>
WriteOperationAsync
(
string
command
,
string
arguments
=
""
,
int
retryCount
=
3
)
{
if
(
Write
Characterist
ic
==
null
)
if
(
Read
Write
Serv
ic
e
==
null
)
{
Debug
.
WriteLine
(
"Write characteristic is not set."
);
return
"Failure"
;
}
//Get Characteristic
WriteCharacteristic
=
await
ReadWriteService
.
GetCharacteristicAsync
(
Guid
.
Parse
(
wxUUID
));
string
joinedData
=
command
+
":"
+
arguments
;
Debug
.
WriteLine
(
$"WRITE COMMAND
{
joinedData
}
, UUID:
{
WriteCharacteristic
}
"
);
byte
[]
data
=
System
.
Text
.
Encoding
.
UTF8
.
GetBytes
(
joinedData
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment