当前位置:网站首页>Portapack application development tutorial (XVII) nRF24L01 launch B

Portapack application development tutorial (XVII) nRF24L01 launch B

2022-07-06 15:09:00 Lao Shao's open source world

This project github:

GitHub - jamesshao8/btle_nrf24l01: send or receiver btle packet with nrf24l01

More than a year ago, I realized PortaPack receive nrf24l01/btle Data packets . Later, I always wanted to realize portapack/hackrf launch nrf24l01 Data packets , The previous idea was to change gr-noridc The launch code in is given to its own receiving code or several other open source receiving projects . But it didn't work . There are problems in both coding and modulation .

Then I came up with a new method . since hackrf and nrf24l01 There are ready-made projects to send and receive low Bluetooth packets . Then I can also use it hackrf Send Bluetooth packets to nrf24l01, Packaging data into Bluetooth mode can be regarded as application layer coding , The bottom layer is consistent nrf24l01 Required , It can also be regarded as indirectly realizing my needs .

However, there are still many holes in the concrete implementation , Here's a record .

I first implemented it with the following project hackrf Send and receive data packets to mobile phones GitHub - jamesshao8/BTLE: Bluetooth Low Energy (BLE) packet sniffer and transmitter for both standard and non standard (raw bit) based on Software Defined Radio (SDR).

SDR Send low-power Bluetooth packets _ Bili, Bili _bilibili

The above is the corresponding video

command

./btle_tx 37-DISCOVERY-TxAdd-1-RxAdd-0-AdvA-070203040506-LOCAL_NAME09-SHAO_HACKRF r30

You can iphone Jacket nrf connect This app Take a look at the searched packets .

such hackrf Launching low-power Bluetooth is done , Of course, receiving is no problem btle_rx Just go .

Then I found two projects , Namely nrf24l01 Transmitting and receiving low-power Bluetooth packets .

The first project is only launch , Corresponding to me github Under the project of send_simplified, The code structure is very simple , There is no need to call a third party RF24 library . Another project has reception , Corresponding send and recv, But sending and receiving are complicated .

Let me use it first. send_simplified project , Confirmed. arduino+nrf24l01 It can indeed send data to mobile phones , And the hardware itself and the connection are all right .

Then try again send and recv. There was a problem , No hair , The data received is also very strange , Later, I learned that the two projects are used by default ce csn The words are reversed . So we changed our country send recv Code for , It was originally radio(9,10) The place is changed to radio(10,9).

then send To send data packets to mobile phones , also recv Can also receive send Data packets of ( The fast refresh is for manual use send The hair , Not environmental ). however send and recv There is too much code to understand ,recv I didn't know what the serial output data was .

So I later tried to use recv Collect it send_simplified Data packets of , And then from send_simplified Find the corresponding relationship in the code of .

I have learned that recv The data of data is actually the data before encoding or after decoding , And does not include the previous broadcast address . After knowing this, I can follow send_simplified The definitions of various data bits are recv Do decoding work in . Mainly to find out Name Length and Name Itself binary to character and find Data And directly show data The number .

After finishing these , I'll try HackRF Send packets to nrf24l01+arduino Of recv Program .

I learned that in fact send_simplified Send packets ,hackrf function btle_rx When , Will receive such a message .

65776us Pkt1111 Ch37 AA:8e89bed6 ADV_PDU_t2:ADV_NONCONN_IND T1 R0 PloadL21 AdvA:685746352413 Data:0201060608534841524604ccaabbdd CRC0

This is related to arduino recv It's corresponding in . then btle_tx There will also be a prompt when launching INFO bit and PHY bit. I guess INFO bit Is the data before coding ,PHY bit It's coded ( It doesn't make much sense ).

Then my later goal was to find ways to adjust btle_tx Parameters of , Make it emit INFO bit Data similar to the following in ( Follow send_simplified Send and recv The solution is exactly the same ):

 2 1 6 6 8 53 48 41 52 46 4 CC AA BB DD

I found it impossible to send LOCAL_NAME09 It's packed , Otherwise, the first few values (2 1 Representative data type ) It's different . Later I read it carefully hackrf With btle Documentation of the program , It is found that the data before coding can be written directly by hand , So I use the following command :

./btle_tx 39-ADV_IND-TxAdd-1-RxAdd-0-AdvA-685746352413-AdvData-0201060608534841524604ccaabbdd r1000

You can see , This manual packet , Mandatory data type 0201, And the following content also follows me send_simplified Send exactly the same , Just like the ,arduino recv You can see this packet .

You can also change the data yourself ccaabbdd Change the content casually , But don't change the length .

SDR Send low-power Bluetooth packets to nrf24l01_ Bili, Bili _bilibili

Theoretically , You can control the small four axes in this way , Small four axis is directly used nrf24l01 Many as receivers . I also found a project to use nrf+arduino Realized ppm Output , This can completely replace ppm The remote control receiver is connected to my own small four-axis .

But there are still several areas that need to be improved : One is data accuracy , If ccaabbdd As data ,4 One channel, one for each channel cc, That's one byte, Then it can only be divided into 256 Combinations of . And it turns out ppm perhaps pwm You can go from 0 To 2000 change , In this case, the accuracy will be lost 8 times . There is also a bigger problem that the data interval sent is relatively large , At present, it is the smallest 300ms, The received data interval is larger due to packet loss , In this way, there is no time to control the aircraft .

So I have a few things to do later :

1. Abbreviation btle_tx project , Try to improve the launch efficiency

2.btle_tx Migration to portapack in

3. use nrf24l01+arduino pro mini combination cheapass receiver, Self control ppm The receiver is ready .

原网站

版权声明
本文为[Lao Shao's open source world]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202131323051525.html