DRA818 VHF or UHF radio module library. http://www.dorji.com/docs/data/DRA818V.pdf
Embed:
(wiki syntax)
Show/hide line numbers
dra818.cpp
00001 #include "mbed.h" 00002 #include "dra818.h" 00003 00004 DRA818::DRA818(Serial *s, PinName PTT): PTT_PIN(PTT){ 00005 this->serial = s; 00006 this->PTT_PIN=1; 00007 00008 this->tx_ctcss = 0; 00009 this->rx_ctcss = 0; 00010 this->tx_freq = 146.500; 00011 00012 this->volume = 4; 00013 this->squelch = 0; 00014 this->preemph = 0; 00015 this->highpass = 0; 00016 this->lowpass = 0; 00017 } 00018 00019 00020 void DRA818::setTXFreq(double tx_freq){ 00021 if( (tx_freq>136.000 && tx_freq<174.000 ) || (tx_freq>410.000 && tx_freq<480.000) ){ 00022 this->tx_freq = tx_freq; 00023 } 00024 } 00025 00026 void DRA818::setRXFreq(double rx_freq){ 00027 if( (rx_freq>136.000 && rx_freq<174.000 ) || (rx_freq>410.000 && rx_freq<480.000) ){ 00028 this->rx_freq = rx_freq; 00029 } 00030 } 00031 00032 // Refer to https://en.wikipedia.org/wiki/CTCSS for CTCSS values. 00033 void DRA818::setTXCTCSS(uint8_t ctcss){ 00034 if(ctcss<=38){ 00035 this->tx_ctcss = ctcss; 00036 } 00037 } 00038 void DRA818::setRXCTCSS(uint8_t ctcss){ 00039 if(ctcss<=38){ 00040 this->rx_ctcss = ctcss; 00041 } 00042 } 00043 00044 void DRA818::setGWB(bool gwb){ 00045 this->gwb=gwb?1:0; 00046 } 00047 00048 void DRA818::setSquelch(uint8_t sql){ 00049 if(sql<=8){ 00050 this->squelch = sql; 00051 } 00052 } 00053 00054 void DRA818::writeFreq(){ 00055 this->PTT_PIN=1; 00056 wait_ms(500); // Delay for a bit, to let the uC boot up (?) 00057 00058 char tx_freq_buffer[10]; 00059 char rx_freq_buffer[10]; 00060 00061 sprintf(tx_freq_buffer,"%.4f",this->tx_freq); 00062 sprintf(rx_freq_buffer,"%.4f",this->rx_freq); 00063 sprintf(this->buffer,"AT+DMOSETGROUP=%d,%s,%s,%04d,%1d,%04d\r\n",this->gwb,tx_freq_buffer,rx_freq_buffer,this->tx_ctcss,this->squelch,this->rx_ctcss); 00064 this->serial->printf("%s",this->buffer); 00065 } 00066 00067 void DRA818::setVolume(uint8_t vol){ 00068 if(vol>=1 || vol<=8){ 00069 this->volume = vol; 00070 } 00071 00072 this->PTT_PIN=1; 00073 wait_ms(500); // Delay for a bit, to let the uC boot up (?) 00074 00075 sprintf(this->buffer,"AT+DMOSETVOLUME=%1d\r\n",this->volume); 00076 this->serial->printf("%s",this->buffer); 00077 } 00078 00079 void DRA818::setFilters(bool preemph, bool highpass, bool lowpass){ 00080 this->preemph=preemph?1:0; 00081 this->highpass=highpass?1:0; 00082 this->lowpass=lowpass?1:0; 00083 00084 this->PTT_PIN=1; 00085 wait_ms(500); // Delay for a bit, to let the uC boot up (?) 00086 00087 sprintf(this->buffer,"AT+SETFILTER=%1d,%1d,%1d\r\n",this->preemph,this->highpass,this->lowpass); 00088 this->serial->printf("%s",this->buffer); 00089 }
Generated on Wed Jul 13 2022 17:53:37 by 1.7.2