Skip to content

SW-19. BLE TX feature #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 43 commits into
base: develop
Choose a base branch
from
Open

Conversation

tryuan99
Copy link
Member

@tryuan99 tryuan99 commented Feb 13, 2020

This code contains the ble.h header file, which allows SCuM to transmit BLE. It also contains code for the LC calibration using the optical programmer.

The application file ble_tx_154_rx allows SCuM to receive 15.4 packets from OpenMote and broadcast the data as BLE packets.

The code was refactored into the current structure and works with the ble_tx.c and ble_tx_154_rx.c application.

  • Call ble_init_tx() after initialize_mote().
  • For a test packet, call ble_gen_test_packet() before calling ble_transmit(). Make sure to set the frequency with LC_FREQCHANGE before transmitting.
  • For a custom packet, set the corresponding fields first like name, temperature, etc. Call [field]_tx_en(true) to include them in the packet. Finally call ble_gen_packet() to generate the BLE packet and then call ble_transmit() to transmit the packet.

@changtengfei
Copy link
Contributor

@tryuan99 here are two questions:

  1. does the bin and hex images required to be committed?
  2. how do you test your code work?

@tryuan99
Copy link
Member Author

@changtengfei

  1. I removed the bin and hex images in this commit: 39daf94. Thanks!
  2. To test ble_tx.c, I ran the code on dev board Q4 and tested that I could receive SCUM3 packets on my phone. I also tested the BLE packet generation by injecting dummy data in the packet and verifying the packet contents on my phone. Sweeping was checked using the spectrum analyzer.
    To test ble_tx_154_rx.c, I had an OpenMote transmitting on channel 11 nearby sending a simple counter. I logged over UART whether I was receiving any packets. I then verified on my phone (see my SCuM meeting presentation on 2020-02-19) that the BLE packet contained the 15.4 packet contents, where the first four bytes are 0xXX 0x01 0x02 0x03.

@changtengfei
Copy link
Contributor

@tryuan99 great! what's the app on the phone I should install for the test?

@tryuan99
Copy link
Member Author

I use https://github.com/tryuan99/android-ble-scum, which is an Android app I wrote that specifically filters for SCuM's BLE packets and displays all of its contents. For general BLE packets, I use nRF Connect to sniff the BLE packets.

@changtengfei
Copy link
Contributor

@tryuan99 could you generate an apk file and attach/release it in your repo? So the other can just download it.

@changtengfei
Copy link
Contributor

@tryuan99 I have reviewed your PR. Usually you are not suppose to touch the bsp/driver code, such as the optical/radio, unless your are sure the changes won't break the other projects.

For the PR, the changes in optical will break all the existing projects.

To fulfill what this PR is trying to do I would propose a way to do so.

Re-write the BLE tx app based on the frequency tx.

  • In the frequency settings, you narrow down the setting range to somewhere you are sure the correct frequency is located at. In another word, you only sweep that short range of frequency settings.
  • send a packet or two at each frequency setting, in the payload, put the frequency setting you used for each packet
  • check on the bluetooth app side, to see the packet shows up, and you will know the right frequency settings for SCuM.

Try to send packet as short as you can, including the device name, frequency setting and any required field. So you can sweep the frequency setting range quickly to see packet show up in BLE app.

I think this will make the app simple and every time you run the code, you will always see packet in BLE app, even the frequency settings may various, but still in the range.

Does this sounds good for you?

@tryuan99
Copy link
Member Author

@changtengfei My changes in optical.c should not affect other projects since all of the code I added will not run unless optical_enableLCCalibration() is called in the application file. The default for LC calibration enable is false.

I see that there is a change in radio.c that turns on the divider for radio_txEnable, which I manually changed in my code, so I will incorporate this change into my PR to not break other projects that do not require the divider.

@tryuan99
Copy link
Member Author

I still need to test that this merge did not break my BLE code.

LC_FREQCHANGE(optical_vars.cal_LC_coarse, optical_vars.cal_LC_mid, optical_vars.cal_LC_fine);
}

bool optical_getCalibrationFinished(void) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see there is a typo of this function that you fixed, I guess all other projects are using the wrong old name.

Copy link
Member Author

@tryuan99 tryuan99 Feb 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed this in c5d0f48.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@changtengfei
Copy link
Contributor

@tryuan99 there should be a conflict to the develop branch, as indicated in the jenkins builder but somehow the Github is not complaining.
Let me know if you have issue to fix it.

set_PA_supply(63);
set_LO_supply(127,0);
set_PA_supply(127);
set_LO_supply(63,0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you confirm this will not effect the project using IEEE802.15.4 radio? such freq_sweep_tx/rx/lc_count?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified that freq_sweep_rx works, but I couldn't get freq_sweep_tx working, even if I check out the current version from the develop branch. After two fine code iterations, SCuM starts printing to UART.


}

void radio_init_divider(unsigned int div_value){

// Set divider LDO value to max
set_DIV_supply(63,0);
set_DIV_supply(127,0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here?

@changtengfei
Copy link
Contributor

Hi @tryuan99 as the builder test still failed.

I reviewed your code again, there are only few comments left which I am not sure it is reason that test failed. Other than the few comments, the code looks fine for me. Could you take a look?

@changtengfei
Copy link
Contributor

@tryuan99 I found the optical interrupts stopped at 24 times (expected 25), which is because of the large size of image takes long for CRC check. I have reported this in the mailinglist and the fix is in my quickCal PR: https://github.com/PisterLab/scum-test-code/pull/15/files, maybe we could try this PR again after merge mine?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants