Compare commits
No commits in common. "features/translate" and "master" have entirely different histories.
features/t
...
master
@ -1,5 +1,4 @@
|
||||
/* NBNS service client
|
||||
Pavel Brychta pablo@xpablo.cz
|
||||
/* Klient sluzby NBNS
|
||||
*/
|
||||
|
||||
#include "ESP8266NetBIOS.h"
|
||||
@ -25,65 +24,65 @@ extern "C" {
|
||||
#define LWIP_PLATFORM_HTONL(_n) ((u32_t)( (((_n) & 0xff) << 24) | (((_n) & 0xff00) << 8) | (((_n) >> 8) & 0xff00) | (((_n) >> 24) & 0xff) ))
|
||||
#endif
|
||||
|
||||
// NBNS query structure (at least things that I've discovered):
|
||||
// Definice struktury NBNS dotazu (alespon veci, ktere jsem vypozoroval):
|
||||
struct NBNSQUESTION {
|
||||
uint16_t NBNSQ_ID; // query ID
|
||||
uint16_t NBNSQ_ID; // ID dotazu
|
||||
uint8_t NBNSQ_FLAGS1;
|
||||
uint8_t NBNSQ_FLAGS2;
|
||||
uint16_t NBNSQ_QUESTIONCOUNT;
|
||||
uint16_t NBNSQ_ANSWERCOUNT;
|
||||
uint16_t NBNSQ_AUTHORITYCOUNT;
|
||||
uint16_t NBNSQ_ADDITIONALRECORDCOUNT;
|
||||
uint8_t NBNSQ_NAMESIZE; // following string length
|
||||
char NBNSQ_NAME[32+1]; // CAUTION!!! maybe this entry is not of constant length
|
||||
uint8_t NBNSQ_NAMESIZE; // delka nasledujiciho retezce
|
||||
char NBNSQ_NAME[32+1]; // POZOR!!! mozna tato polozka muze byt ruzne dlouha
|
||||
uint16_t NBNSQ_TYPE;
|
||||
uint16_t NBNSQ_CLASS;
|
||||
} __attribute__((packed));
|
||||
|
||||
// NBNS response structure (again at least things that I've discovered)
|
||||
// Definice struktury NBNS odpovedi (stejne jako u dotazu)
|
||||
struct NBNSANSWER {
|
||||
uint16_t NBNSA_ID; // query ID
|
||||
uint16_t NBNSA_ID; // ID dotazu
|
||||
uint8_t NBNSA_FLAGS1;
|
||||
uint8_t NBNSA_FLAGS2;
|
||||
uint16_t NBNSA_QUESTIONCOUNT;
|
||||
uint16_t NBNSA_ANSWERCOUNT;
|
||||
uint16_t NBNSA_AUTHORITYCOUNT;
|
||||
uint16_t NBNSA_ADDITIONALRECORDCOUNT;
|
||||
uint8_t NBNSA_NAMESIZE; // length of the following string
|
||||
char NBNSA_NAME[32 + 1]; // CAUTION!!! maybe this entry is not of constant length
|
||||
uint8_t NBNSA_NAMESIZE; // delka nasledujiciho retezce
|
||||
char NBNSA_NAME[32 + 1]; // POZOR!!! mozna tato polozka muze byt ruzne dlouha
|
||||
uint16_t NBNSA_TYPE;
|
||||
uint16_t NBNSA_CLASS;
|
||||
uint32_t NBNSA_TIMETOLIVE;
|
||||
uint16_t NBNSA_LENGTH;
|
||||
uint16_t NBNSA_NODEFLAGS; // CAUTION!!! I'm really not sure about this
|
||||
uint16_t NBNSA_NODEFLAGS; // POZOR!!! tady si nejsem moc jisty
|
||||
uint32_t NBNSA_NODEADDRESS;
|
||||
} __attribute__((packed));
|
||||
|
||||
// structure of NBNS response to name query
|
||||
// Definice struktury NBNS odpovedi na dotaz na jmeno
|
||||
struct NBNSANSWERN {
|
||||
uint16_t NBNSAN_ID; // query ID
|
||||
uint16_t NBNSAN_ID; // ID dotazu
|
||||
uint8_t NBNSAN_FLAGS1;
|
||||
uint8_t NBNSAN_FLAGS2;
|
||||
uint16_t NBNSAN_QUESTIONCOUNT;
|
||||
uint16_t NBNSAN_ANSWERCOUNT;
|
||||
uint16_t NBNSAN_AUTHORITYCOUNT;
|
||||
uint16_t NBNSAN_ADDITIONALRECORDCOUNT;
|
||||
uint8_t NBNSAN_NAMESIZE; // length of the following string
|
||||
char NBNSAN_NAME[32 + 1]; // CAUTION!!! maybe this entry is not of constant length
|
||||
uint8_t NBNSAN_NAMESIZE; // delka nasledujiciho retezce
|
||||
char NBNSAN_NAME[32 + 1]; // POZOR!!! mozna tato polozka muze byt ruzne dlouha
|
||||
uint16_t NBNSAN_TYPE;
|
||||
uint16_t NBNSAN_CLASS;
|
||||
uint32_t NBNSAN_TIMETOLIVE;
|
||||
uint16_t NBNSAN_LENGTH;
|
||||
uint8_t NBNSAN_NUMBER; // number of names
|
||||
char NBNSAN_NNAME[15]; // node name
|
||||
uint8_t NBNSAN_NTYPE; // type of name
|
||||
char NBNSAN_NNAME[15]; // jmeno nodu
|
||||
uint8_t NBNSAN_NTYPE; // typ jmena
|
||||
uint16_t NBNSAN_NFLAGS; // node flags
|
||||
} __attribute__((packed));
|
||||
|
||||
/** Method to get NETBIOS name encoding.
|
||||
* \param nbname Pointer to NETBIOS encoded name.
|
||||
* \param name Pointer where to decode the name.
|
||||
* \param maxlen Maximum of characters allowed in the nbname.
|
||||
/** Metoda pro ziskani jmena z kodovani NETBIOS.
|
||||
* \param nbname Ukazatel na jmeno v NETBIOS kodovani.
|
||||
* \param name Ukazatel na misto, kam prevadime jmeno.
|
||||
* \param maxlen Maximalni pocet znaku v nbname.
|
||||
*/
|
||||
void ESP8266NetBIOS::_getnbname(char *nbname, char *name, uint8_t maxlen)
|
||||
{
|
||||
@ -91,15 +90,15 @@ void ESP8266NetBIOS::_getnbname(char *nbname, char *name, uint8_t maxlen)
|
||||
uint8_t c = 0;
|
||||
|
||||
while ((*nbname != 0x0) && (c < maxlen)) {
|
||||
b = (*nbname++ - 'A') << 4; // correct the nibble and move it to upper bits
|
||||
c++; // removed byte counter
|
||||
b = (*nbname++ - 'A') << 4; // opravime nibble a prevedeme ho do vyssich bitu
|
||||
c++; // pocitame pocet odebranych bytu
|
||||
if (*nbname != 0x0) {
|
||||
b |= *nbname++ - 'A'; // add lower nibble
|
||||
c++; // again removed byte counter
|
||||
b |= *nbname++ - 'A'; // pridame nizsi nibble
|
||||
c++; // opet spocitame pocet odebranych znaku
|
||||
}
|
||||
*name++ = b; // store decoded character and bump pointer
|
||||
*name++ = b; // ulozime znak do vysledku a posuneme ukazatel
|
||||
}
|
||||
*name = 0x0; // store trailing zero (made C character string)
|
||||
*name = 0x0; // ulozime ukoncovaci 0
|
||||
}
|
||||
|
||||
/** Prevod zadaneho textu do NETBIOS kodovani
|
||||
|
@ -6,11 +6,14 @@ const char* ssid = "............";
|
||||
const char* password = "..............";
|
||||
|
||||
ESP8266WebServer wwwserver(80);
|
||||
const char PAGE[] PROGMEM = "<!DOCTYPE HTML>\n<html>Hello world from ESP8266<p></html>"
|
||||
String content;
|
||||
|
||||
static void handleRoot(void) {
|
||||
content = F("<!DOCTYPE HTML>\n<html>Hello world from ESP8266");
|
||||
content += F("<p>");
|
||||
content += F("</html>");
|
||||
|
||||
wwwserver.send_P(200, F("text/html"), PAGE);
|
||||
wwwserver.send(200, F("text/html"), content);
|
||||
}
|
||||
|
||||
void setup() {
|
||||
|
Loading…
Reference in New Issue
Block a user