[ 
https://issues.apache.org/jira/browse/MYNEWT-881?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16365394#comment-16365394
 ] 

ASF GitHub Bot commented on MYNEWT-881:
---------------------------------------

rymanluk commented on a change in pull request #718: MYNEWT-881: SensorAPI: Add 
sensor_unset_thresh() API and LIS2DH12 set threshold cb fix
URL: https://github.com/apache/mynewt-core/pull/718#discussion_r168437966
 
 

 ##########
 File path: hw/sensor/src/sensor.c
 ##########
 @@ -1922,6 +1922,59 @@ sensor_set_thresh(char *devname, struct 
sensor_type_traits *stt)
     return rc;
 }
 
+/**
+ * Unset the thresholds and comparison algo for a sensor
+ *
+ * @param name of the sensor
+ * @param Ptr to sensor threshold
+ *
+ * @return 0 on success, non-zero on failure
+ */
+int
+sensor_unset_thresh(char *devname, struct sensor_type_traits *stt)
+{
+    struct sensor *sensor;
+    struct sensor_type_traits *stt_tmp;
+    int rc;
+
+    if (!stt) {
+        rc = SYS_EINVAL;
+        goto err;
+    }
+
+    sensor = sensor_get_type_traits_byname(devname, &stt_tmp,
+                                           stt->stt_sensor_type);
+    if (!sensor) {
 
 Review comment:
   maybe if (!sensor || !stt_tmp) {}
   
   btw why we care about stt_tmp since this is not used?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> SensorAPI: Add sensor_unset_thresh() API and LIS2DH12 set threshold cb fix
> --------------------------------------------------------------------------
>
>                 Key: MYNEWT-881
>                 URL: https://issues.apache.org/jira/browse/MYNEWT-881
>             Project: Mynewt
>          Issue Type: Improvement
>      Security Level: Public(Viewable by anyone) 
>          Components: Drivers, Sensor Framework
>    Affects Versions: v1_3_0_rel
>         Environment: ruuvitag-revb2
>            Reporter: Vipul Rahane
>            Assignee: Vipul Rahane
>            Priority: Major
>              Labels: core
>             Fix For: v1_4_0_rel
>
>
> There are two issues for calling the lis2dh12_sensor_set_trigger_thresh() :
> 1. gpio irq was not being released before doing a re-initialization
>  2. srec was malloced and calling the function multiple times would have 
> malloced additional memory without freeing it.
> Solution:
>  1. Release the gpio irq
>  2. Remove the malloc and add a ptr for the sensor in each type trait so that 
> a sensor read could be performed in the irq handler.
> Also, sensor_unset_thresh() API was added to unset thresholds 
> triggers/interrupts.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to