title: Read ble values and update livedata/recyclerview list
body: <p>I have an Android application, that reads Bluetooth values from a device. I present these values in a recyclerView. I would like to find a way to update this list and i feel abit lost since i tried diffrent solutions that i found on google.</p>
  <p>I really dont know if it's my recyclerView thats the issue or my livedata Observer that is not getting triggerd. When i try to read the values again the list disappears, but i can see in my logs that there is a new list of values comming from the viewmodel</p>
  <p>The app runs as i intended the first iteration.</p>
  <p>I can provide more code if needed</p>
  <p>Sharing some code for extra clarity</p>
  <p>Here i read the values where i retrive a byteArray.</p>
  <pre><code>ReadLineNodeValues().iRObjectTemperature -&gt; {
                          bleListViewModel.addBleToList(characteristic.value)
  } 
  </code></pre>
  <p>Which i send to my ViewModel here</p>
  <pre><code>
  class BleValueViewModel: ViewModel() {
  
      fun addBleToList(bleValue: ByteArray) {
              blueToothLEvalue.add(bleValue)
              mutableLiveDataBluetooth.postValue(blueToothLEvalue)
      }
  
      fun getList(): MutableLiveData&lt;ArrayList&lt;ByteArray&gt;&gt; {
          return mutableLiveDataBluetooth
      }
  
  
  </code></pre>
  <p>Here i trying to retrive the list where i add it to my recyclverView</p>
  <pre><code> private fun showItems() {
          val bleValueViewModel = ViewModelProvider(requireActivity()).get(BleValueViewModel::class.java)
          bleValueViewModel.getList().observe(viewLifecycleOwner) {
              if (it.size == 26) {
                  showlist(it)
              }
          }
      }
  
  </code></pre>
  <p>RecyclerView</p>
  <pre><code>
  class LineNodeValueDataAdapter :
      RecyclerView.Adapter&lt;LineNodeBigViewHolder&gt;() {
  
      private val differCallback = object : DiffUtil.ItemCallback&lt;LinenNodeValueData&gt;() {
          override fun areItemsTheSame(
              oldItem: LinenNodeValueData,
              newItem: LinenNodeValueData
          ): Boolean {
              return oldItem.valueOne == newItem.valueOne &amp;&amp; oldItem.valueTwo == newItem.valueTwo &amp;&amp; oldItem.valueThree == newItem.valueThree &amp;&amp; oldItem.valueFour == newItem.valueFour
          }
  
          override fun areContentsTheSame(
              oldItem: LinenNodeValueData,
              newItem: LinenNodeValueData
          ): Boolean {
              return oldItem == newItem
          }
      }
  
       val differ = AsyncListDiffer(this, differCallback)
  
  
      override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): LineNodeBigViewHolder {
  
          val binding = CardviewListlayoutValueBinding
              .inflate(LayoutInflater.from(parent.context), parent, false)
  
          return LineNodeBigViewHolder(binding)
      }
  
      override fun onBindViewHolder(holder: LineNodeBigViewHolder, position: Int) {
          val place = differ.currentList[position]
          holder.bind(place)
  
      }
  
      override fun getItemCount(): Int = differ.currentList.size
  
  
  }
  </code></pre>
  <p>I convert the values since they all come as ByteArrays</p>
  <pre><code>
     fun showlist(listValues: MutableList&lt;ByteArray&gt;) {
  
          //Systemnode
          val systemNodeMCUTemp = String(listValues[0])
          val systemNodeVoltages = String(listValues[1])
          val systemNodeWeatherSensor = String(listValues[2])
          val systemNodeOpenThreadCfg = String(listValues[3])
          //Linenode
          val currentLineNode = String(listValues[4])
  
          val acceleroMeterX = ByteBuffer.wrap(listValues[5]).order(ByteOrder.LITTLE_ENDIAN).float
          val acceleroMeterY = ByteBuffer.wrap(listValues[6]).order(ByteOrder.LITTLE_ENDIAN).float
          val acceleroMeterZ = ByteBuffer.wrap(listValues[7]).order(ByteOrder.LITTLE_ENDIAN).float
          val iRObjectTemperature =
              ByteBuffer.wrap(listValues[8]).order(ByteOrder.LITTLE_ENDIAN).float
          val contactSensorTemperature =
              ByteBuffer.wrap(listValues[9]).order(ByteOrder.LITTLE_ENDIAN).float
          val magneticField = ByteBuffer.wrap(listValues[10]).order(ByteOrder.LITTLE_ENDIAN).float
          val internalVoltage1V8 =
              ByteBuffer.wrap(listValues[11]).order(ByteOrder.LITTLE_ENDIAN).float
          val internalVoltagevBusRail =
              ByteBuffer.wrap(listValues[12]).order(ByteOrder.LITTLE_ENDIAN).float
          val internalVoltageVDD =
              ByteBuffer.wrap(listValues[13]).order(ByteOrder.LITTLE_ENDIAN).float
          val internalVoltageVDDH =
              ByteBuffer.wrap(listValues[14]).order(ByteOrder.LITTLE_ENDIAN).float
          
          val powerHarvestingVoltageSol1 =
              ByteBuffer.wrap(listValues[15]).order(ByteOrder.LITTLE_ENDIAN).float
          val powerHarvestingVoltageSol2 =
              ByteBuffer.wrap(listValues[16]).order(ByteOrder.LITTLE_ENDIAN).float
  
          val powerHarvestingVoltageEmppt =
              ByteBuffer.wrap(listValues[17]).order(ByteOrder.LITTLE_ENDIAN).float
          val powerHarvestingVoltageHmppt =
              ByteBuffer.wrap(listValues[18]).order(ByteOrder.LITTLE_ENDIAN).float
  
          val eHFieldHField =
              ByteBuffer.wrap(listValues[19]).order(ByteOrder.LITTLE_ENDIAN).float
  
          val eHFieldEField =
              ByteBuffer.wrap(listValues[20]).order(ByteOrder.LITTLE_ENDIAN).float
  
          val ambientTemperaturesAcc =
              ByteBuffer.wrap(listValues[21]).order(ByteOrder.LITTLE_ENDIAN).float
  
          val ambientTemperaturesIR =
              ByteBuffer.wrap(listValues[22]).order(ByteOrder.LITTLE_ENDIAN).float
  
          val ambientTemperaturesMag =
              ByteBuffer.wrap(listValues[23]).order(ByteOrder.LITTLE_ENDIAN).float
  
          val ambientTemperaturesMCU =
              ByteBuffer.wrap(listValues[24]).order(ByteOrder.LITTLE_ENDIAN).float
  
          val openThreadCFG =
              ByteBuffer.wrap(listValues[25]).order(ByteOrder.LITTLE_ENDIAN).float
  
          val systemNodeList = ArrayList&lt;SystemValue&gt;()
          systemNodeList.add(SystemValue(&quot;Systemode MguTemp&quot;, systemNodeMCUTemp))
          systemNodeList.add(SystemValue(&quot;Systemnode Voltages&quot;, systemNodeVoltages))
          systemNodeList.add(SystemValue(&quot;Systemnode WeatherSensor&quot;, systemNodeWeatherSensor))
          systemNodeList.add(SystemValue(&quot;Systemnode OpenThreadCfg&quot;, systemNodeOpenThreadCfg))
  
          val lineNodevaluelist = ArrayList&lt;LinenNodeValueData&gt;()
  
          val lineNodeListBle = ArrayList&lt;SystemValue&gt;()
          lineNodeListBle.add(SystemValue(&quot;LineNode Service&quot;, currentLineNode))
          lineNodeListBle.add(SystemValue(&quot;Current LineNode&quot;, acceleroMeterX.toString()))
          //lineNodeListBle.add(SystemValue(&quot;Acclero meter&quot;, lineNodeValueSeven.toString()))
          Timber.i(&quot;Acclerometer2 :: ${acceleroMeterY}}&quot;)
  
          lineNodeListBle.add(
              SystemValue(
                  &quot;Accelero Meter&quot;,
                  &quot;X: $acceleroMeterX &quot; + &quot;Y:  $acceleroMeterY&quot;
                          + &quot; Z: $acceleroMeterZ&quot;
              )
          )
  
          lineNodeListBle.add(
              SystemValue(
                  &quot;iRObject Temperature&quot;,
                  iRObjectTemperature.toString()
              )
          )
          lineNodeListBle.add(
              SystemValue(
                  &quot;ContactSensor Temperature&quot;,
                  contactSensorTemperature.toString()
              )
          )
          lineNodeListBle.add(SystemValue(&quot;Magnetic Field&quot;, magneticField.toString()))
          lineNodevaluelist.add(
              LinenNodeValueData(
                  &quot;Internal Voltage&quot;,
                  &quot;1V8: $internalVoltage1V8&quot;,
                  &quot;Vbus rail: $internalVoltagevBusRail&quot;,
                  &quot;VDD: $internalVoltageVDD&quot;,
                  &quot;VDDH: $internalVoltageVDDH&quot;
              )
          )
          lineNodevaluelist.add(
              LinenNodeValueData(
                  &quot;Power Harvesting Voltage&quot;,
                  &quot;Sol1: $powerHarvestingVoltageSol1&quot;,
                  &quot;Sol2: $powerHarvestingVoltageSol2&quot;,
                  &quot;E-Mppt: $powerHarvestingVoltageEmppt&quot;, &quot;H-Mppt: $powerHarvestingVoltageHmppt&quot;
              )
          )
          lineNodeListBle.add(
              SystemValue(
                  &quot;eHField&quot;,
                  &quot;H-field: $eHFieldHField E-field: $eHFieldEField&quot;
              )
          )
          lineNodevaluelist.add(
              LinenNodeValueData(
                  &quot;Ambient Temperatures&quot;,
                  &quot;Acc: $ambientTemperaturesAcc&quot;,
                  &quot;IR: $ambientTemperaturesIR&quot;,
                  &quot;Mag: $ambientTemperaturesMag&quot;,
                  &quot;Mcu: $ambientTemperaturesMCU&quot;
              )
          )
          lineNodeListBle.add(SystemValue(&quot;openThreadCFG&quot;, openThreadCFG.toString()))
  
          setupRecyclerViewSystemNode(binding.systemNodeRecyclerView, systemNodeList)
          Timber.i(&quot;blueviewRecycler :: ${systemNodeList.size}&quot;)
          setupRecylerViewLineNodeOne(binding.lineNodeRecyclerView, lineNodeListBle, lineNodevaluelist)
          Timber.i(&quot;blueviewRecycler1 :: ${lineNodeListBle.size}+${lineNodevaluelist.size}&quot;)
      }
  </code></pre>
  <p>Have a nice day everyone
  Kind regards
  Droid</p>