{"id":20900576,"url":"https://github.com/mr-glt/sx127x_lora","last_synced_at":"2025-04-09T18:22:56.128Z","repository":{"id":33787881,"uuid":"162230852","full_name":"mr-glt/sx127x_lora","owner":"mr-glt","description":"A platform-agnostic driver for Semtech SX1276/77/78/79 based boards.","archived":false,"fork":false,"pushed_at":"2024-05-26T13:14:55.000Z","size":86,"stargazers_count":47,"open_issues_count":9,"forks_count":41,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-02T12:54:09.447Z","etag":null,"topics":["embedded-hal-driver","lora","no-std","rust","sx1276","sx1278"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mr-glt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-18T04:38:11.000Z","updated_at":"2025-03-16T00:20:58.000Z","dependencies_parsed_at":"2024-11-19T04:15:32.173Z","dependency_job_id":"2027fd50-26e5-403d-951d-517daa09bcc0","html_url":"https://github.com/mr-glt/sx127x_lora","commit_stats":{"total_commits":35,"total_committers":6,"mean_commits":5.833333333333333,"dds":0.5428571428571429,"last_synced_commit":"967c7e7e7e457971f0d5541255d280b84675c6b8"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mr-glt%2Fsx127x_lora","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mr-glt%2Fsx127x_lora/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mr-glt%2Fsx127x_lora/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mr-glt%2Fsx127x_lora/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mr-glt","download_url":"https://codeload.github.com/mr-glt/sx127x_lora/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248085875,"owners_count":21045235,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["embedded-hal-driver","lora","no-std","rust","sx1276","sx1278"],"created_at":"2024-11-18T11:20:49.556Z","updated_at":"2025-04-09T18:22:56.111Z","avatar_url":"https://github.com/mr-glt.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sx127x_lora\n[![](http://meritbadge.herokuapp.com/sx127x-lora)](https://crates.io/crates/sx127x-lora)\n![](https://img.shields.io/hexpm/l/plug.svg)\n\n A platform-agnostic driver for Semtech SX1276/77/78/79 based boards. It supports any device that\nimplements the `embedded-hal` traits. Devices are connected over SPI and require an extra GPIO pin for\nRESET. This cate works with any Semtech based board including:\n * Modtronix inAir4, inAir9, and inAir9B\n * HopeRF RFM95W, RFM96W, and RFM98W\n# Examples\n## Raspberry Pi Basic Send\nUtilizes a Raspberry Pi to send a message. The example utilizes the `linux_embedded_hal` crate.\n```rust\n#![feature(extern_crate_item_prelude)]\nextern crate sx127x_lora;\nextern crate linux_embedded_hal as hal;\n\nuse hal::spidev::{self, SpidevOptions};\nuse hal::{Pin, Spidev};\nuse hal::sysfs_gpio::Direction;\nuse hal::Delay;\n\nconst LORA_CS_PIN: u64 = 8;\nconst LORA_RESET_PIN: u64 = 21;\nconst FREQUENCY: i64 = 915;\n\nfn main(){\n\n    let mut spi = Spidev::open(\"/dev/spidev0.0\").unwrap();\n    let options = SpidevOptions::new()\n        .bits_per_word(8)\n        .max_speed_hz(20_000)\n        .mode(spidev::SPI_MODE_0)\n        .build();\n    spi.configure(\u0026options).unwrap();\n\n    let cs = Pin::new(LORA_CS_PIN);\n    cs.export().unwrap();\n    cs.set_direction(Direction::Out).unwrap();\n\n    let reset = Pin::new(LORA_RESET_PIN);\n    reset.export().unwrap();\n    reset.set_direction(Direction::Out).unwrap();\n\n    let mut lora = sx127x_lora::LoRa::new(\n        spi, cs, reset,  FREQUENCY, Delay)\n        .expect(\"Failed to communicate with radio module!\");\n\n    lora.set_tx_power(17,1); //Using PA_BOOST. See your board for correct pin.\n\n    let message = \"Hello, world!\";\n    let mut buffer = [0;255];\n    for (i,c) in message.chars().enumerate() {\n        buffer[i] = c as u8;\n    }\n\n    let transmit = lora.transmit_payload(buffer,message.len());\n    match transmit {\n        Ok(packet_size) =\u003e println!(\"Sent packet with size: {}\", packet_size),\n        Err(()) =\u003e println!(\"Error\"),\n    }\n}\n```\n## STM32F429 Blocking Receive\nUtilizes a STM32F429 to receive data using the blocking `poll_irq(timeout)` function. It prints\nthe received packet back out over semihosting. The example utilizes the `stm32f429_hal`, `cortex_m`,\nand `panic_semihosting` crates.\n```rust\n#![no_std]\n#![no_main]\n\nextern crate sx127x_lora;\nextern crate stm32f429_hal as hal;\nextern crate cortex_m;\nextern crate panic_semihosting;\n\nuse sx127x_lora::MODE;\nuse cortex_m_semihosting::*;\nuse hal::gpio::GpioExt;\nuse hal::flash::FlashExt;\nuse hal::rcc::RccExt;\nuse hal::time::MegaHertz;\nuse hal::spi::Spi;\nuse hal::delay::Delay;\n\nconst FREQUENCY: i64 = 915;\n\n#[entry]\nfn main() -\u003e !{\n    let cp = cortex_m::Peripherals::take().unwrap();\n    let p = hal::stm32f429::Peripherals::take().unwrap();\n\n    let mut rcc = p.RCC.constrain();\n    let mut flash = p.FLASH.constrain();\n    let clocks = rcc\n        .cfgr\n        .sysclk(MegaHertz(64))\n        .pclk1(MegaHertz(32))\n        .freeze(\u0026mut flash.acr);\n\n    let mut gpioa = p.GPIOA.split(\u0026mut rcc.ahb1);\n    let mut gpiod = p.GPIOD.split(\u0026mut rcc.ahb1);\n    let mut gpiof = p.GPIOF.split(\u0026mut rcc.ahb1);\n\n    let sck = gpioa.pa5.into_af5(\u0026mut gpioa.moder, \u0026mut gpioa.afrl);\n    let miso = gpioa.pa6.into_af5(\u0026mut gpioa.moder, \u0026mut gpioa.afrl);\n    let mosi = gpioa.pa7.into_af5(\u0026mut gpioa.moder, \u0026mut gpioa.afrl);\n    let reset = gpiof.pf13.into_push_pull_output(\u0026mut gpiof.moder, \u0026mut gpiof.otyper);\n    let cs = gpiod.pd14.into_push_pull_output(\u0026mut gpiod.moder, \u0026mut gpiod.otyper);\n\n    let spi = Spi::spi1(\n        p.SPI1,\n        (sck, miso, mosi),\n        MODE,\n        MegaHertz(8),\n        clocks,\n        \u0026mut rcc.apb2,\n    );\n\n    let mut lora = sx127x_lora::LoRa::new(\n        spi, cs, reset, FREQUENCY,\n        Delay::new(cp.SYST, clocks)).unwrap();\n\n    loop {\n        let poll = lora.poll_irq(Some(30)); //30 Second timeout\n        match poll {\n            Ok(size) =\u003e{\n               hprint!(\"with Payload: \");\n               let buffer = lora.read_packet(); // Received buffer. NOTE: 255 bytes are always returned\n               for i in 0..size{\n                   hprint!(\"{}\",buffer[i] as char).unwrap();\n               }\n               hprintln!();\n            },\n            Err(()) =\u003e hprintln!(\"Timeout\").unwrap(),\n        }\n    }\n}\n```\n## Interrupts\nThe crate currently polls the IRQ register on the radio to determine if a new packet has arrived. This\nwould be more efficient if instead an interrupt was connect the the module's DIO_0 pin. Once interrupt\nsupport is available in `embedded-hal`, then this will be added. It is possible to implement this function on a\ndevice-to-device basis by retrieving a packet with the `read_packet()` function.\n\n## Contributing\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmr-glt%2Fsx127x_lora","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmr-glt%2Fsx127x_lora","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmr-glt%2Fsx127x_lora/lists"}