Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pi.hub
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
iot
pi.hub
Commits
aa535619
Commit
aa535619
authored
Jul 05, 2017
by
artur.rachwal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sth
parent
ee8c5ed3
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
0 deletions
+13
-0
Pi.Hub.Api/Controllers/StatusController.cs
+12
-0
Pi.Hub.Api/Pi.Hub.Api.csproj
+1
-0
No files found.
Pi.Hub.Api/Controllers/StatusController.cs
View file @
aa535619
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
Microsoft.AspNetCore.Mvc
;
using
Newtonsoft.Json
;
using
uPLibrary.Networking.M2Mqtt
;
using
uPLibrary.Networking.M2Mqtt.Messages
;
namespace
Pi.Hub.Api.Controllers
{
...
...
@@ -23,6 +26,15 @@ namespace Pi.Hub.Api.Controllers
{
string
serialized
=
JsonConvert
.
SerializeObject
(
obj
);
System
.
IO
.
File
.
AppendAllLines
(
"C:\\apps\\msgs.txt"
,
new
[]
{
$",
{{
\
"object\":{serialized},\"timestamp\":\"{DateTime.Now:F}\"}}"
});
var
client
=
new
MqttClient
(
"test.mosquitto.org"
);
string
[]
topic
=
{
"e1s/iot.challange"
};
byte
[]
qosLevels
=
{
MqttMsgBase
.
QOS_LEVEL_AT_LEAST_ONCE
};
client
.
Subscribe
(
topic
,
qosLevels
);
client
.
Connect
(
Guid
.
NewGuid
().
ToString
());
client
.
Publish
(
"e1s/iot.challange"
,
Encoding
.
UTF8
.
GetBytes
(
serialized
));
client
.
Disconnect
();
return
new
{
Echo
=
obj
...
...
Pi.Hub.Api/Pi.Hub.Api.csproj
View file @
aa535619
...
...
@@ -11,6 +11,7 @@
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="M2MqttDotnetCore" Version="1.0.6" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0-preview1-final" />
</ItemGroup>
<ItemGroup>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment