1086 views|6 replies

970

Posts

0

Resources
The OP
 

I would like to ask, what is the use of sending Observer and Discover messages to devices from the OneNET platform? [Copy link]

邀请:@maychang   @huo_hu   @vincentc543   @lugl4313820   参与回复

See the following information

Platform subscription & device resource discovery

After the terminal device successfully logs in to the platform, the OneNET platform will send Observer message and Discover message to the device. After the terminal device receives these two messages, the basic communication suite will automatically process them without the need for the user to process them separately.

I would like to ask, what is the use of sending Observer and Discover messages to devices from the OneNET platform?

This post is from MCU

Latest reply

Just apply it first. You will understand some things after using them more. You need to understand the principle. Unless you are a professional researcher in this field, it is enough to be able to use it in reality. For example, if you learn to drive a car, it is enough to be able to drive well. As for how the wheels are made, the working principle of the engine, how the car ECU communicates with its equipment, etc., you don’t have to understand everything.   Details Published on 2022-9-3 10:37
 

6824

Posts

11

Resources
2
 

Observer Pattern

When there is a one-to-many relationship between objects, the Observer Pattern is used. For example, when an object is modified, it automatically notifies the objects that depend on it. The Observer Pattern is a behavioral pattern.

introduce

Intent: Define a one-to-many dependency relationship between objects. When the state of an object changes, all objects that depend on it are notified and automatically updated.

The main solution is to notify other objects of changes in the state of an object, and to take into account ease of use and low coupling to ensure a high degree of collaboration.

When to use: When the state of an object (target object) changes, all dependent objects (observer objects) will be notified and broadcast notification will be made.

How to solve it: Using object-oriented technology can weaken this dependency.

Key code: There is an ArrayList in the abstract class to store observers.

Application examples: 1. During an auction, the auctioneer observes the highest bid and then informs other bidders to bid. 2. In Journey to the West, Wukong asks the Bodhisattva to subdue Red Boy. The Bodhisattva sprinkles water on the ground and attracts an old turtle. The turtle is the observer, who observes the Bodhisattva's action of sprinkling water.

Advantages: 1. The observer and the observed are abstractly coupled. 2. A trigger mechanism is established.

Disadvantages: 1. If an observed object has many direct and indirect observers, it will take a lot of time to notify all observers. 2. If there is a circular dependency between the observer and the observed target, the observed target will trigger a circular call between them, which may cause the system to crash. 3. The observer pattern has no corresponding mechanism to let the observer know how the observed target object has changed, but only know that the observed target has changed.

Use scenarios:

  • An abstract model has two aspects, one of which depends on the other. Encapsulating these aspects in separate objects allows them to be changed and reused independently.
  • A change in one object will cause one or more other objects to change as well, without knowing exactly how many objects will change, which can reduce the coupling between objects.
  • An object must notify other objects without knowing who those objects are.
  • It is necessary to create a trigger chain in the system. The behavior of object A will affect object B, the behavior of object B will affect object C... You can use the observer pattern to create a chain trigger mechanism.
This post is from MCU
 
 

6824

Posts

11

Resources
3
 

1. Create user accounts, create products, and add virtual devices on the OneNET platform.

  2. Send AT commands through the serial port to configure the NB module (for specific data, see the operation examples in Chapter 5)
    2.2 AT+MIPLCREATE Create basic communication suite
    2.3 AT+MIPLADDOBJ Add Object
    2.4 AT+MIPLOPEN Register device
    2.4 AT+MIPLOBSERVERSP Reply to Observe message
    2.5 AT+MIPLDISCOVERRSP Reply to Discover message
    2.6 Add module to automatically reply to observe and discover messages (see Chapter 5.6 for details, both are compatible and only one can be used at the same time)

  3. OneNET module read, write and execute operations
    3.1 The platform issues read, write and execute operation instructions, and needs to reply to the corresponding AT instructions (see the previous chapters 4 and 5 for detailed processes and data)
    3.2 The platform needs to observe resources first, and then the corresponding resource information can be reported

  NOTE: After completing the above steps, you are connected to the platform and can perform operations such as reporting data and issuing commands.

This post is from MCU
 
 
 

6824

Posts

11

Resources
4
 

Thanks for the question, I also learned about these two messages. In general, after successfully connecting to the service, its SDK will automatically process these two messages. Of course, you can also process these two messages manually.

This post is from MCU

Comments

Thank you very much for your reply. I have learned MQTT, but I only understand that the client subscribes to topics and publishes messages. I don't understand what the MQTT server observes and discovers. What is its use? Can you explain it in more detail?  Details Published on 2022-9-3 08:29
 
 
 

970

Posts

0

Resources
5
 
lugl4313820 posted on 2022-9-3 06:56 Thanks for the question, which made me learn about these two messages. In general, after successfully connecting to the service, its SDK will automatically process these two messages...

Thank you very much for your reply.

I have learned about MQTT, but I only understand that the client subscribes to topics and publishes messages. I don't understand what the MQTT server does for observation and discovery. What is it used for? Can you explain it in more detail?

This post is from MCU

Comments

Just apply it first. You will understand some things after using them more. You need to understand the principle. Unless you are a professional researcher in this field, in reality, it is enough to be able to use it. For example, if you learn to drive a car and can drive well, it is enough. As for how the wheels are made, the working principle of the engine, how the car ECU communicates with its equipment, etc.  Details Published on 2022-9-3 10:37
 
 
 

6824

Posts

11

Resources
6
 
Yishayishi published on 2022-9-3 08:29 Thank you very much for your reply. I learned MQTT, but I only understood that the client subscribes to topics and publishes messages, ...

Just apply it first. You will understand some things after using them more. You need to understand the principle. Unless you are a professional researcher in this field, it is enough to be able to use it in reality. For example, if you learn to drive a car, it is enough to be able to drive well. As for how the wheels are made, the working principle of the engine, how the car ECU communicates with its equipment, etc., you don’t have to understand everything.

This post is from MCU

Comments

Thank you very much. I agree with your point of view. Thanks again.  Details Published on 2022-9-3 10:58
 
 
 

970

Posts

0

Resources
7
 
lugl4313820 posted on 2022-9-3 10:37 Apply it first. You will know some things after using them more. To understand the principle, unless you are a professional in this field, in reality, you can use it...

Thank you very much. I agree with your point of view. Thanks again.

This post is from MCU
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list