Open pedrorovi opened 5 days ago
I added this custom commands while the issue is not fixed.
uint8_t get_mac_spi_eth() {
uint8_t mac_addr[6] = {0};
esp_netif_t *eth_netif = get_spi_eth_netif(0);
ESP_ERROR_CHECK(esp_netif_get_mac(eth_netif, mac_addr));
char text[64] = {0};
snprintf(text, sizeof(text), "+MAC:%02X:%02X:%02X:%02X:%02X:%02X\r\n",
mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4],
mac_addr[5]);
esp_at_port_write_data((uint8_t *)text, sizeof(text));
return ESP_AT_RESULT_CODE_OK;
}
uint8_t set_mac_spi_eth(const uint8_t *mac) {
ESP_LOGI(TAG, "Setting SPI MAC %s", mac);
uint8_t res = ESP_AT_RESULT_CODE_OK;
uint8_t mac_bytes[6] = {0, 0, 0, 0, 0, 0};
int success_parsed_vbles =
sscanf((const char *)mac, "%02X:%02X:%02X:%02X:%02X:%02X", &mac_bytes[0],
&mac_bytes[1], &mac_bytes[2], &mac_bytes[3], &mac_bytes[4],
&mac_bytes[5]);
ESP_LOGI(TAG, "Parsed %d variables: %02X:%02X:%02X:%02X:%02X:%02X",
success_parsed_vbles, mac_bytes[0], mac_bytes[1], mac_bytes[2],
mac_bytes[3], mac_bytes[4], mac_bytes[5]);
if (success_parsed_vbles != 6) {
ESP_LOGE(TAG, "Error scanning MAC");
res = ESP_AT_RESULT_CODE_FAIL;
return res;
}
esp_netif_t *eth_netif = get_spi_eth_netif(0);
ESP_ERROR_CHECK(esp_netif_set_mac(eth_netif, mac_bytes));
return ESP_AT_RESULT_CODE_OK;
}
uint8_t get_ip_spi_eth() {
uint8_t ip_addr[4] = {0};
esp_netif_ip_info_t ip_info;
esp_netif_t *eth_netif = get_spi_eth_netif(0);
ESP_ERROR_CHECK(esp_netif_get_ip_info(eth_netif, &ip_info));
char *ip = ip4addr_ntoa(&ip_info.ip);
ESP_LOGI(TAG, "IP: %s", ip);
char text[64] = {0};
snprintf(text, sizeof(text), "+IP:%s\r\n", ip);
esp_at_port_write_data((uint8_t *)text, sizeof(text));
return ESP_AT_RESULT_CODE_OK;
}
uint8_t set_ip_spi_eth(const uint8_t *ip) {
uint8_t res = ESP_AT_RESULT_CODE_OK;
uint8_t ip_bytes[4] = {0, 0, 0, 0};
ip4_addr_t toCheck;
int success_parsed_vbles =
sscanf((const char *)ip, "%u.%u.%u.%u", &ip_bytes[0], &ip_bytes[1],
&ip_bytes[2], &ip_bytes[3]);
ESP_LOGI(TAG, "Parsed %d variables: %u.%u.%u.%u", success_parsed_vbles,
ip_bytes[0], ip_bytes[1], ip_bytes[2], ip_bytes[3]);
if (success_parsed_vbles != 4) {
ESP_LOGE(TAG, "Error scanning IP");
res = ESP_AT_RESULT_CODE_FAIL;
return res;
}
esp_netif_t *eth_netif = get_spi_eth_netif(0);
esp_netif_ip_info_t ip_info;
ESP_ERROR_CHECK(esp_netif_dhcpc_stop(eth_netif)); // Stop DHCP client
// Set static IP
IP4_ADDR(&ip_info.ip, ip_bytes[0], ip_bytes[1], ip_bytes[2], ip_bytes[3]);
IP4_ADDR(&ip_info.gw, ip_bytes[0], ip_bytes[1], ip_bytes[2], 1);
IP4_ADDR(&ip_info.netmask, 255, 255, 255, 0);
ESP_ERROR_CHECK(esp_netif_set_ip_info(eth_netif, &ip_info));
return ESP_AT_RESULT_CODE_OK;
}
Answers checklist.
General issue report
Hey, I have a problem. The AT firmware can't store cmd commands with SPI defined to use Ethernet. I have implemented the example and I get these logs:
The driver install is working at components/at/src/at_eth_init.c but I think this function _esp_at_eth_cmdregist try to do something similar, but it is using the old physical layers models instead the SPI configured.
I tried already with some releases (3.2, 3.4 and 4.0) and master. In any of them works.
Can you give me some help?