protocomm : version endpoint behavior simplified

List of changes:
* Version endpoint now sends the set version string instead of verifying the incoming version string. This simplifies fetching version info from the provisioning application.
* esp_prov script updated to expect version string as response.
This commit is contained in:
Anurag Kar 2019-02-08 12:06:23 +05:30 committed by bot
parent 59b10709d1
commit a1d37c833c
2 changed files with 9 additions and 27 deletions

View file

@ -305,40 +305,22 @@ static int protocomm_version_handler(uint32_t session_id,
uint8_t **outbuf, ssize_t *outlen,
void *priv_data)
{
const char *resp_match = "SUCCESS";
const char *resp_fail = "FAIL";
bool match = false;
char *version = strndup((const char *)inbuf, inlen);
protocomm_t *pc = (protocomm_t *) priv_data;
*outbuf = NULL;
*outlen = 0;
if ((pc->ver != NULL) && (version != NULL)) {
ESP_LOGV(TAG, "Protocol version of device : %s", pc->ver);
ESP_LOGV(TAG, "Protocol version of client : %s", version);
if (strcmp(pc->ver, version) == 0) {
match = true;
}
} else if ((pc->ver == NULL) && (version == NULL)) {
match = true;
if (!pc->ver) {
*outlen = 0;
*outbuf = NULL;
return ESP_OK;
}
free(version);
if (!match) {
ESP_LOGE(TAG, "Protocol version mismatch");
}
const char *result_msg = match ? resp_match : resp_fail;
/* Output is a non null terminated string with length specified */
*outlen = strlen(result_msg);
*outbuf = malloc(strlen(result_msg));
*outlen = strlen(pc->ver);
*outbuf = malloc(*outlen);
if (outbuf == NULL) {
ESP_LOGE(TAG, "Failed to allocate memory for version check response");
ESP_LOGE(TAG, "Failed to allocate memory for version response");
return ESP_ERR_NO_MEM;
}
memcpy(*outbuf, result_msg, *outlen);
memcpy(*outbuf, pc->ver, *outlen);
return ESP_OK;
}

View file

@ -77,7 +77,7 @@ def get_transport(sel_transport, softap_endpoint=None, ble_devname=None):
def version_match(tp, protover):
try:
response = tp.send_data('proto-ver', protover)
if response != "SUCCESS":
if response != protover:
return False
return True
except RuntimeError as e: