Translated partially
This commit is contained in:
parent
d6fc3ab6fb
commit
e3d68e1b25
@ -1,4 +1,5 @@
|
||||
/* Klient sluzby NBNS
|
||||
/* NBNS service client
|
||||
Pavel Brychta pablo@xpablo.cz
|
||||
*/
|
||||
|
||||
#include "ESP8266NetBIOS.h"
|
||||
@ -24,65 +25,65 @@ extern "C" {
|
||||
#define LWIP_PLATFORM_HTONL(_n) ((u32_t)( (((_n) & 0xff) << 24) | (((_n) & 0xff00) << 8) | (((_n) >> 8) & 0xff00) | (((_n) >> 24) & 0xff) ))
|
||||
#endif
|
||||
|
||||
// Definice struktury NBNS dotazu (alespon veci, ktere jsem vypozoroval):
|
||||
// NBNS query structure (at least things that I've discovered):
|
||||
struct NBNSQUESTION {
|
||||
uint16_t NBNSQ_ID; // ID dotazu
|
||||
uint16_t NBNSQ_ID; // query ID
|
||||
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; // delka nasledujiciho retezce
|
||||
char NBNSQ_NAME[32+1]; // POZOR!!! mozna tato polozka muze byt ruzne dlouha
|
||||
uint8_t NBNSQ_NAMESIZE; // following string length
|
||||
char NBNSQ_NAME[32+1]; // CAUTION!!! maybe this entry is not of constant length
|
||||
uint16_t NBNSQ_TYPE;
|
||||
uint16_t NBNSQ_CLASS;
|
||||
} __attribute__((packed));
|
||||
|
||||
// Definice struktury NBNS odpovedi (stejne jako u dotazu)
|
||||
// NBNS response structure (again at least things that I've discovered)
|
||||
struct NBNSANSWER {
|
||||
uint16_t NBNSA_ID; // ID dotazu
|
||||
uint16_t NBNSA_ID; // query ID
|
||||
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; // delka nasledujiciho retezce
|
||||
char NBNSA_NAME[32 + 1]; // POZOR!!! mozna tato polozka muze byt ruzne dlouha
|
||||
uint8_t NBNSA_NAMESIZE; // length of the following string
|
||||
char NBNSA_NAME[32 + 1]; // CAUTION!!! maybe this entry is not of constant length
|
||||
uint16_t NBNSA_TYPE;
|
||||
uint16_t NBNSA_CLASS;
|
||||
uint32_t NBNSA_TIMETOLIVE;
|
||||
uint16_t NBNSA_LENGTH;
|
||||
uint16_t NBNSA_NODEFLAGS; // POZOR!!! tady si nejsem moc jisty
|
||||
uint16_t NBNSA_NODEFLAGS; // CAUTION!!! I'm really not sure about this
|
||||
uint32_t NBNSA_NODEADDRESS;
|
||||
} __attribute__((packed));
|
||||
|
||||
// Definice struktury NBNS odpovedi na dotaz na jmeno
|
||||
// structure of NBNS response to name query
|
||||
struct NBNSANSWERN {
|
||||
uint16_t NBNSAN_ID; // ID dotazu
|
||||
uint16_t NBNSAN_ID; // query ID
|
||||
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; // delka nasledujiciho retezce
|
||||
char NBNSAN_NAME[32 + 1]; // POZOR!!! mozna tato polozka muze byt ruzne dlouha
|
||||
uint8_t NBNSAN_NAMESIZE; // length of the following string
|
||||
char NBNSAN_NAME[32 + 1]; // CAUTION!!! maybe this entry is not of constant length
|
||||
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]; // jmeno nodu
|
||||
uint8_t NBNSAN_NTYPE; // typ jmena
|
||||
char NBNSAN_NNAME[15]; // node name
|
||||
uint8_t NBNSAN_NTYPE; // type of name
|
||||
uint16_t NBNSAN_NFLAGS; // node flags
|
||||
} __attribute__((packed));
|
||||
|
||||
/** 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.
|
||||
/** 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.
|
||||
*/
|
||||
void ESP8266NetBIOS::_getnbname(char *nbname, char *name, uint8_t maxlen)
|
||||
{
|
||||
@ -90,15 +91,15 @@ void ESP8266NetBIOS::_getnbname(char *nbname, char *name, uint8_t maxlen)
|
||||
uint8_t c = 0;
|
||||
|
||||
while ((*nbname != 0x0) && (c < maxlen)) {
|
||||
b = (*nbname++ - 'A') << 4; // opravime nibble a prevedeme ho do vyssich bitu
|
||||
c++; // pocitame pocet odebranych bytu
|
||||
b = (*nbname++ - 'A') << 4; // correct the nibble and move it to upper bits
|
||||
c++; // removed byte counter
|
||||
if (*nbname != 0x0) {
|
||||
b |= *nbname++ - 'A'; // pridame nizsi nibble
|
||||
c++; // opet spocitame pocet odebranych znaku
|
||||
b |= *nbname++ - 'A'; // add lower nibble
|
||||
c++; // again removed byte counter
|
||||
}
|
||||
*name++ = b; // ulozime znak do vysledku a posuneme ukazatel
|
||||
*name++ = b; // store decoded character and bump pointer
|
||||
}
|
||||
*name = 0x0; // ulozime ukoncovaci 0
|
||||
*name = 0x0; // store trailing zero (made C character string)
|
||||
}
|
||||
|
||||
/** Prevod zadaneho textu do NETBIOS kodovani
|
||||
|
@ -6,14 +6,11 @@ const char* ssid = "............";
|
||||
const char* password = "..............";
|
||||
|
||||
ESP8266WebServer wwwserver(80);
|
||||
String content;
|
||||
const char PAGE[] PROGMEM = "<!DOCTYPE HTML>\n<html>Hello world from ESP8266<p></html>"
|
||||
|
||||
static void handleRoot(void) {
|
||||
content = F("<!DOCTYPE HTML>\n<html>Hello world from ESP8266");
|
||||
content += F("<p>");
|
||||
content += F("</html>");
|
||||
|
||||
wwwserver.send(200, F("text/html"), content);
|
||||
wwwserver.send_P(200, F("text/html"), PAGE);
|
||||
}
|
||||
|
||||
void setup() {
|
||||
|
Loading…
Reference in New Issue
Block a user