\ ********************************************************************* \ Communication between two REYAX LoRa transmitters \ Filename: LoRaInitParams.txt \ Date: 20 jan 2022 \ Updated: 20 jan 2022 \ File Version: 1.0 \ MCU: ESP32-WROOM-32 \ Forth: ESP32forth all versions 7.x++ \ with Serial2 extension \ Copyright: Marc PETREMANN \ Author: Marc PETREMANN \ GNU General Public License \ ********************************************************************* DEFINED? --TRlora [if] forget --TRlora [then] create --TRlora \ *** defining LoRa Setup words ***************************** create $crlf $0d c, $0a c, : crlf ( -- ) \ same action as cr, but adapted for LoRa $crlf 2 type ; \ SEND Send data to the appointment address : ATsend { addr len address -- } ." AT+SEND=" address n. [char] , emit len n. [char] , emit addr len type crlf ; \ *** defining defered words ******************************** serial \ Select Serial vocabulary : serial2-type ( a n -- ) Serial2.write drop ; : typeToLoRa ( -- ) 0 echo ! \ disable display echo from terminal ['] serial2-type is type ; : typeToTerm ( -- ) ['] default-type is type -1 echo ! \ enable display echo from terminal ; \ 115200 speed communication for LoRa REYAX 115200 value #SERIAL2_RATE \ definition of OUTput and INput buffers 256 string LoRaRX \ buffer LoRa transmitter -> ESP32 \ initialise Serial2 : Serial2.init ( -- ) #SERIAL2_RATE Serial2.begin ; \ input from LoRa transmitter : LoRaInput ( -- ) Serial2.available if LoRaRX maxlen$ nip Serial2.readBytes LoRaRX drop cell - ! else 0 LoRaRX drop cell - ! then ; : rx. ( -- ) LoRaINPUT loRaRX type ; \ *** examples of usage ***** DEFINED? --test [if] forget --test [then] create --test : emptyRX ( -- ) LoRaINPUT ; 55 constant LoRaBOSS 39 constant LoRaSLAV1 40 constant LoRaSLAV2 : toSLAV2 ( addr len -- ) emptyRX typeToLoRa LoRaSLAV2 ATsend typeToTerm ; serial2.init s" this is a transmission test" toSLAV2 100 ms rx.
Legal: site web personnel sans commerce / personal site without seling