Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
id-iot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Per Lindgren
id-iot
Commits
6049d9f6
Commit
6049d9f6
authored
8 years ago
by
James Munns
Browse files
Options
Downloads
Patches
Plain Diff
Fix README (again)
parent
f3aae2f4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+15
-13
15 additions, 13 deletions
README.md
with
15 additions
and
13 deletions
README.md
+
15
−
13
View file @
6049d9f6
...
...
@@ -36,21 +36,23 @@ use std::io;
use
coap
::{
CoAPServer
,
CoAPResponse
,
CoAPRequest
};
fn
request_handler
(
req
:
CoAPRequest
)
->
Option
<
CoAPResponse
>
{
println!
(
"Receive request: {:?}"
,
req
);
response
println!
(
"Receive request: {:?}"
,
req
);
// Return the auto-generated response
req
.response
}
fn
main
()
{
let
addr
=
"127.0.0.1:5683"
;
let
addr
=
"127.0.0.1:5683"
;
let
mut
server
=
CoAPServer
::
new
(
addr
)
.unwrap
();
server
.handle
(
request_handler
)
.unwrap
();
let
mut
server
=
CoAPServer
::
new
(
addr
)
.unwrap
();
server
.handle
(
request_handler
)
.unwrap
();
println!
(
"Server up on {}"
,
addr
);
println!
(
"Press any key to stop..."
);
io
::
stdin
()
.read_line
(
&
mut
String
::
new
())
.unwrap
();
println!
(
"Server up on {}"
,
addr
);
println!
(
"Press any key to stop..."
);
io
::
stdin
()
.read_line
(
&
mut
String
::
new
())
.unwrap
();
println!
(
"Server shutdown"
);
println!
(
"Server shutdown"
);
}
```
...
...
@@ -61,11 +63,11 @@ extern crate coap;
use
coap
::{
CoAPClient
,
CoAPResponse
};
fn
main
()
{
let
url
=
"coap://127.0.0.1:5683/Rust"
;
println!
(
"Client request: {}"
,
url
);
let
url
=
"coap://127.0.0.1:5683/Rust"
;
println!
(
"Client request: {}"
,
url
);
let
response
:
CoAPResponse
=
CoAPClient
::
request
(
url
)
.unwrap
();
println!
(
"Server reply: {}"
,
String
::
from_utf8
(
response
.message.payload
)
.unwrap
());
let
response
:
CoAPResponse
=
CoAPClient
::
request
(
url
)
.unwrap
();
println!
(
"Server reply: {}"
,
String
::
from_utf8
(
response
.message.payload
)
.unwrap
());
}
```
...
...
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