Fastcon network configuration commands

1 FastCon SmartConfig Commands from APP

FastCon supports dual configuration methods: SmartConfig or ZeroConfig.
This section defines the interaction of commands between the App and master in SmartConfig mode.
The commands sent from the App go through UART interface 106 with standard DNA UART head.
Here you need to define the value of UART CMD.

typedef enum{
    CONFIG_CONFIRM      = 0x0800, //Confirm configuration
    CONFIG_CONFIRM_RSP  = 0x0801,
    CONFIG_QUERY        = 0x0802, //Query configuration state
    CONFIG_QUERY_RSP    = 0x0803,
    CONFIG_STOP         = 0x0804, //Finish configuration
    CONFIG_STOP_RSP     = 0x0805,
}uart_cmd_e;

The App sends the commands to master using the following APPSDK interfaces:

	/**
     * Control device with data string composed by yourself.
     *
     * @param did Control wifi device did
     * @param sDid Control sub device did. If sdid = nil, just control wifi device.
     * @param dataStr Control data string composed by yourself
     * @param cmd Control command composed by yourself
     * @param configParam Config param
     * @return Control result
     */
    public static String dnaControl(String did, String sDid, String dataStr, String cmd, BLConfigParam configParam);
	/**
	 Control device with data string composed by yourself.

	 @param did             Control wifi device did
	 @param sDid            Control sub device did. If sdid = nil, just control wifi device.
	 @param dataStr         Control data string composed by yourself
	 @param command         Control command composed by yourself
	 @param scriptPath      Control device script. If scriptPath = nil, find device script in default store path.
	 @return                Control result
	 */
	- (NSString *_Nonnull)dnaControl:(NSString *_Nonnull)did
	                       subDevDid:(NSString *_Nullable)sDid
	                         dataStr:(NSString *_Nonnull)dataStr
	                         command:(NSString *_Nonnull)command
	                      scriptPath:(NSString *_Nullable)scriptPath;

1.1 Confirming configuration

App sends commands:

cmd : “fastcon_device_add”

dataStr :

{
    "config":1,         //1:Configure device; 2: Add 
    "timeout":100,      //Timeout of configuration. Unit: sec.
    "did":"00000000000000000000112233445566"    //Total 32-byte string with last 12 bytes for MAC address and filled with 0 in front.
}

Returned from master

{
    "state":1
    "fastcon_enable":1      //0:FastCon is disabled; 1: FastCon is enabled.
}
state
-1 Cannot confirm configuration command because the master is being configured or FastCon is not supported.
0 The master is free.
1 The master confirms configuration or adding clients
2 Master two-way authentication
3 The master gets token
4 The master is waiting for pairing
5 The configuration / adding clients is successful

1.2 Querying configuration state

App sends commands:

cmd : “fastcon_device_add_status_query”

dataStr :

{
    "did":"00000000000000000000112233445566"    //Total 32-byte string with last 12 bytes for MAC address and filled with 0 in front.
}

Returned from master

{
    "state":1,
    "fastcon_enable":1,
    ["token":"xxxxxxxx"]
}

NOTE: The token is only available if the state value is larger than 3.

1.3 Completing configuration

App sends commands:

cmd : “fastcon_cancel”

dataStr :

{
    "did":"00000000000000000000112233445566"    //Total 32-byte string with last 12 bytes for MAC address and filled with 0 in front.
}

master返回

{
    "state":0
    "fastcon_enable":1      //0:FastCon is disabled; 1: FastCon is enabled.
}

2 FastCon ZeroConfig Commands from App

This section defines the interaction of commands between the App and master in ZeroConfig mode.

The App sends the commands to master using the following APPSDK interfaces:

	/**
     * Control device with data string composed by yourself.
     *
     * @param did Control wifi device did
     * @param sDid Control sub device did. If sdid = nil, just control wifi device.
     * @param dataStr Control data string composed by yourself
     * @param cmd Control command composed by yourself
     * @param configParam Config param
     * @return Control result
     */
    public static String dnaControl(String did, String sDid, String dataStr, String cmd, BLConfigParam configParam);
	/**
	 Control device with data string composed by yourself.

	 @param did             Control wifi device did
	 @param sDid            Control sub device did. If sdid = nil, just control wifi device.
	 @param dataStr         Control data string composed by yourself
	 @param command         Control command composed by yourself
	 @param scriptPath      Control device script. If scriptPath = nil, find device script in default store path.
	 @return                Control result
	 */
	- (NSString *_Nonnull)dnaControl:(NSString *_Nonnull)did
	                       subDevDid:(NSString *_Nullable)sDid
	                         dataStr:(NSString *_Nonnull)dataStr
	                         command:(NSString *_Nonnull)command
	                      scriptPath:(NSString *_Nullable)scriptPath;

2.1 Parameter description

command : “fastcon_no_config”

dataStr is JSON String and the parameter “act” stands for steps during ZeroConfig:

act
0 Get device list to be configured
1 Configure device in batch
2 Get configuration state

2.2 Get device list to be configured

Get device list to be configured Request:

{
	"did":"xx",					//Common module did
	"act" : 0, 
	"count": xx, 				//Query count
	"index": xx, 				//Query start index
}

Response:

{
	"did":"xx",					//Common module did
	"status": 0, 					//Failed if the value is not 0
	"total": xx,  					//Total number of devices
	"index": xx, 					//Query start index
	"devlist" : [
		{"pid": "xx", "did":"xx"},
		{"pid": "xx", "did":"xx"},
	    {"pid": "xx", "did":"xx"},
	]
}

2.3 Batch configuration

Request:

{
	"did":"xx",					//Common module did
	"act" : 1, 
	"devlist" : [
		"did0","did1","did2"		//Device DID list to be configured
		]
}

Response:

{
	"did":"xx",					//Common module did
	"status": 0, 					//Failed if the value is not 0
}

**FastCon supports configuration of max 8 devices at the same time. **

2.4 Getting configuration state

Request:

{
	"did":"xx",					//Common module did
	"act" : 2, 
	"devlist" : [
		"did0","did1","did2"		//Device DID list to be configured
		]
}

Response:

{
	"did":"xx",					//Common module did
	"status": 0, 					//Failed if the value is not 0

	"devlist":[
		{"did":"xx", "status":xx},
		{"did":"xx", "status":xx},
	    {"did":"xx", "status":xx},
	]
}

Definition of configuration states:

status
0 Waiting for configuration
1 Configuring
2 Successful
3 Configuration is timeout
4 Device is offline (device does not exist)