Mconfig API¶
Mconfig
(Mesh Network Configuration) is a network configuration solution for ESP-WIFI-MESH, which sends network configuration information to ESP-WIFI-MESH devices in a convenient and efficient manner.
Application Examples¶
For ESP-MDF examples, please refer to the directory function_demo/mconfig, which includes:
- Connect to the external network: This can be achieved by the root node via MQTT and HTTP.
Mconfig Blufi¶
Header File¶
Functions¶
-
mdf_err_t
mconfig_blufi_init
(const mconfig_blufi_config_t *config)¶ initialize Bluetooth network configuratxion
- Attention
- The BLE stack must be enabled first through menuconfig configuration.
- Return
- MDF_OK
- MDF_ERR_INVALID_ARG
- MDF_FAIL
Structures¶
-
struct
mconfig_blufi_config_t
¶ Bluetooth configuration network related configuration.
Public Members
-
char
name
[MCONFIG_BLUFI_NAME_SIZE
]¶ Local device & peripheral name, If the length of name is greater than 10 bytes, it will overwrite custom_data, and custom_data will not be available.
-
uint16_t
company_id
¶ Company Identifiers (https://www.bluetooth.com/specifications/assigned-numbers/company-identifiers)
-
uint16_t
tid
¶ Type of device
-
uint8_t
custom_size
¶ Custom data size
-
uint8_t
custom_data
[MCONFIG_BLUFI_CUSTOM_SIZE
]¶ Placed in a Bluetooth broadcast package
-
bool
only_beacon
¶ Send only beacon does not support connection
-
char
-
struct
mconfig_blufi_data_t
¶ Mconfig_blufi event callback parameters.
Macros¶
-
MCONFIG_BLUFI_NAME_SIZE
¶ Contains the ending character
-
MCONFIG_BLUFI_CUSTOM_SIZE
¶ BLE broadcast data packets have a valid length of up to 31 bytes
-
CONFIG_BLUFI_BROADCAST_OUI
¶ Used to filter other Bluetooth broadcast packets, 3 bytes CONFIG_BLUFI_FILTER_OUI
-
MDF_EVENT_MCONFIG_BLUFI_STARTED
¶
-
MDF_EVENT_MCONFIG_BLUFI_STOPED
¶
-
MDF_EVENT_MCONFIG_BLUFI_CONNECTED
¶
-
MDF_EVENT_MCONFIG_BLUFI_DISCONNECTED
¶
-
MDF_EVENT_MCONFIG_BLUFI_STA_CONNECTED
¶
-
MDF_EVENT_MCONFIG_BLUFI_STA_DISCONNECTED
¶
-
MDF_EVENT_MCONFIG_BLUFI_FINISH
¶
-
MDF_EVENT_MCONFIG_BLUFI_RECV
¶
Mconfig Chain¶
Header File¶
Functions¶
-
mdf_err_t
mconfig_chain_slave_init
(void)¶ Chain configuration network slave initialization for obtaining network configuration information.
- Attention
- The received network configuration information is sent to mconfig_queue
- Return
- MDF_OK
- MDF_FAIL
-
mdf_err_t
mconfig_chain_slave_channel_switch_disable
(void)¶ Disable slave to switch wifi channel.
- Attention
- Chain configuration network slaves, will constantly switch channels to find the master, if you need to make a wifi connection, You must first disable the switch of the slave wifi channel.
- Return
- MDF_OK
- MDF_FAIL
-
mdf_err_t
mconfig_chain_slave_channel_switch_enable
(void)¶ Enable slave to switch wifi channel.
- Attention
- The slave will continuously switch the wifi channel for scanning, which is enabled by default.
- Return
- MDF_OK
- MDF_FAIL
-
mdf_err_t
mconfig_chain_slave_deinit
(void)¶ Free all resource allocated in mconfig_chain_slave_init and stop chain_slave task.
- Return
- MDF_OK
- MDF_ERR_NOT_SUPPORTED
-
mdf_err_t
mconfig_chain_master
(const mconfig_data_t *config, TickType_t duration_ticks)¶ Chain configuration network host initialization, sending network configuration information to the slave.
- Return
- MDF_OK
- MDF_ERR_NOT_SUPPORTED
- Parameters
config
: This configuration information will be sent to the slave device.duration_ticks
: Stop chain_master after the set time
-
mdf_err_t
mconfig_chain_filter_rssi
(int8_t rssi)¶ Chain Devices with weak rssi are not allowed to join the network.
- Note
- If you use it, you must call after
mconfig_chain_master
- Return
- MDF_OK
- MDF_FAIL__MCONFIG_CHAIN_H__
- Parameters
rssi
: When the device signal strength is less than this value, it will not join the network.
Mconfig Queue¶
Header File¶
Functions¶
-
mdf_err_t
mconfig_queue_write
(const mconfig_data_t *mconfig_data, TickType_t wait_ticks)¶ Write data to the queue of mconfig.
- Return
- MDF_OK
- MDF_ERR_TIMEOUT
- Parameters
mconfig_data
: information that points to the configuration of the networkwait_ticks
: wait time if a packet isn’t immediately available
-
mdf_err_t
mconfig_queue_read
(mconfig_data_t **mconfig_data, TickType_t wait_ticks)¶ READ data to the queue of mconfig.
- Return
- MDF_OK
- MDF_ERR_TIMEOUT__MCONFIG_QUEUE_H__
- Parameters
mconfig_data
: mconfig_data is a secondary pointer and must be called after MDF_FREE is usedwait_ticks
: wait time if a packet isn’t immediately available
Structures¶
-
struct
mconfig_whitelist_t
¶ List of configured networks for each device.
Public Members
-
uint8_t
addr
[MWIFI_ADDR_LEN
]¶ the address of the device
-
uint8_t
-
struct
mconfig_data_t
¶ Network configuration information.
Public Members
-
mwifi_config_t
config
¶ Mwifi AP configuration
-
mwifi_init_config_t
init_config
¶ Mwifi initialization configuration, Used only during debugging
-
uint8_t
custom
[32 +CONFIG_MCONFIG_CUSTOM_EXTERN_LEN
]¶ Custom data for specific applications, such as: uuid, token, username, etc
-
uint16_t
whitelist_size
¶ The size of the device’s whitelist
-
mconfig_whitelist_t
whitelist_data
[0]¶ Whitelist of devices
-
mwifi_config_t
Mconfig Security¶
Header File¶
Functions¶
-
mdf_err_t
mconfig_random
(void *rng_state, uint8_t *output, size_t len)¶ Generate an array of random numbers.
- Return
- MDF_OK
- MDF_ERR_INVALID_ARG
- Parameters
rng_state
: The seed of the random number, not used temporarily, you can pass NULLoutput
: Pointer to an array of random numberslen
: The length of the array of random numbers
-
mdf_err_t
mconfig_dhm_gen_key
(uint8_t *param, ssize_t param_size, uint8_t *privkey, uint8_t *pubkey)¶ Generate a public and private key using the DHM algorithm.
- Return
- MDF_OK
- MDF_ERR_INVALID_ARG
- Parameters
param
: DHM configuration parametersparam_size
: The length of the DHM configuration parameterprivkey
: DHM’s public keypubkey
: DHM’s private key
-
mdf_err_t
mconfig_rsa_gen_key
(char *privkey_pem, char *pubkey_pem)¶ Generate a public and private key using the RSA algorithm.
- Return
- ESP_OK
- ESP_FAIL
- Parameters
privkey_pem
: RSA public key in pem formatpubkey_pem
: RSA private key in pem format
-
mdf_err_t
mconfig_rsa_decrypt
(const uint8_t *ciphertext, const char *privkey_pem, void *plaintext, size_t plaintext_size)¶ Use RSA’s public key to encrypt the data.
- Return
- ESP_OK
- ESP_FAIL
- MDF_ERR_INVALID_ARG
- Parameters
ciphertext
: Encrypted dataprivkey_pem
: RSA’s private key in pem formatplaintext
: Unencrypted dataplaintext_size
: The length of unencrypted data
-
mdf_err_t
mconfig_rsa_encrypt
(const void *plaintext, size_t plaintext_size, const char *pubkey_pem, uint8_t *ciphertext)¶ use RSA’s public key to encrypt the data
- Return
- ESP_OK
- ESP_FAIL
- MDF_ERR_INVALID_ARG__MCONFIG_SECURITY_H__
- Parameters
plaintext
: Unencrypted dataplaintext_size
: The length of unencrypted datapubkey_pem
: RSA’s public key in pem formatciphertext
: Encrypted data
Macros¶
-
MCONFIG_RSA_PRIVKEY_PEM_SIZE
¶
-
MCONFIG_RSA_PUBKEY_PEM_SIZE
¶
-
MCONFIG_RSA_KEY_BITS
¶
-
MCONFIG_RSA_CIPHERTEXT_SIZE
¶
-
MCONFIG_RSA_PLAINTEXT_MAX_SIZE
¶
-
MCONFIG_RSA_EXPONENT
¶
-
MCONFIG_RSA_PUBKEY_PEM_DATA_SIZE
¶
-
PEM_BEGIN_PUBLIC_KEY
¶
-
PEM_END_PUBLIC_KEY
¶
-
PEM_BEGIN_PRIVATE_KEY
¶
-
PEM_END_PRIVATE_KEY
¶
-
MCONFIG_DH_PRIVKEY_LEN
¶
-
MCONFIG_DH_PUBKEY_LEN
¶
-
MCONFIG_AES_KEY_LEN
¶