# Poor Signal Quality and Air Vantage Data Costs

**URL:** <https://mangoh.discourse.group/t/poor-signal-quality-and-air-vantage-data-costs/2636>\
**Category:** Cloud & Connectivity\
**Created:** [May 14, 2019, 5:37am UTC](https://mangoh.discourse.group/t/poor-signal-quality-and-air-vantage-data-costs/2636 "2019-05-14T05:37:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dbeckwith](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dbeckwith/32/2139_2.png) [@dbeckwith](https://mangoh.discourse.group/u/dbeckwith)\
**Post date:** [May 14, 2019, 5:37am UTC](https://mangoh.discourse.group/t/poor-signal-quality-and-air-vantage-data-costs/2636/1 "2019-05-14T05:37:20Z")

</div>

I have a modified version of `RedSensorToCloud` which retries a data connection every 5 minutes if `LE_AVDATA_SESSION_STOPPED` occurs. This seems to be generating a lot of connection device registrations on Air Vantage when the cellular connection is poor (IE 1 bar).

What is the best way to avoid this additional cost? I’m thinking it would be better to check the cell signal level and only attempt a session if the signal level is above a threshold after some number of attempts but I’m not sure if this makes sense.

Thoughts?

Thanks,  
Darren

---

<div class="post-metadata">

**Author:** ![asyal](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/asyal/32/78_2.png) [@asyal](https://mangoh.discourse.group/u/asyal)\
**Post date:** [May 14, 2019, 3:54pm UTC](https://mangoh.discourse.group/t/poor-signal-quality-and-air-vantage-data-costs/2636/2 "2019-05-14T15:54:04Z")

</div>

> [@dbeckwith](#):
>
> What is the best way to avoid this additional cost? I’m thinking it would be better to check the cell signal level and only attempt a session if the signal level is above a threshold after some number of attempts but I’m not sure if this makes sense.

Hi Darren,

Can you look at the following Legato API:

> **[le\_mrc\_interface.h - Legato Docs](https://docs.legato.io/19_01/le __mrc__ interface_8h_source.html)**
>
> legato™ is an open source Linux-based embedded platform designed to simplify connected IoT application development

specifically you can look at →

1. le\_mrc\_MeasureSignalMetrics()
2. For e.g. for GSM : le\_mrc\_GetGsmSignalMetrics(metricsRef, &rxLevel, &er);

This should help you get the signal strength and then make a decision based on that.  
Does that help?

cheers,  
Ashish

---

<div class="post-metadata">

**Author:** ![dbeckwith](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dbeckwith/32/2139_2.png) [@dbeckwith](https://mangoh.discourse.group/u/dbeckwith)\
**Post date:** [May 14, 2019, 4:05pm UTC](https://mangoh.discourse.group/t/poor-signal-quality-and-air-vantage-data-costs/2636/3 "2019-05-14T16:05:54Z")

</div>

@asyal Yes, that helps and I stumbled on this late last night in this post [https://forum.legato.io/t/airvantage-data-push-stops-after-some-time/3450/2](https://forum.legato.io/t/airvantage-data-push-stops-after-some-time/3450/2)

Would you recommend these checks are performed before a call to `le_avdata_RequestSession`? We have had some problems with the data session not reconnecting unless we reboot the modem is this normal or should we be able to restart the app and acquire a data connection again?

Also does the modem automatically try and connect to the cellular network once it boots? Are they docs that talk about this behaviour?

Thanks,  
Darren

---

<div class="post-metadata">

**Author:** ![Prush](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/prush/32/1398_2.png) [@Prush](https://mangoh.discourse.group/u/Prush)\
**Post date:** [May 14, 2019, 5:50pm UTC](https://mangoh.discourse.group/t/poor-signal-quality-and-air-vantage-data-costs/2636/4 "2019-05-14T17:50:28Z")

</div>

Hi Darren, You don’t have to reboot the modem to reestablish the cellular connection. You should be able to reconnect if you release the session and request session again. A quick way to check cellular connection is also by using the ‘cm tool’. Use commands ‘cm radio’, ‘cm data’. Typically after a boot the device will connect to the cellular network but you have to request a data connect explicitly.

**Right after boot**  
root@swi-mdm9x28-wp:~# cm data  
Index: 1  
APN: ltemobile.apn  
PDP Type: IPV4  
Connected: no  
root@swi-mdm9x28-wp:~# cm radio  
Power: ON  
Current Network Operator: Rogers Wireless  
Current RAT: GSM network (LE\_MRC\_RAT\_GSM)  
Status: Registered, home network (LE\_MRC\_REG\_HOME)  
Signal: Very strong signal strength (5)  
PS: Packet Switched Registered, home network (LE\_MRC\_REG\_HOME)

**Explicit data connection**  
root@swi-mdm9x28-wp:~# cm data connect  
Setting up profile 1  
Connecting … ok  
Checking if device ‘rmnet\_data0’ is up … ok  
Routing inet … ok  
mv: can’t remove ‘/etc/resolv.conf’: Device or resource busy  
Updating /etc/resolv.conf … ok  
Updating /etc/resolv.conf … ok  
Testing connection … ok  
root@swi-mdm9x28-wp:~# cm data  
Index: 1  
APN: ltemobile.apn  
PDP Type: IPV4  
Connected: yes  
Interface: rmnet\_data0  
Family[IPv4]: inet  
IP[IPv4]: 25.167.7.155  
Gateway[IPv4]: 25.167.7.156  
Dns1[IPv4]: 64.71.255.254  
Dns2[IPv4]: 64.71.255.253  
root@swi-mdm9x28-wp:~#

---

<div class="post-metadata">

**Author:** ![dbeckwith](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dbeckwith/32/2139_2.png) [@dbeckwith](https://mangoh.discourse.group/u/dbeckwith)\
**Post date:** [May 14, 2019, 6:11pm UTC](https://mangoh.discourse.group/t/poor-signal-quality-and-air-vantage-data-costs/2636/5 "2019-05-14T18:11:01Z")

</div>

@Prush

Thanks for the help and the pointers about the `cm` tool. I noticed while I was debugging today that `le_avdata_RequestSession` seems to return a non-null reference even when cm radio indicated no network connection. Is this normal?

Sounds like `le_avdata_ReleaseSession()` should be called if `le_avdata_RequestSession` returned a non-null reference, correct.

Thanks,  
Darren

---

<div class="post-metadata">

**Author:** ![Prush](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/prush/32/1398_2.png) [@Prush](https://mangoh.discourse.group/u/Prush)\
**Post date:** [May 14, 2019, 7:28pm UTC](https://mangoh.discourse.group/t/poor-signal-quality-and-air-vantage-data-costs/2636/6 "2019-05-14T19:28:08Z")

</div>

Most cases you will get a non-null reference unless the service ran out of resources. Getting a non-null reference doesn’t imply you have a connection to the server. You still have to wait for events from avc service.

Look at the sample in:

> <https://github.com/legatoproject/legato-af/blob/master/apps/sample/assetData/assetDataComponent/main.c>

avcStatusHandler() will notify your app when the connection goes up/down.

When your app doesn’t need avdata connection you can call le\_avdata\_ReleaseSession(). When all clients release their sessions avms connection will be torn down.

The dependency for avc app is “avc -\> data connection service -\> modem service”.  
The cm tool is a debug tool which interacts directly with modem. You cannot compare events from modem service to events from avc.

For example, when avc indicates a connection is up, you can check the and rmnet interface and ip by running ‘cm data’. But when avc indicates that the avms connection is down, you might still see rmnet interface and ip depedning on if other app is using that channel.

---

<div class="post-metadata">

**Author:** ![dbeckwith](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dbeckwith/32/2139_2.png) [@dbeckwith](https://mangoh.discourse.group/u/dbeckwith)\
**Post date:** [May 14, 2019, 9:15pm UTC](https://mangoh.discourse.group/t/poor-signal-quality-and-air-vantage-data-costs/2636/7 "2019-05-14T21:15:00Z")

</div>

@Prush

Thanks for the sample code reference but I’m not sure how similar this app is to our sensorToCloud app. The AssetData app purposely stops sending data after 10 minutes.

Our app opens a data connection and then keeps trying that data connection (every 5 minutes) if the response handler isn’t called. After 10 minutes it gives up and reboots.

I’m trying illuminate the reboots and at the same time optimize LWM2M session data costs. So I better understand.

1. Is it best practice to setup and tear down a data session or should a data sessions be setup for as long as possible?
2. Should `le_avdata_ReleaseSession` be called before attempting to call `le_avdata_RequestSession` if the first call to `le_avdata_RequestSession` returned a non-null reference?

Answer to 2: Looking at avcData.c in avcDaemon `le_avdata_RequestSession` will return the existing reference if it’s a duplicate request. So no need to release the session before trying again.

Thanks,  
Darren

---

<div class="post-metadata">

**Author:** ![Prush](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/prush/32/1398_2.png) [@Prush](https://mangoh.discourse.group/u/Prush)\
**Post date:** [May 14, 2019, 9:38pm UTC](https://mangoh.discourse.group/t/poor-signal-quality-and-air-vantage-data-costs/2636/8 "2019-05-14T21:38:27Z")

</div>

Here is my opinion:  
#1) It is best if you can tear down session if you know for sure you don’t need it for a long time. To save power. But if you transfer every 5 minutes it may be better to keep data session up all the time to save bandwidth.  
#2) Yes, le\_avdata\_ReleaseSession() should be called
