├── library.properties ├── .gitignore ├── src ├── NTRIPClient.h └── NTRIPClient.cpp ├── keywords.txt ├── README.md ├── examples └── NTRIPClientSample │ └── NTRIPClientSample.ino └── LICENSE /library.properties: -------------------------------------------------------------------------------- 1 | name=NTRIPClient 2 | version=0.2.0 3 | author=GLAY-AK2 4 | maintainer=GLAY-AK2 5 | sentence=Library for ESP32 with high precision reciever 6 | paragraph= 7 | category=Communication 8 | url=https://github.com/GLAY-AK2/NTRIP-client-for-Arduino.git 9 | architectures=esp8266,esp32 10 | includes=NTRIPClient.h 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | -------------------------------------------------------------------------------- /src/NTRIPClient.h: -------------------------------------------------------------------------------- 1 | #ifndef NTRIP_CLIENT 2 | #define NTRIP_CLIENT 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class NTRIPClient : public WiFiClient{ 9 | public : 10 | bool reqSrcTbl(char* host,int &port); //request MountPoints List serviced the NTRIP Caster 11 | bool reqRaw(char* host,int &port,char* mntpnt,char* user,char* psw); //request RAW data from Caster 12 | bool reqRaw(char* host,int &port,char* mntpnt); //non user 13 | int readLine(char* buffer,int size); 14 | 15 | 16 | }; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For NTRIPClient 3 | ####################################### 4 | 5 | ####################################### 6 | # Library (KEYWORD3) 7 | ####################################### 8 | 9 | NTRIPClient KEYWORD3 10 | 11 | ####################################### 12 | # Datatypes (KEYWORD1) 13 | ####################################### 14 | 15 | ntrip_c KEYWORD1 16 | 17 | ####################################### 18 | # Methods and Functions (KEYWORD2) 19 | ####################################### 20 | 21 | reqSrcTbl KEYWORD2 22 | reqRaw KEYWORD2 23 | readLine KEYWORD2 24 | 25 | ####################################### 26 | # Constants (LITERAL1) 27 | ####################################### 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NTRIP-client-for-Arduino 2 | DGPS (Differential GPS) and RTK (GPS positioning with centimeter level accuracy) requires the reference position data. 3 | 4 | NTRIP caster relays GNSS reference position data Stream from BaseStation (GNSS reference position is called that) to GNSS rover via NTRIP protocol. 5 | NTRIP client get GNSS reference data from NTRIP casters for high precision receivers via Internet. 6 | 7 | This suports request Source Table (NTRIP caster has many BaseStation data. Caster informe all of these. Its List is called "Source Table".) and GNSS Reference Data. 8 | 9 | ## How to use 10 | Please check sample source. 11 | 12 | This source has NTRIPClient class based on WiFiClient. 13 | This Developed on ESP32 core for Arduino. 14 | 15 | if you want to use Other function, please check WiFiClient. 16 | 17 | ### Support 18 | Now, this source check with ESP32 & M5Stack. 19 | 20 | if you check with other board, please informe me. 21 | 22 | And, I'm Japanese. Help me for English. 23 | 24 | ## Updates 25 | First Commit : Support for ESP32. 26 | 27 | 2/15 : Compatible with ESP8266. if you can use this, source code needs to include "ESP8266WiFi.h". 28 | Source code needs to include "WiFi.h" for ESP32. 29 | -------------------------------------------------------------------------------- /examples/NTRIPClientSample/NTRIPClientSample.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * NTRIP client for Arduino Ver. 1.0.0 3 | * NTRIPClient Sample 4 | * Request Source Table (Source Table is basestation list in NTRIP Caster) 5 | * Request Reference Data 6 | * 7 | * 8 | */ 9 | //#include //Need for ESP8266 10 | #include //Need for ESP32 11 | #include "NTRIPClient.h" 12 | 13 | const char* ssid = "your_ssid"; 14 | const char* password = "your_password"; 15 | 16 | char* host = "ntrip caster host"; 17 | int httpPort = 2101; //port 2101 is default port of NTRIP caster 18 | char* mntpnt = "ntrip caster's mountpoint"; 19 | char* user = "ntrip caster's client user"; 20 | char* passwd = "ntrip caster's client password"; 21 | NTRIPClient ntrip_c; 22 | 23 | void setup() { 24 | // put your setup code here, to run once: 25 | Serial.begin(115200); 26 | delay(10); 27 | Serial.print("Connecting to "); 28 | Serial.println(ssid); 29 | WiFi.begin(ssid, password); 30 | while (WiFi.status() != WL_CONNECTED) { 31 | delay(500); 32 | Serial.print("."); 33 | } 34 | Serial.println("WiFi connected"); 35 | Serial.println("IP address: "); 36 | Serial.println(WiFi.localIP()); 37 | 38 | Serial.println("Requesting SourceTable."); 39 | if(ntrip_c.reqSrcTbl(host,httpPort)){ 40 | char buffer[512]; 41 | delay(5); 42 | while(ntrip_c.available()){ 43 | ntrip_c.readLine(buffer,sizeof(buffer)); 44 | Serial.print(buffer); 45 | } 46 | } 47 | else{ 48 | Serial.println("SourceTable request error"); 49 | } 50 | Serial.print("Requesting SourceTable is OK\n"); 51 | ntrip_c.stop(); //Need to call "stop" function for next request. 52 | 53 | Serial.println("Requesting MountPoint's Raw data"); 54 | if(!ntrip_c.reqRaw(host,httpPort,mntpnt,user,passwd)){ 55 | delay(15000); 56 | ESP.restart(); 57 | } 58 | Serial.println("Requesting MountPoint is OK"); 59 | 60 | 61 | } 62 | 63 | void loop() { 64 | // put your main code here, to run repeatedly: 65 | while(ntrip_c.available()) { 66 | char ch = ntrip_c.read(); 67 | Serial.print(ch); 68 | 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/NTRIPClient.cpp: -------------------------------------------------------------------------------- 1 | #include"NTRIPClient.h" 2 | bool NTRIPClient::reqSrcTbl(char* host,int &port) 3 | { 4 | if(!connect(host,port)){ 5 | Serial.print("Cannot connect to "); 6 | Serial.println(host); 7 | return false; 8 | }/*p = String("GET ") + String("/") + String(" HTTP/1.0\r\n"); 9 | p = p + String("User-Agent: NTRIP Enbeded\r\n");*/ 10 | print( 11 | "GET / HTTP/1.0\r\n" 12 | "User-Agent: NTRIPClient for Arduino v1.0\r\n" 13 | ); 14 | unsigned long timeout = millis(); 15 | while (available() == 0) { 16 | if (millis() - timeout > 5000) { 17 | Serial.println("Client Timeout !"); 18 | stop(); 19 | return false; 20 | } 21 | delay(10); 22 | } 23 | char buffer[50]; 24 | readLine(buffer,sizeof(buffer)); 25 | if(strncmp((char*)buffer,"SOURCETABLE 200 OK",17)) 26 | { 27 | Serial.print((char*)buffer); 28 | return false; 29 | } 30 | return true; 31 | 32 | } 33 | bool NTRIPClient::reqRaw(char* host,int &port,char* mntpnt,char* user,char* psw) 34 | { 35 | if(!connect(host,port))return false; 36 | String p="GET /"; 37 | String auth=""; 38 | Serial.println("Request NTRIP"); 39 | 40 | p = p + mntpnt + String(" HTTP/1.0\r\n" 41 | "User-Agent: NTRIPClient for Arduino v1.0\r\n" 42 | ); 43 | 44 | if (strlen(user)==0) { 45 | p = p + String( 46 | "Accept: */*\r\n" 47 | "Connection: close\r\n" 48 | ); 49 | } 50 | else { 51 | auth = base64::encode(String(user) + String(":") + psw); 52 | #ifdef Debug 53 | Serial.println(String(user) + String(":") + psw); 54 | #endif 55 | 56 | p = p + String("Authorization: Basic "); 57 | p = p + auth; 58 | p = p + String("\r\n"); 59 | } 60 | p = p + String("\r\n"); 61 | print(p); 62 | #ifdef Debug 63 | Serial.println(p); 64 | #endif 65 | unsigned long timeout = millis(); 66 | while (available() == 0) { 67 | if (millis() - timeout > 20000) { 68 | Serial.println("Client Timeout !"); 69 | return false; 70 | } 71 | delay(10); 72 | } 73 | char buffer[50]; 74 | readLine(buffer,sizeof(buffer)); 75 | if(strncmp((char*)buffer,"ICY 200 OK",10)) 76 | { 77 | Serial.print((char*)buffer); 78 | return false; 79 | } 80 | return true; 81 | } 82 | bool NTRIPClient::reqRaw(char* host,int &port,char* mntpnt) 83 | { 84 | return reqRaw(host,port,mntpnt,"",""); 85 | } 86 | int NTRIPClient::readLine(char* _buffer,int size) 87 | { 88 | int len = 0; 89 | while(available()) { 90 | _buffer[len] = read(); 91 | len++; 92 | if(_buffer[len-1] == '\n' || len >= size) break; 93 | } 94 | _buffer[len]='\0'; 95 | 96 | return len; 97 | } 98 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | --------------------------------------------------------------------------------