Skip to content

Commit 600f4c4

Browse files
authored
Update IDF to 1c3dd23
* Update mDNS and LEDC * update toolchain * Update IDF to 1c3dd23 * Advertise the board variant for Arduino OTA * Add generic variant definition for mDNS
1 parent 70d0d46 commit 600f4c4

File tree

150 files changed

+7079
-3732
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+7079
-3732
lines changed

‎cores/esp32/esp32-hal-bt.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BLUEDROID_ENABLED)
1818

1919

20-
#include"bt.h"
20+
#include"esp_bt.h"
2121
#include"esp_bt_defs.h"
2222
#include"esp_bt_main.h"
2323

‎cores/esp32/esp32-hal-ledc.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ static void _ledcSetupTimer(uint8_t chan, uint32_t div_num, uint8_t bit_num, boo
6868
#endif
6969
}
7070
LEDC_MUTEX_LOCK();
71-
LEDC_TIMER(group, timer).conf.div_num=div_num;//18 bit (10.8) This register is used to configure parameter for divider in timer the least significant eight bits represent the decimal part.
72-
LEDC_TIMER(group, timer).conf.bit_num=bit_num;//5 bit This register controls the range of the counter in timer. the counter range is [0 2**bit_num] the max bit width for counter is 20.
71+
LEDC_TIMER(group, timer).conf.clock_divider=div_num;//18 bit (10.8) This register is used to configure parameter for divider in timer the least significant eight bits represent the decimal part.
72+
LEDC_TIMER(group, timer).conf.duty_resolution=bit_num;//5 bit This register controls the range of the counter in timer. the counter range is [0 2**bit_num] the max bit width for counter is 20.
7373
LEDC_TIMER(group, timer).conf.tick_sel=apb_clk;//apb clock
7474
if(group){
7575
LEDC_TIMER(group, timer).conf.low_speed_update=1;//This bit is only useful for low speed timer channels, reserved for high speed timers
@@ -111,8 +111,8 @@ static double _ledcTimerRead(uint8_t chan)
111111
boolapb_clk;
112112
uint8_tgroup=(chan/8), timer=((chan/2)%4);
113113
LEDC_MUTEX_LOCK();
114-
div_num=LEDC_TIMER(group, timer).conf.div_num;//18 bit (10.8) This register is used to configure parameter for divider in timer the least significant eight bits represent the decimal part.
115-
bit_num=LEDC_TIMER(group, timer).conf.bit_num;//5 bit This register controls the range of the counter in timer. the counter range is [0 2**bit_num] the max bit width for counter is 20.
114+
div_num=LEDC_TIMER(group, timer).conf.clock_divider;//18 bit (10.8) This register is used to configure parameter for divider in timer the least significant eight bits represent the decimal part.
115+
bit_num=LEDC_TIMER(group, timer).conf.duty_resolution;//5 bit This register controls the range of the counter in timer. the counter range is [0 2**bit_num] the max bit width for counter is 20.
116116
apb_clk=LEDC_TIMER(group, timer).conf.tick_sel;//apb clock
117117
LEDC_MUTEX_UNLOCK();
118118
uint64_tclk_freq=1000000;

‎libraries/ESPmDNS/src/ESPmDNS.cpp‎

Lines changed: 118 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -39,144 +39,210 @@ License (MIT license):
3939
#endif
4040

4141
#include"ESPmDNS.h"
42+
#include"WiFi.h"
4243
#include<functional>
4344
#include"esp_wifi.h"
4445

45-
MDNSResponder::MDNSResponder() : mdns(NULL), _if(TCPIP_ADAPTER_IF_STA){}
46+
staticvoid_on_sys_event(system_event_t *event){
47+
mdns_handle_system_event(NULL, event);
48+
}
49+
50+
MDNSResponder::MDNSResponder() :results(NULL){}
4651
MDNSResponder::~MDNSResponder(){
4752
end();
4853
}
4954

50-
boolMDNSResponder::begin(constchar* hostName, tcpip_adapter_if_t tcpip_if, uint32_t ttl){
51-
_if = tcpip_if;
52-
if(!mdns && mdns_init(_if, &mdns)){
55+
boolMDNSResponder::begin(constchar* hostName){
56+
if(mdns_init()){
5357
log_e("Failed starting MDNS");
5458
returnfalse;
5559
}
60+
WiFi.onEvent(_on_sys_event);
5661
_hostname = hostName;
57-
if(mdns_set_hostname(mdns, hostName)){
62+
if(mdns_hostname_set(hostName)){
5863
log_e("Failed setting MDNS hostname");
5964
returnfalse;
6065
}
6166
returntrue;
6267
}
6368

6469
voidMDNSResponder::end(){
65-
if(!mdns){
66-
return;
67-
}
68-
mdns_free(mdns);
69-
mdns = NULL;
70+
mdns_free();
7071
}
7172

7273
voidMDNSResponder::setInstanceName(String name){
7374
if (name.length() > 63) return;
74-
if(mdns_set_instance(mdns, name.c_str())){
75+
if(mdns_instance_name_set(name.c_str())){
7576
log_e("Failed setting MDNS instance");
7677
return;
7778
}
7879
}
7980

81+
8082
voidMDNSResponder::enableArduino(uint16_t port, bool auth){
81-
constchar * arduTxtData[4] ={
82-
"board=" ARDUINO_BOARD,
83-
"tcp_check=no",
84-
"ssh_upload=no",
85-
"auth_upload=no"
83+
mdns_txt_item_t arduTxtData[4] ={
84+
{(char*)"board" ,(char*)ARDUINO_VARIANT},
85+
{(char*)"tcp_check" ,(char*)"no"},
86+
{(char*)"ssh_upload",(char*)"no"},
87+
{(char*)"auth_upload",(char*)"no"}
8688
};
87-
if(auth){
88-
arduTxtData[3] = "auth_upload=yes";
89-
}
9089

91-
if(mdns_service_add(mdns, "_arduino", "_tcp", port)){
90+
if(mdns_service_add(NULL, "_arduino", "_tcp", port, arduTxtData, 4)){
9291
log_e("Failed adding Arduino service");
93-
} elseif(mdns_service_txt_set(mdns, "_arduino", "_tcp", 4, arduTxtData)){
94-
log_e("Failed setting Arduino service TXT");
92+
}
93+
94+
if(auth && mdns_service_txt_item_set("_arduino", "_tcp", "auth_upload", "yes")){
95+
log_e("Failed setting Arduino txt item");
9596
}
9697
}
9798

9899
voidMDNSResponder::disableArduino(){
99-
if(mdns_service_remove(mdns, "_arduino", "_tcp")){
100+
if(mdns_service_remove("_arduino", "_tcp")){
100101
log_w("Failed removing Arduino service");
101102
}
102103
}
103104

104-
voidMDNSResponder::enableWorkstation(){
105+
voidMDNSResponder::enableWorkstation(wifi_interface_t interface){
105106
char winstance[21+_hostname.length()];
106107
uint8_t mac[6];
107-
esp_wifi_get_mac((wifi_interface_t)_if, mac);
108+
esp_wifi_get_mac(interface, mac);
108109
sprintf(winstance, "%s [%02x:%02x:%02x:%02x:%02x:%02x]", _hostname.c_str(), mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
109110

110-
if(mdns_service_add(mdns, "_workstation", "_tcp", 9)){
111+
if(mdns_service_add(NULL, "_workstation", "_tcp", 9, NULL, 0)){
111112
log_e("Failed adding Workstation service");
112-
} elseif(mdns_service_instance_set(mdns, "_workstation", "_tcp", winstance)){
113+
} elseif(mdns_service_instance_name_set("_workstation", "_tcp", winstance)){
113114
log_e("Failed setting Workstation service instance name");
114115
}
115116
}
116117

117118
voidMDNSResponder::disableWorkstation(){
118-
if(mdns_service_remove(mdns, "_workstation", "_tcp")){
119+
if(mdns_service_remove("_workstation", "_tcp")){
119120
log_w("Failed removing Workstation service");
120121
}
121122
}
122123

123124
voidMDNSResponder::addService(char *name, char *proto, uint16_t port){
124-
if(mdns_service_add(mdns, name, proto, port)){
125+
if(mdns_service_add(NULL, name, proto, port, NULL, 0)){
125126
log_e("Failed adding service %s.%s.\n", name, proto);
126127
}
127128
}
128129

129130
boolMDNSResponder::addServiceTxt(char *name, char *proto, char *key, char *value){
130-
//ToDo: implement it in IDF. This will set the TXT to one record currently
131-
String txt = String(key) + "=" + String(value);
132-
constchar * txt_chr[1] ={txt.c_str()};
133-
if(mdns_service_txt_set(mdns, name, proto, 1, txt_chr)){
131+
if(mdns_service_txt_item_set(name, proto, key, value)){
134132
log_e("Failed setting service TXT");
135133
returnfalse;
136134
}
137135
returntrue;
138136
}
139137

140-
intMDNSResponder::queryService(char *service, char *proto){
141-
mdns_result_free(mdns);
142-
if(proto){
143-
char srv[strlen(service)+2];
144-
char prt[strlen(proto)+2];
145-
sprintf(srv, "_%s", service);
146-
sprintf(prt, "_%s", proto);
147-
returnmdns_query(mdns, srv, prt, 2000);
138+
IPAddress MDNSResponder::queryHost(char *host, uint32_t timeout){
139+
structip4_addr addr;
140+
addr.addr = 0;
141+
142+
esp_err_t err = mdns_query_a(host, timeout, &addr);
143+
if(err){
144+
if(err == ESP_ERR_NOT_FOUND){
145+
log_w("Host was not found!");
146+
returnIPAddress();
147+
}
148+
log_e("Query Failed");
149+
returnIPAddress();
148150
}
149-
returnmdns_query(mdns, service, NULL, 2000);
151+
returnIPAddress(addr.addr);
150152
}
151153

152-
IPAddress MDNSResponder::queryHost(char *host){
153-
mdns_result_free(mdns);
154-
if(!mdns_query(mdns, host, NULL, 2000)){
155-
returnIPAddress();
154+
155+
intMDNSResponder::queryService(char *service, char *proto){
156+
if(!service || !service[0] || !proto || !proto[0]){
157+
log_e("Bad Parameters");
158+
return0;
159+
}
160+
161+
if(results){
162+
mdns_query_results_free(results);
163+
results = NULL;
156164
}
157-
returnIP(0);
165+
166+
char srv[strlen(service)+2];
167+
char prt[strlen(proto)+2];
168+
sprintf(srv, "_%s", service);
169+
sprintf(prt, "_%s", proto);
170+
171+
esp_err_t err = mdns_query_ptr(srv, prt, 3000, 20, &results);
172+
if(err){
173+
log_e("Query Failed");
174+
return0;
175+
}
176+
if(!results){
177+
log_w("No results found!");
178+
return0;
179+
}
180+
181+
mdns_result_t * r = results;
182+
int i = 0;
183+
while(r){
184+
i++;
185+
r = r->next;
186+
}
187+
return i;
188+
}
189+
190+
mdns_result_t * MDNSResponder::_getResult(int idx){
191+
mdns_result_t * result = results;
192+
int i = 0;
193+
while(result){
194+
if(i == idx){
195+
break;
196+
}
197+
i++;
198+
result = result->next;
199+
}
200+
return result;
158201
}
159202

160203
String MDNSResponder::hostname(int idx){
161-
constmdns_result_t * result = mdns_result_get(mdns, idx);
204+
mdns_result_t * result = _getResult(idx);
162205
if(!result){
163206
log_e("Result %d not found", idx);
164207
returnString();
165208
}
166-
returnString(result->host);
209+
returnString(result->hostname);
167210
}
168211

169212
IPAddress MDNSResponder::IP(int idx){
170-
constmdns_result_t * result = mdns_result_get(mdns, idx);
213+
mdns_result_t * result = _getResult(idx);
171214
if(!result){
172215
log_e("Result %d not found", idx);
173216
returnIPAddress();
174217
}
175-
returnIPAddress(result->addr.addr);
218+
mdns_ip_addr_t * addr = result->addr;
219+
while(addr){
220+
if(addr->addr.type == MDNS_IP_PROTOCOL_V4){
221+
returnIPAddress(addr->addr.u_addr.ip4.addr);
222+
}
223+
addr = addr->next;
224+
}
225+
returnIPAddress();
226+
}
227+
228+
IPv6Address MDNSResponder::IPv6(int idx){
229+
mdns_result_t * result = _getResult(idx);
230+
if(!result){
231+
log_e("Result %d not found", idx);
232+
returnIPv6Address();
233+
}
234+
mdns_ip_addr_t * addr = result->addr;
235+
while(addr){
236+
if(addr->addr.type == MDNS_IP_PROTOCOL_V6){
237+
returnIPv6Address(addr->addr.u_addr.ip6.addr);
238+
}
239+
addr = addr->next;
240+
}
241+
returnIPv6Address();
176242
}
177243

178244
uint16_tMDNSResponder::port(int idx){
179-
constmdns_result_t * result = mdns_result_get(mdns, idx);
245+
mdns_result_t * result = _getResult(idx);
180246
if(!result){
181247
log_e("Result %d not found", idx);
182248
return0;

‎libraries/ESPmDNS/src/ESPmDNS.h‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,19 @@ License (MIT license):
4242
#defineESP32MDNS_H
4343

4444
#include"Arduino.h"
45+
#include"IPv6Address.h"
4546
#include"mdns.h"
4647

4748
//this should be defined at build time
48-
#ifndefARDUINO_BOARD
49-
#defineARDUINO_BOARD"esp32"
49+
#ifndefARDUINO_VARIANT
50+
#defineARDUINO_VARIANT"esp32"
5051
#endif
5152

5253
classMDNSResponder{
5354
public:
5455
MDNSResponder();
5556
~MDNSResponder();
56-
boolbegin(constchar* hostName, tcpip_adapter_if_t tcpip_if=TCPIP_ADAPTER_IF_STA, uint32_t ttl=120);
57+
boolbegin(constchar* hostName);
5758
voidend();
5859

5960
voidsetInstanceName(String name);
@@ -83,15 +84,15 @@ class MDNSResponder{
8384
voidenableArduino(uint16_t port=3232, bool auth=false);
8485
voiddisableArduino();
8586

86-
voidenableWorkstation();
87+
voidenableWorkstation(wifi_interface_t interface=ESP_IF_WIFI_STA);
8788
voiddisableWorkstation();
8889

89-
IPAddress queryHost(char *host);
90-
IPAddress queryHost(constchar *host){
91-
returnqueryHost((char *)host);
90+
IPAddress queryHost(char *host, uint32_t timeout=2000);
91+
IPAddress queryHost(constchar *host, uint32_t timeout=2000){
92+
returnqueryHost((char *)host, timeout);
9293
}
93-
IPAddress queryHost(String host){
94-
returnqueryHost(host.c_str());
94+
IPAddress queryHost(String host, uint32_t timeout=2000){
95+
returnqueryHost(host.c_str(), timeout);
9596
}
9697

9798
intqueryService(char *service, char *proto);
@@ -104,12 +105,13 @@ class MDNSResponder{
104105

105106
String hostname(int idx);
106107
IPAddress IP(int idx);
108+
IPv6Address IPv6(int idx);
107109
uint16_tport(int idx);
108110

109111
private:
110-
mdns_server_t * mdns;
111-
tcpip_adapter_if_t _if;
112112
String _hostname;
113+
mdns_result_t * results;
114+
mdns_result_t * _getResult(int idx);
113115
};
114116

115117
extern MDNSResponder MDNS;

‎libraries/WiFi/src/ETH.cpp‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ extern void tcpipInit();
3030
staticint _eth_phy_mdc_pin = -1;
3131
staticint _eth_phy_mdio_pin = -1;
3232
staticint _eth_phy_power_pin = -1;
33-
staticeth_clock_mode_t _eth_clk_mode = ETH_CLOCK_GPIO0_IN;
3433
static eth_phy_power_enable_func _eth_phy_power_enable_orig = NULL;
3534

3635
staticvoid_eth_phy_config_gpio(void)

0 commit comments

Comments
(0)