acassis commented on code in PR #19129:
URL: https://github.com/apache/nuttx/pull/19129#discussion_r3409482312


##########
arch/arm/src/nrf91/nrf91_modem_sock.c:
##########
@@ -606,6 +606,104 @@ static int nrf91_modem_actpdn(FAR lte_apn_setting_t *apn,
   return OK;
 }
 
+/****************************************************************************
+ * Name: nrf91_modem_bits
+ *
+ * Description:
+ *   Format the low 'nbits' of 'value' as a binary string (MSB first), as
+ *   used by the 3GPP timer fields of AT+CPSMS and AT+CEDRXS.
+ *

Review Comment:
   Please add the function parameters and return



##########
arch/arm/src/nrf91/nrf91_modem_sock.c:
##########
@@ -606,6 +606,104 @@ static int nrf91_modem_actpdn(FAR lte_apn_setting_t *apn,
   return OK;
 }
 
+/****************************************************************************
+ * Name: nrf91_modem_bits
+ *
+ * Description:
+ *   Format the low 'nbits' of 'value' as a binary string (MSB first), as
+ *   used by the 3GPP timer fields of AT+CPSMS and AT+CEDRXS.
+ *
+ ****************************************************************************/
+
+static void nrf91_modem_bits(uint8_t value, int nbits, FAR char *out)
+{
+  int i;
+
+  for (i = 0; i < nbits; i++)
+    {
+      out[i] = (value & (1 << (nbits - 1 - i))) ? '1' : '0';
+    }
+
+  out[nbits] = '\0';
+}
+
+/****************************************************************************
+ * Name: nrf91_modem_setpsm
+ *
+ * Description:
+ *   Apply PSM settings (LTE_CMDID_SETPSM) by translating the LAPI
+ *   lte_psm_setting_t into the AT+CPSMS command.
+ *

Review Comment:
   Ditto



##########
arch/arm/src/nrf91/nrf91_modem_sock.c:
##########
@@ -606,6 +606,104 @@ static int nrf91_modem_actpdn(FAR lte_apn_setting_t *apn,
   return OK;
 }
 
+/****************************************************************************
+ * Name: nrf91_modem_bits
+ *
+ * Description:
+ *   Format the low 'nbits' of 'value' as a binary string (MSB first), as
+ *   used by the 3GPP timer fields of AT+CPSMS and AT+CEDRXS.
+ *
+ ****************************************************************************/
+
+static void nrf91_modem_bits(uint8_t value, int nbits, FAR char *out)
+{
+  int i;
+
+  for (i = 0; i < nbits; i++)
+    {
+      out[i] = (value & (1 << (nbits - 1 - i))) ? '1' : '0';
+    }
+
+  out[nbits] = '\0';
+}
+
+/****************************************************************************
+ * Name: nrf91_modem_setpsm
+ *
+ * Description:
+ *   Apply PSM settings (LTE_CMDID_SETPSM) by translating the LAPI
+ *   lte_psm_setting_t into the AT+CPSMS command.
+ *
+ ****************************************************************************/
+
+static int nrf91_modem_setpsm(FAR lte_psm_setting_t *psm)
+{
+  /* LAPI timer-unit enums -> 3GPP encoded unit bits (TS 24.008 GPRS timers).
+   * T3412 extended (periodic TAU) and T3324 (active time).
+   */
+
+  static const uint8_t t3412[] =
+    {
+      3, 4, 5, 0, 1, 2, 6, 7  /* 2s,30s,1m,10m,1h,10h,320h,deact */
+    };
+
+  static const uint8_t t3324[] =
+    {
+      0, 1, 2, 7              /* 2s,1m,6m,deact */
+    };
+
+  char tau[9];
+  char act[9];
+  uint8_t b;
+
+  if (!psm->enable)
+    {
+      return nrf_modem_at_printf("AT+CPSMS=0");
+    }
+
+  b = (uint8_t)((t3412[psm->ext_periodic_tau_time.unit & 0x7] << 5) |
+                (psm->ext_periodic_tau_time.time_val & 0x1f));
+  nrf91_modem_bits(b, 8, tau);
+
+  b = (uint8_t)((t3324[psm->req_active_time.unit & 0x3] << 5) |
+                (psm->req_active_time.time_val & 0x1f));
+  nrf91_modem_bits(b, 8, act);
+
+  return nrf_modem_at_printf("AT+CPSMS=1,,,\"%s\",\"%s\"", tau, act);
+}
+
+/****************************************************************************
+ * Name: nrf91_modem_setedrx
+ *
+ * Description:
+ *   Apply eDRX settings (LTE_CMDID_SETEDRX) by translating the LAPI
+ *   lte_edrx_setting_t into the AT+CEDRXS command.
+ *

Review Comment:
   Ditto



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to