adafruit / Adafruit_GPS

An interrupt-based GPS Arduino library for no-parsing-required use
Other
469 stars 318 forks source link

Added support for generic Stream class #125

Closed petrkr closed 2 years ago

petrkr commented 4 years ago

Added support for generic Stream class.

Motivation was to use BluetoothSerial based GPS module and it's not good way to support "BTSerial" class. But since in arduino most of those classes are based on "Stream" class. This chage will add support not only to Bluetooth Serial, but should add also for network based sockets (tcp/udp streams) and other classes which are based on Stream class.

Maybe consider remove SW/HW serial too and make it as stream too. But there should be somehow kept function ->begin() which HW/SW Serial has.

Since I do not have any HWSerial based GPS here I can not test if this PR not break HardwareSerial constructor as it's also based on Stream. But I guess it should take most exact class and then go to parent ones.

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)                                                                                             
configsip: 0, SPIWP:0xee                                                                                                                            
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00                                                                             
mode:DIO, clock div:1                                                                                                                               
load:0x3fff0018,len:4                                                                                                                               
load:0x3fff001c,len:1216                                                                                                                            
ho 0 tail 12 room 4                                                                                                                                 
load:0x40078000,len:9720                                                                                                                            
ho 0 tail 12 room 4                                                                                                                                 
load:0x40080400,len:6352                                                                                                                            
entry 0x400806b8                                                                                                                                    
[I][BluetoothSerial.cpp:510] _init_bt(): device name set                                                                                            
[I][BluetoothSerial.cpp:225] esp_spp_cb(): ESP_SPP_INIT_EVT                                                                                         
[I][BluetoothSerial.cpp:118] btSetPin(): pin set                                                                                                    
[I][BluetoothSerial.cpp:722] connect(): master : remoteAddress                                                                                      
[I][BluetoothSerial.cpp:290] esp_spp_cb(): ESP_SPP_DISCOVERY_COMP_EVT                                                                               
Connected Succesfully!                                                                                                                              
[I][BluetoothSerial.cpp:735] connect(): master : remoteAddress                                                                                      
[I][BluetoothSerial.cpp:290] esp_spp_cb(): ESP_SPP_DISCOVERY_COMP_EVT                                                                               
[I][BluetoothSerial.cpp:292] esp_spp_cb(): ESP_SPP_DISCOVERY_COMP_EVT: spp connect to remote                                                        
[I][BluetoothSerial.cpp:314] esp_spp_cb(): ESP_SPP_CL_INIT_EVT                                                                                      
[I][BluetoothSerial.cpp:298] esp_spp_cb(): ESP_SPP_OPEN_EVT                                                                                         

Time: 00:00:00.000                                                                                                                                  
Date: 0/0/200                                                                                                                                       
Fix: 0 quality: 0                                                                                                                                   
$GPGGA,151126.000,1234.5552,N,01428.8626,E,1,7,1.14,277.4,M,45.5,M,,*5F                                                                             
$GPGGA,151126.000,1234.5552,N,01428.8626,E,1,7,1.14,277.4,M,45.5,M,,*5F                                                                             

$GPGSA,A,3,14,27,32,22,08,10,01,,,,,,1.50,1.14,0.97*05                                                                                              
$GPGSA,A,3,14,27,32,22,08,10,01,,,,,,1.50,1.14,0.97*05                                                                                              

$GPGSV,4,1,14,11,74,278,,08,60,191,15,01,47,289,18,32,44,102,37*7A                                                                                  
$GPGSV,4,1,14,11,74,278,,08,60,191,15,01,47,289,18,32,44,102,37*7A                                                                                  

$GPGSV,4,2,14,22,40,232,18,14,36,128,27,10,32,057,27,27,32,161,23*7E                                                                                
$GPGSV,4,2,14,22,40,232,18,14,36,128,27,10,32,057,27,27,32,161,23*7E                                                                                

$GPGSV,4,3,14,39,31,166,,28,19,318,,03,18,230,,21,11,102,*71                                                                                        
$GPGSV,4,3,14,39,31,166,,28,19,318,,03,18,230,,21,11,102,*71                                                                                        

$GPGSV,4,4,14,24,03,029,,20,01,060,*77                                                                                                              
$GPGSV,4,4,14,24,03,029,,20,01,060,*77                                                                                                              

$GPRMC,151126.000,A,1234.5552,N,01428.8626,E,0.04,271.96,121100,,,A*60                                                                              
$GPRMC,151126.000,A,1234.5552,N,01428.8626,E,0.04,271.96,121100,,,A*60                                                                              

$GPZDA,151126.000,12,11,2000,,*57                                                                                                                   
$GPZDA,151126.000,12,11,2000,,*57                                                                                                                   

$GPGGA,151127.000,1234.5551,N,01428.8631,E,1,7,1.14,277.5,M,45.5,M,,*5A                                                                             
$GPGGA,151127.000,1234.5551,N,01428.8631,E,1,7,1.14,277.5,M,45.5,M,,*5A                                                                             

$GPGSA,A,3,14,27,32,22,08,10,01,,,,,,1.50,1.14,0.97*05                                                                                              
$GPGSA,A,3,14,27,32,22,08,10,01,,,,,,1.50,1.14,0.97*05                                                                                              

$GPRMC,151127.000,A,1234.5551,N,01428.8631,E,0.04,271.96,121100,,,A*64                                                                              
$GPRMC,151127.000,A,1234.5551,N,01428.8631,E,0.04,271.96,121100,,,A*64                                                                              

$GPZDA,151127.000,12,11,2000,,*56                                                                                                                   
$GPZDA,151127.000,12,11,2000,,*56                                                                                                                   

$GPGGA,151128.000,1234.5551,N,01428.8636,E,1,7,1.14,277.5,M,45.5,M,,*52                                                                             
$GPGGA,151128.000,1234.5551,N,01428.8636,E,1,7,1.14,277.5,M,45.5,M,,*52                                                                             

$GPGSA,A,3,14,27,32,22,08,10,01,,,,,,1.50,1.14,0.97*05                                                                                              
$GPGSA,A,3,14,27,32,22,08,10,01,,,,,,1.50,1.14,0.97*05                                                                                              

$GPRMC,151128.000,A,1234.5551,N,01428.8636,E,0.04,271.96,121100,,,A*6C                                                                              
$GPRMC,151128.000,A,1234.5551,N,01428.8636,E,0.04,271.96,121100,,,A*6C                                                                              

$GPZDA,151128.000,12,11,2000,,*59                                                                                                                   
$GPZDA,151128.000,12,11,2000,,*59                                                                                                                   

Time: 15:11:28.1984                                                                                                                                 
Date: 12/11/200                                                                                                                                     
Fix: 1 quality: 1                                                                                                                                   
Location: 1234.5552N, 1428.8636E
Speed (knots): 0.04                                                                                                                                 
Angle: 271.96                                                                                                                                       
Altitude: 277.50                                                                                                                                    
Satellites: 7                                                                                                                                       
drak7 commented 4 years ago

This looks useful! Check out the build details to see where clang wants formatting changes.

caternuson commented 2 years ago

Merging. Did not test. But looks largely boiler plate and CI is happy.