u-blox / c209-aoa-tag

Bluetooth Direction Finding Tag sample application. Works with u-connectLocate.
https://www.u-blox.com/en/technologies/bluetooth-indoor-positioning
Apache License 2.0
31 stars 11 forks source link

C209 tx power issue #18

Closed stan-jelavic closed 1 year ago

stan-jelavic commented 1 year ago

The tags received from the factory work OK and track very nice. We wanted to be able to control the power level for several reasons such as to minimize the reflections and save battery but ran into this weird issue. When the TX power is set via AT+TXPWR=2 or 4 or 8 the board goes into a very low power mode. No matter what is written into the board, the power stays low. The antenna board can only see the tag if it is with inches from it. Here is the log where I am setting the power to 4. AT+TXPWR=4 OK Booting Zephyr OS build v2.4.99-ncs2-1

[00:00:00.014,923]  fs_nvs: 4 Sectors of 4096 bytes [00:00:00.014,923]  fs_nvs: alloc wra: 0, f40 [00:00:00.014,953]  fs_nvs: data wra: 0, 58 [00:00:00.014,953]  storage: NVS Init done [00:00:00.014,953]  app: InstanceId (MAC) 6c 1d eb a4 18 49 |l....I  [00:00:00.015,045]  buttons: Set up button at GPIO_0 pin 2 [00:00:00.017,578]  app: Bluetooth initialized [00:00:00.017,608]  app: Setting TxPower: 4 [00:00:00.017,761]  app: Set Tx Power: 4 [00:00:00.018,524]  bt_adv: adv started [00:00:00.018,646]  app: Started blink thread

jakkra commented 1 year ago

Hi thanks for raising this issue. I assume you pressed the reset button in your log after sending AT+TXPWR=4? I'll try to reproduce, just so I have the same setup as you, have you flashed the tags with the precompiled sw and flashed using the pre-flashed bootloader on the tags or compiled the sw yourself?

stan-jelavic commented 1 year ago

Thank you for a prompt reply. We tried a few builds. Tried flashing from here: https://github.com/u-blox/c209-aoa-tag/releases Then I did the build from here https://github.com/u-blox/c209-aoa-tag/ The results were the same -- First it was OK but after I tried a new power settings the tag went into low power permanently.

jakkra commented 1 year ago

Hi @stan-jelavic I have tried to reproduce but unfortunately unable to. I send the commands and then reset the C209 using the button after each AT+TXPWR=X Here's a plot where I changed the output power down and then back up again, plotted the RSSI on channel 37 on the C211 anchor. Capture-rssi

I added a command to read out the output power, here app-dfu-boot-with-read-txpwr.zip is a release build for you to test or you can compile this branch jkra_txpwr_issue_18

Can you flash this and see what your output is when you have low output power even if you have set it to something high. Send AT+TXPWR? to read back the output power.

stan-jelavic commented 1 year ago

I tried your build and read the power ok. AT+TXPWR=6 OK

Reset at this point

AT+TXPWR? +TXPWR:6 OK

This is what I get from the C211 at about a foot distance. Very low RSSI. +UUDF:6C1DEBA41849,-93,-6,18,-98,37,"6C1DEBA09A54","",62264 +UUDF:6C1DEBA41849,-84,18,18,-90,37,"6C1DEBA09A54","",62368 +UUDF:6C1DEBA41849,-85,16,20,-91,37,"6C1DEBA09A54","",62477 +UUDF:6C1DEBA41849,-92,18,4,-96,38,"6C1DEBA09A54","",62582 +UUDF:6C1DEBA41849,-89,6,6,-85,38,"6C1DEBA09A54","",63514 +UUDF:6C1DEBA41849,-89,58,-8,-85,39,"6C1DEBA09A54","",63938 +UUDF:6C1DEBA41849,-87,-56,-16,-85,39,"6C1DEBA09A54","",64043

A few questions: Is there a way of clearing out the NV ram. Does the build that you sent me use the patched radio.c for CTE?

jakkra commented 1 year ago

Does the build that you sent me use the patched radio.c for CTE?

Yes it's with the CTE patch as I can see my C211 giving angles that looks ok when I move the C209 tag.

Is there a way of clearing out the NV ram.

You can erase NVS if you have a j-link debugger and just erase the flash with JFlashLite for example and then flash back the SW according to the README. However I don't think NVS is the issue as you get a correct readback in AT+TXPWR? command. The only thing I can think of right now is if for some reason it fails to actually set the output power to the Bluetooth controller.

Here is a debug build which gives you logs on the UART, can you flash that and send me the log. app-with-read-txpwr-debug.zip

Look for this print set Tx Power successful:

[00:00:00.017,578] <inf> app: Bluetooth initialized
[00:00:00.017,608] <inf> app: Setting TxPower: 6
[00:00:00.017,761] <inf> app: Set Tx Power successful: 6
*** Booting Zephyr OS build v2.4.99-ncs1  ***

[00:00:00.014,923] <inf> fs_nvs: 4 Sectors of 4096 bytes
[00:00:00.014,923] <inf> fs_nvs: alloc wra: 0, f98
[00:00:00.014,953] <inf> fs_nvs: data wra: 0, 2c
[00:00:00.014,953] <inf> storage: NVS Init done
[00:00:00.014,953] <inf> app: InstanceId (MAC)
                              fa c1 d6 6e 15 42                                |...n.B           
[00:00:00.015,045] <inf> buttons: Set up button at GPIO_0 pin 2
[00:00:00.017,578] <inf> app: Bluetooth initialized
[00:00:00.017,608] <inf> app: Setting TxPower: 6
[00:00:00.017,761] <inf> app: Set Tx Power successful: 6
[00:00:00.018,524] <inf> bt_adv: adv started
[00:00:00.018,615] <inf> app: Started blink thread
AT+TXPWR?
+TXPWR:6
OK
AT+TXPWR=-20
OK
*** Booting Zephyr OS build v2.4.99-ncs1  ***

[00:00:00.014,923] <inf> fs_nvs: 4 Sectors of 4096 bytes
[00:00:00.014,923] <inf> fs_nvs: alloc wra: 0, f90
[00:00:00.014,923] <inf> fs_nvs: data wra: 0, 30
[00:00:00.014,953] <inf> storage: NVS Init done
[00:00:00.014,953] <inf> app: InstanceId (MAC)
                              fa c1 d6 6e 15 42                                |...n.B           
[00:00:00.015,045] <inf> buttons: Set up button at GPIO_0 pin 2
[00:00:00.017,578] <inf> app: Bluetooth initialized
[00:00:00.017,578] <inf> app: Setting TxPower: -20
[00:00:00.017,761] <inf> app: Set Tx Power successful: -20
[00:00:00.018,493] <inf> bt_adv: adv started
[00:00:00.018,615] <inf> app: Started blink thread
AT+TXPWR?
+TXPWR:-20
OK
AT+TXPWR=6
OK
*** Booting Zephyr OS build v2.4.99-ncs1  ***

[00:00:00.014,923] <inf> fs_nvs: 4 Sectors of 4096 bytes
[00:00:00.014,923] <inf> fs_nvs: alloc wra: 0, f88
[00:00:00.014,953] <inf> fs_nvs: data wra: 0, 34
[00:00:00.014,953] <inf> storage: NVS Init done
[00:00:00.014,953] <inf> app: InstanceId (MAC)
                              fa c1 d6 6e 15 42                                |...n.B           
[00:00:00.015,045] <inf> buttons: Set up button at GPIO_0 pin 2
[00:00:00.017,578] <inf> app: Bluetooth initialized
[00:00:00.017,608] <inf> app: Setting TxPower: 6
[00:00:00.017,761] <inf> app: Set Tx Power successful: 6
[00:00:00.018,524] <inf> bt_adv: adv started
[00:00:00.018,646] <inf> app: Started blink thread
AT+TXPWR?
+TXPWR:6
OK

Have you managed getting a tag from "stuck in low power" to good output power? If so what did you do? Do you have more than one tag? Same problem on them (i.e. antenna could not be damaged)?

stan-jelavic commented 1 year ago

We have several tags but tried one tag only. Possibly damaged tag for whatever reason. The other tags have the factory flashed code and work ok. Since we need the tags for testing we are reluctant to try changing the power. Will check if we can find another tag to test this. Your debug code gave me the same results as yours.

Booting Zephyr OS build v2.4.99-ncs1

[00:00:00.014,984]  fs_nvs: 4 Sectors of 4096 bytes [00:00:00.014,984]  fs_nvs: alloc wra: 0, f28 [00:00:00.015,014]  fs_nvs: data wra: 0, 64 [00:00:00.015,014]  storage: NVS Init done [00:00:00.015,014]  app: InstanceId (MAC) 6c 1d eb a4 18 49 |l....I  [00:00:00.015,106]  buttons: Set up button at GPIO_0 pin 2 [00:00:00.017,639]  app: Bluetooth initialized [00:00:00.017,669]  app: Setting TxPower: 4 [00:00:00.017,822]  app: Set Tx Power successful: 4 [00:00:00.018,585]  bt_adv: adv started [00:00:00.018,676]  app: Started blink thread AT+TXPWR? +TXPWR:4 OK AT+TXPWR=-20 OK Booting Zephyr OS build v2.4.99-ncs1

[00:00:00.014,953]  fs_nvs: 4 Sectors of 4096 bytes [00:00:00.014,953]  fs_nvs: alloc wra: 0, f20 [00:00:00.014,984]  fs_nvs: data wra: 0, 68 [00:00:00.014,984]  storage: NVS Init done [00:00:00.014,984]  app: InstanceId (MAC) 6c 1d eb a4 18 49 |l....I  [00:00:00.015,075]  buttons: Set up button at GPIO_0 pin 2 [00:00:00.017,608]  app: Bluetooth initialized [00:00:00.017,639]  app: Setting TxPower: -20 [00:00:00.017,791]  app: Set Tx Power successful: -20 [00:00:00.018,554]  bt_adv: adv started [00:00:00.018,676]  app: Started blink thread AT+TXPWR? +TXPWR:-20 OK AT+TXPWR=6 OK Booting Zephyr OS build v2.4.99-ncs1

[00:00:00.014,984]  fs_nvs: 4 Sectors of 4096 bytes [00:00:00.014,984]  fs_nvs: alloc wra: 0, f18 [00:00:00.014,984]  fs_nvs: data wra: 0, 6c [00:00:00.015,014]  storage: NVS Init done [00:00:00.015,014]  app: InstanceId (MAC) 6c 1d eb a4 18 49 |l....I  [00:00:00.015,106]  buttons: Set up button at GPIO_0 pin 2 [00:00:00.017,639]  app: Bluetooth initialized [00:00:00.017,669]  app: Setting TxPower: 6 [00:00:00.017,822]  app: Set Tx Power successful: 6 [00:00:00.018,585]  bt_adv: adv started [00:00:00.018,676]  app: Started blink thread AT+TXPWR? +TXPWR:6 OK

jakkra commented 1 year ago

@stan-jelavic Since output power seems to be set correctly down to Zephyr and with a no error response back, I'm leaning towards a HW issue on that tag. You can visually inspect the PCB antenna and compare it with a working C209 PCB antenna, check so none of the components on the PCB antenna are missing/looks damaged. If the PCB antenna looks good, then please try another tag.

stan-jelavic commented 1 year ago

Inspected the antenna cct under the microscope and discovered that one cap in the antenna cct was missing. After the fix the power came back. Thank you for your support.

jakkra commented 1 year ago

Inspected the antenna cct under the microscope and discovered that one cap in the antenna cct was missing. After the fix the power came back. Thank you for your support.

Great that you managed to solve it!