<commit_before>/*

UKHASnet Dumb-Buoy Code by <NAME> M0DNY

Based on UKHASnet rf69_repeater by <NAME> M6JCX

GPS Code from Habduino by <NAME> M0UPU - https://github.com/HABduino/HABduino/tree/master/Software/
* Based on CUSF Joey Flight Code - https://github.com/cuspaceflight/joey-m/tree/master/firmware

*/
#include <util/crc16.h>
#include <SPI.h>
#include <string.h>
#include "RFM69Config.h"
#include "RFM69.h"
#include "LowPower.h"
#include "DallasTemperature.h"

#define PB1

//************* Node ID Setup ****************/
#ifdef PB1
char id[] = "PB1";
#define BATTV_FUDGE 1.098
#endif
#define BEACON_INTERVAL 20
uint8_t rfm_power = 20; // dBmW

//************* Sensors ****************/
// Battery Voltage Measurement - Also enables zombie mode
#define ENABLE_BATTV_SENSOR // Comment out to disable, also disables zombie mode
#define BATTV_PIN 0 //ADC 0 - Battery Voltage, scaled to 1.1V
DeviceAddress ds_addr;

//************* Misc Setup ****************/
byte num_repeats = '3'; //The number of hops the message will make before stopping
float battV=0.0;
uint8_t n;
uint32_t count = 1, data_interval = 10;
uint8_t data_count = 97; // 'a'
char data[64], string_end[] = "]";

// Singleton instance of the radio
RFM69 rf69(9.3); // parameter: RFM temperature calibration offset (degrees as float)
OneWire ow(9);  // on pin PB1 (arduino: 9)
DallasTemperature sensors(&ow);

uint8_t buf[60]; 
uint8_t lock =0, sats = 0, nolock=0;
int GPSerror = 0,navmode = 0,psm_status = 0,lat_int=0,lon_int=0;
int32_t lat = 0, lon = 0, alt = 0, maxalt = 0, lat_dec = 0, lon_dec =0 ,tslf=0;

#ifdef ENABLE_BATTV_SENSOR
float sampleBattv() {
  // External 5:1 Divider
  return ((float)analogRead(BATTV_PIN)*1.1*5*BATTV_FUDGE)/1023.0;
}
#endif

int gen_Data(){
  sprintf(data, "%c%c", num_repeats, data_count);
  
  gps_check_lock();
  if(lock<2) {
    if(psm_status==1) {
        setGps_MaxPerformanceMode();
        psm_status=0;
    }
    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
    gps_check_lock();
    if(lock<2) {
        LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
        gps_check_lock();
        nolock++;
        if(lock<2 && nolock>10) {
            resetGPS();
            LowPower.powerDown(SLEEP_120MS, ADC_OFF, BOD_OFF);
            setupGPS();
            LowPower.powerDown(SLEEP_120MS, ADC_OFF, BOD_OFF);
            setGps_MaxPerformanceMode();
            nolock=0;
        }
     }
  }
  if(lock>=2) {
    gps_get_position();
    if(sats>=6 && psm_status==0) {
        setGPS_PowerSaveMode();
        psm_status=1;
    }
    nolock=0;
  }
  
  sprintf(data,"%sL%s%i.%05d,%s%i.%05d,%ldS%d",data,lat < 0 ? "-" : "",lat_int,lat_dec,lon < 0 ? "-" : "",lon_int,lon_dec,maxalt,sats);
  
  sensors.setWaitForConversion(false);
  sensors.requestTemperatures();
  LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);
  
  float temp = sensors.getTempC(ds_addr);

  char* tempStr;
  char tempStrA[12]; //make buffer large enough for 7 digits
  tempStr = dtostrf(temp,6,1,tempStrA);
  while( (strlen(tempStr) > 0) && (tempStr[0] == 32) )
  {
     strcpy(tempStr,&tempStr[1]);
  }
  sprintf(data,"%sT%s",data,tempStr);
  
  #ifdef ENABLE_BATTV_SENSOR
  battV = sampleBattv();<commit_msg>buoy: Fix flaot parsing.<commit_after>/*

UKHASnet Dumb-Buoy Code by <NAME> M0DNY

Based on UKHASnet rf69_repeater by <NAME> M6JCX

GPS Code from Habduino by <NAME> M0UPU - https://github.com/HABduino/HABduino/tree/master/Software/
* Based on CUSF Joey Flight Code - https://github.com/cuspaceflight/joey-m/tree/master/firmware

*/
#include <util/crc16.h>
#include <SPI.h>
#include <string.h>
#include "RFM69Config.h"
#include "RFM69.h"
#include "LowPower.h"
#include "DallasTemperature.h"

#define PB1

//************* Node ID Setup ****************/
#ifdef PB1
char id[] = "PB1";
#define BATTV_FUDGE 1.098
#endif
#define BEACON_INTERVAL 20
uint8_t rfm_power = 10; // dBmW

//************* Sensors ****************/
// Battery Voltage Measurement - Also enables zombie mode
#define ENABLE_BATTV_SENSOR // Comment out to disable, also disables zombie mode
#define BATTV_PIN 0 //ADC 0 - Battery Voltage, scaled to 1.1V
DeviceAddress ds_addr;

//************* Misc Setup ****************/
byte num_repeats = '3'; //The number of hops the message will make before stopping
float battV=0.0;
uint8_t n;
uint32_t count = 1, data_interval = 10;
uint8_t data_count = 97; // 'a'
char data[64], string_end[] = "]";

// Singleton instance of the radio
RFM69 rf69(9.3); // parameter: RFM temperature calibration offset (degrees as float)
OneWire ow(9);  // on pin PB1 (arduino: 9)
DallasTemperature sensors(&ow);

uint8_t buf[60]; 
uint8_t lock =0, sats = 0, nolock=0, psm_status = 0;
int16_t GPSerror = 0,navmode = 0,lat_int=0,lon_int=0;
int32_t lat = 0, lon = 0, alt = 0, maxalt = 0, lat_dec = 0, lon_dec =0 ,tslf=0;

#ifdef ENABLE_BATTV_SENSOR
float sampleBattv() {
  // External 5:1 Divider
  return ((float)analogRead(BATTV_PIN)*1.1*5*BATTV_FUDGE)/1023.0;
}
#endif

int gen_Data(){
  sprintf(data, "%c%c", num_repeats, data_count);
  
  gps_check_lock();
  if(lock<2) {
    if(psm_status==1) {
        setGps_MaxPerformanceMode();
        psm_status=0;
    }
    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
    gps_check_lock();
    if(lock<2) {
        LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
        gps_check_lock();
        nolock++;
        if(lock<2 && nolock>10) {
            resetGPS();
            LowPower.powerDown(SLEEP_120MS, ADC_OFF, BOD_OFF);
            setupGPS();
            LowPower.powerDown(SLEEP_120MS, ADC_OFF, BOD_OFF);
            setGps_MaxPerformanceMode();
            nolock=0;
        }
     }
  }
  if(lock>=2) {
    gps_get_position();
    if(sats>=6 && psm_status==0) {
        setGPS_PowerSaveMode();
        psm_status=1;
    }
    nolock=0;
  }
  
  sprintf(data,"%sL%s%d.%05ld,%s%d.%05ld,%ldS%d",data,lat < 0 ? "-" : "",lat_int,lat_dec,lon < 0 ? "-" : "",lon_int,lon_dec,maxalt,sats);
  
  sensors.setWaitForConversion(false);
  sensors.requestTemperatures();
  LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);
  
  float temp = sensors.getTempC(ds_addr);

  char* tempStr;
  char tempStrA[12]; //make buffer large enough for 7 digits
  tempStr = dtostrf(temp,6,1,tempStrA);
  while( (strlen(tempStr) > 0) && (tempStr[0] == 32) )
  {
     strcpy(tempStr,&tempStr[1]);
  }
  sprintf(data,"%sT%s",data,tempStr);
  
  #ifdef ENABLE_BATTV_SENSOR
  battV = sampleBattv();
{'fraction_non_alphanumeric': 0.16625, 'fraction_numerical': 0.0375, 'mean_word_length': 3.692815249266862, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 23, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3490326', 'n_tokens_mistral': 2729, 'n_tokens_neox': 2552, 'n_words': 529}