3. Benefits of using mbed Device Connector
Fully compatible with mbed OS and the LWM2M protocol (using the mbed
Client library)
Provides access to the ARM mbed IoT Device Ecosystem.
Provides an example web application, accelerating proof of concept
projects.
Uses CoAP/HTTP, TLS/TCP, DTLS/UDP and OMALWM2M, enabling energy
efficient data communication and device management.
3
7. mbed Client
mbed Client implements a subset of mbed
OS functionality and is optimized for
constrained networks and devices;
it uses the Constrained Application Protocol
(CoAP) to provide energy-efficient
communication and supports security
measures tailored for low-memory devices.
7
8. mbed Client 註冊
mbed Client Registration
1) Register
2) Update
3) Deregister
Performs the Register operation and provides
parameters that mDS requires to register the client (for
example Endpoint Name).
Maintains the registration and session (for example, it
sets the Lifetime and Queue Mode towards mbed
Device Server).
Provides information on the Objects the client supports
and existing Object Instances in the client.
8
9. Resources Path
9
GET /endpoints/endpoint1/3303/0/
Resources are categorized using the Lightweight Machine to
Machine (LWM2M) protocol from the Open Mobile Alliance (OMA)
每個Endpoint就是一個
mbed client
ObjectID/ObjectInstance/Resource
RESTful API
10. mbed client 資源管理
mbed client即是一個endpoint擁有一堆resource
mbed Device Server uses the Device Management and
Service Enabler to access Object Instances and
Resources available on the client
1) Create ---> Static or Dynamic Resource
2) Delete --> DELETE
3) Read ---> GET (Query Resource State)
4) Write---> Whenever there is a valid PUT operation for
any of the resources, the application will receive a
callback:(Set Resource State)
5) Execute -->When your Resource receives
the POST request, mbed Client parses the payload from
the request
10
11. Update Resource
11
Object
Object Instance
Resource Value
GET : Set a value to this resource and
return it
POST : Execution a function
GET
POST
/endpoints/endpoint1/Object/instance/resource
*You need to periodically update the reso
12. mbed Client data types
mbed Client is based on CoAP client. The
Resource values are represented as text/plain
format.
Different data type values have to be converted
into corresponding text/plain format.
For example, an integer value 100 is passed in a
text buffer format of 100 and it appears on the
web service side as 100 in text format.
The service must interpret this data to an
appropriate format.
12
13. HTTP 都是字串 text
13
int value = 1;
M2MResource* instance = objinst->create_dynamic_resource(“D",
“IntegerType“,M2MResourceInstance::INTEGER, true);
char buffer[20];
int size = sprintf(buffer,"%d",value);
instance->set_value((const uint8_t*)buffer, size);
float value = 1.023; --> FLOAT
bool value = true; --> BOOLEAN
char *str; --->STRING
14. build mbed client using yotta
mbed OS applications as yotta executables
yotta - to build the example programs. To
learn how to build mbed OS applications with
yotta.
yotta is written in python, and distributed
using pip, the python package manager
Yotta tutorial
• http://yottadocs.mbed.com/tutorial/tutorial.ht
ml
14
15. Code architecture in ARM mbed client
M2MInterfaceObserver
Instance
Resource
Value
Instance
Resource
Value
M2MDe
vice
(option)
M2M
Security
Object Object
CoAP GET
CoAP POST
M2MObjectList
mbed Device
Connector
M2MInterface
M2MObject
16. Control Flow
Initialize Hardware
Peripherals
create_interface ()
create_security()
create_device_object()
obj=create_object()
obj-> instance->resource
(BME280)
Register All M2M Object List
Generating multi-threads
Get Value from
BME280
Set value to
resource
Sensor
Observer
Catch SIGINT
Signal ?
yes
Unregister
Detach All Threads
Periodically
updating resource
value
Waiting for ‘Ctrl-
C’ ?
Threads
Periodically
updating
registration for
keep alive
M2MObjectList
obj=create_object()
obj-> instance->resource
(GPIO)