2021-04-13 20:29:55 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								Advanced esp-modem use cases
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								============================
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-14 17:57:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								This chapter outlines basic extensibility of the esp-modem component.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								..  _dce_factory: 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Custom instantiation with DCE factory
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								--------------------------------------
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								It is possible to create a modem handle in many different ways:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  Build a DCE on top a generic module, user defined module or build the module only (in case the application will only use AT command interface)
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  Create the DCE as a shared, unique or a vanilla pointer
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  Create a generic DCE or a templated DCE_T of a specific module (this could be one of the supported modules or a user defined module)
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								All the functionality is provided by the DCE factory
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								..  doxygengroup ::  ESP_MODEM_DCE_FACTORY
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								   :members: 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-13 20:29:55 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-01 15:52:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								..  _create_custom_module: 
  
						 
					
						
							
								
									
										
										
										
											2021-04-13 20:29:55 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Create custom module
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								--------------------
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-14 17:57:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Creating a custom module is necessary if the application needs to use a specific device that is not supported
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								and their commands differ from any of the supported devices. In this case it is recommended to define a new class
 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-09 10:26:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								representing this specific device and derive from the :cpp:class: `esp_modem::GenericModule`  (or any other available
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								module, that's close to your custom device). Then you can create the DCE using :ref: `the DCE factory<dce_factory>` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								public method :cpp:func: `esp_modem::dce_factory::Factory::create_unique_dce_from` .
 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-14 17:57:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-09 10:26:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Please note that the `` pppos_client ``  example defines a trivial custom DCE which overrides one command, and adds a new command
 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-18 19:10:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								for demonstration purposes only.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-09 10:26:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								It is also possible to create a specific DCE class that would conform to the generic `` DCE ``  API and use all generic commands,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								work with commands differently. This might be useful to add some custom preprocessing of commands or replies.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Please check the `` modem_console ``  example with `` CONFIG_EXAMPLE_MODEM_DEVICE_SHINY=y ``  configuration which demonstrates
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								overriding default `` command() ``  method to implement URC processing in user space.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-13 20:29:55 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Create new communication interface
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								----------------------------------
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-18 19:10:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								In order to connect to a device using an unsupported interface (e.g. SPI or I2C), it is necessary to implement
 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-14 17:57:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								a custom DTE object and supply it into :ref: `the DCE factory<dce_factory>` . The DCE is typically created in two steps:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-26 16:41:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								-  Define and create the corresponding terminal, which communicates on the custom interface. This terminal should support basic IO methods defined in :cpp:class: `esp_modem::Terminal`  and derive from it.
  
						 
					
						
							
								
									
										
										
										
											2021-04-14 17:57:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								-  Create the DTE which uses the custom Terminal
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Please refer to the implementation of the existing UART DTE.