Created
October 5, 2023 12:48
-
-
Save dj1711572002/0308bcc750129e3f66f11b0d05b95cf2 to your computer and use it in GitHub Desktop.
NTRIP ALES
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//ALES_M5Stick_NewBizStatio_GGA_TEST__rev000.ino | |
/* | |
* NTRIP client for Arduino Ver. 1.0.0 | |
* NTRIPClient Sample | |
* Request Source Table (Source Table is basestation list in NTRIP Caster) | |
* Request Reference Data | |
* | |
* | |
*/ | |
//#include <ESP8266WiFi.h> //Need for ESP8266 | |
#include<M5StickC.h> | |
#include <WiFi.h> //Need for ESP32 | |
#include <NTRIPClient.h> | |
#define YELLOW 0xFFE0 | |
//#include"M5Stack.h"; | |
const char* ssid = "e";// | |
const char* password = "21311610";// | |
int n; | |
char* host ="";//ALESのURL | |
int httpPort = ; //ALESのポート | |
char* mntpnt ="";//ALESのマウントポイント名 | |
char* user = ""; //ALESのユーザID | |
char* passwd ="";//ALESのパスワード | |
NTRIPClient ntrip_c; | |
void setup() { | |
M5.begin(); | |
M5.Lcd.setRotation( 1 ); | |
M5.Lcd.setTextSize(1); | |
M5.Lcd.setTextColor(YELLOW); | |
// put your setup code here, to run once: | |
Serial.begin(115200); | |
Serial1.begin(115200,SERIAL_8N1,32,33);//To RIGHT_F9P Grove RX32 TX33*******(baudrate,config,RX,TX) | |
Serial2.begin(115200,SERIAL_8N1,0,26);//To LEFT_F9P EXT RX0 TX26*******(baudrate,config,RX,TX) | |
delay(10); | |
Serial.print("Connecting to "); | |
// M5.Lcd.print("Connecting to "); | |
Serial.println("Requesting SourceTable."); | |
WiFi.begin(ssid, password); | |
while (WiFi.status() != WL_CONNECTED) { | |
delay(500); | |
Serial.print("."); | |
//M5.Lcd.print("."); | |
} | |
Serial.println("WiFi connected"); | |
Serial.println("IP address: "); | |
Serial.println(WiFi.localIP()); | |
Serial.print(ssid); | |
M5.Lcd.setTextSize(1); | |
M5.Lcd.print("WiFI:OK_"); | |
if(ntrip_c.reqSrcTbl(host,httpPort)){ | |
char buffer[512]; | |
delay(5); | |
while(ntrip_c.available()){ | |
ntrip_c.readLine(buffer,sizeof(buffer)); | |
Serial.print(buffer); | |
// M5.Lcd.print(buffer); | |
} | |
} | |
else{ | |
Serial.println("SourceTable request error"); | |
M5.Lcd.setTextSize(1); | |
M5.Lcd.print("Ntrip Err"); | |
} | |
Serial.print("Requesting SourceTable is OK\n"); | |
ntrip_c.stop(); //Need to call "stop" function for next request. | |
Serial.println("Requesting MountPoint's Raw data"); | |
// M5.Lcd.print("R"); | |
//===================================vrs GGA send====================================================== | |
// char ggac[]={"$GNGGA,064702.40,3612.27794,N,13756.95425,E,5,12,0.83,609.1,M,36.7,M,0.0,0000*6F"};//KYOTO | |
char ggac[]={"$GNGGA,124733.13,3612.27759,N,13756.95161,E,4,12,0.80,608.5,M,36.7,M,0.1,0000*6C\r\n"};//Ishihsiba | |
// Serial.print("ggac size="); | |
//Serial.println(sizeof(ggac)); | |
if(!ntrip_c.reqRaw(host,httpPort,mntpnt,user,passwd,ggac)){ | |
delay(10000); | |
ESP.restart(); | |
} | |
//======================================================================================================= | |
/* | |
//===================Ntrip Caster======================================================= | |
if(!ntrip_c.reqRaw(host,httpPort,mntpnt,user,passwd)){ | |
delay(15000); | |
ESP.restart(); | |
} | |
//==================================================================================== | |
*/ | |
M5.Lcd.setTextSize(1); | |
M5.Lcd.print("Ntrip:OK\n"); | |
M5.Lcd.setTextSize(2); | |
M5.Lcd.printf("%s\n",mntpnt); | |
Serial.print("Requesting MountPoint is OK="); | |
Serial.println(mntpnt); | |
//M5.Lcd.print("Requesting MountPoint's Raw data"); | |
M5.Lcd.setTextSize(1); | |
M5.Lcd.print("RTCM:OK_"); | |
M5.Lcd.print("["); | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
while(ntrip_c.available()) { | |
n++; | |
char ch = ntrip_c.read(); | |
Serial1.print(ch); | |
Serial2.print(ch); | |
//Serial.print(ch,HEX); | |
//Serial.print(","); | |
if (n<6){ | |
M5.Lcd.print(ch,HEX); | |
} | |
if(n==6){ | |
M5.Lcd.println("]"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment