-
Notifications
You must be signed in to change notification settings - Fork 234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change the value of hostname #470
Comments
Hello. I'm not sure what you are referring to by "hostname". Would you be more precise? FWIW - The Moddable SDK does not assign a hostname to the device. How are you observing that a the hostname is "espressif"? |
hi, thank you for your reply :-) When i connect my esp32 device that run my moddable app to my dsl box, i see in the devices list connected the device name associated with ip address (DNS) for my eps32 device the name is "espressif". I searched for the word "espressif" in the ~ / esp32 / esp-idf folder and found in some C files: netif-> hostname = "espressif"; But I did not find how to change the value of "hostname ". Do you know if it's possible to change this value? Thanks :-) |
Thank you for the details. I never tried to set that hostname on the Espressif devices. I did some investigation and found it can be done using I've made a small change to the Moddable SDK Wi-Fi code to support setting the hostname in the project manifest's defines section. Here's a trivial example;
We'll push the change to this repository a little later today. On a somewhat related note, the Moddable SDK implements mDNS so you can claim a hostname that way (and automatically resolve name conflicts). Here's a basic example: moddable/examples/network/mdns/httpserver/main.js Lines 31 to 36 in e1fe8b4
|
Thank you very much. I test as soon as possible and I inform you of the result. |
Some weeks ago, i've tried this code (below) immediately after the wifi connection was ready. It seems working fine but my esp32 device had no hostname on my network. _claimHostname() {
if( this._hostname.length>0 ) {
const mdns = new MDNS({hostName: this._hostname}, (message, value) => {
switch( message ) {
case 1:
if( this.debug ) {
trace(`${Date()}: MDNS - claimed hostname is "${value}"\n`);
}
break;
case 2:
if( this.debug ) {
trace(`${Date()}: MDNS - failed to claim "${value}", try next\n`);
}
break;
default:
if( message<0 ) {
if( this.debug ) {
trace("${Date()}: MDNS - failed to claim, give up\n");
}
}
break;
}
});
}
} I've copied this piece of code from moddable documentation: network / class MDNS. ... and congratulations: this is the second personal project I have done with Moddable SDK and it works really well! |
Glad to hear you are having good success with the Moddable SDK. If you decide to make any of your personal projects available, please let me know. It is always interesting to see how people are using the SDK. Regarding mDNS, I adapted your code slightly and added it at the end of $MODDABLE/examples/network/http/httpget/main.js: import MDNS from "mdns"
const _hostname = "test";
const debug = true;
const mdns = new MDNS({hostName: _hostname}, (message, value) => {
switch( message ) {
case 1:
if( debug ) {
trace(`${Date()}: MDNS - claimed hostname is "${value}"\n`);
}
break;
case 2:
if( debug ) {
trace(`${Date()}: MDNS - failed to claim "${value}", try next\n`);
}
break;
default:
if( message<0 ) {
if( debug ) {
trace("${Date()}: MDNS - failed to claim, give up\n");
}
}
break;
}
}); That worked as expected for me. The hostname with mDNS is always in the ".local" domain, so I did this to check it:
Not all computers resolve ".local" addresses -- macOS definitely does. For Windows, I believe it requires additional configuration. |
It was my mistake, I did not add |
All works fine (macOS) ! |
Hi, how to change the value of hostname for ESP32 & 8266 ? The default value is espressif. Is there an API for that ?
Thanks
The text was updated successfully, but these errors were encountered: