How ankraft/acme-onem2m-cse works
Project Type and Purpose
• The project is an open-source oneM2M Common Service Entity (CSE) middleware, implemented in Python, aimed at education and easy extensibility.
• It provides multiple network interfaces (CoAP, HTTP, MQTT, WebSocket), a resource-oriented service layer, pluggable storage backends, and both CLI (textui) and browser-based (webui) user interfaces.
File Structure
• Top-Level Packages
– acme/protocols: network servers/clients for CoAP, HTTP, MQTT, WebSocket
– acme/runtime: bootstrapping, configuration, script manager, logging, storage initialization
– acme/services: business-logic managers (RequestManager, RegistrationManager, NotificationManager, etc.)
– acme/resources: oneM2M resource classes and their “Annc” variants
– acme/databases: binding modules for PostgreSQL and TinyDB
– acme/textui & acme/webui: CLI and web front-ends
• Supporting Directories
– acme/etc & acme/helpers: shared utilities, enums, locks, caches, geo, date, ID generators
– acme/init: startup scripts, AS-style configuration, demo content
– docs, tests, tools, and Docker for documentation, CI, testing, and deployment
README for Additional Insights
• Confirms oneM2M compliance subset, target audience (educational), tech stack (Python 3.10), and maintenance status.
• Points to external documentation, change history, and community channels.
Main Components
a. External Entities
– oneM2M AEs or devices (“Clients”)
– MQTT Broker (for MQTTClient module)
– Web browser (for webui)
– Terminal (for textui CLI)
b. ACME CSE Application Container
– Protocol Layer
• CoAPServer, HttpServer, WebSocketServer, MQTTClient
– Runtime Layer
• Configuration loader, Storage initializer (DBBinding), ScriptManager, Logging
– Service Layer
• RequestManager → Dispatcher → various Manager classes (Registration, Notification, etc.)
– Resource Model
• Resource classes (CNT, CIN, AE, etc.) → CRUD operations, Announceable vs. Announced
– Persistence Layer
• Interfaces → PostgreSQLBinding, TinyDBBinding
– Presentation Layer
• TextUI (ACMETuiApp), WebUI (webUI.py + static assets)
– Init & Scripts
• Startup scripts, demo code, attribute-policy files
c. Configuration
– acme/init and acme/runtime/configurations modules supplying JSON/INI defaults
Relationships and Data Flows
• Clients → Protocol Layer (incoming REST/CoAP/MQTT/WS requests)
• Protocol Layer → Runtime → Service Layer (RequestManager)
• Service Layer → Resource Model → Persistence Layer (storage bindings)
• Service Layer → NotificationManager → Protocol Layer (outbound notifications)
• Runtime → ScriptManager → custom AS scripts (init, tests)
• Presentation Layer queries Service Layer / Runtime for status and invokes operations
Architectural Patterns and Principles
• Layered Architecture: Protocol → Runtime → Services → Resources → Storage
• Plugin-style Storage Binding: two DBBinding implementations loaded via Configuration
• Modular Protocol Adapters: each protocol lives in its own module and registers with the Dispatcher
• Separation of Concerns: distinct packages for helpers/utilities vs. business logic vs. I/O