smlparser.h
bool parseMessageBody(int pos) {
      getLength(pos);            // Skip list identifier of message
      uint16_t message = (uint16_t)getNextIntValue(pos);
      if (message != SML_GET_LIST_RES) {
         return false;
      }
      getLength(pos);            // Skip list identifier of message body
      getNextElement(pos, 4);    // Skip first 4 entries of GET_LIST_RES message
      int listElements = getLength(pos);
      for (int i = 0; i < listElements; ++i) {
         getLength(pos);         // Skip the list identifier of the SML_LIST_ENTRY
         pos += 3;               // Skip the beginning of the value-identifier
         uint8_t index = _pPacket[pos++];
         uint8_t type = _pPacket[pos++];
         uint8_t tariff = _pPacket[pos++];
         ++pos;                  // Skip next value
         getNextElement(pos, 2);  // Skip status and timestamp
         getNextIntValue(pos);      // Skip unit
         int8_t scale = (int8_t)getNextIntValue(pos);
         int64_t value = (int64_t)getNextIntValue(pos);
         getNextElement(pos);    // Skip signature

         // Store the value in fields
         if ((tariff == OBIS_TARIFF) && (scale >= SML_MIN_SCALE) && (scale <= SML_MAX_SCALE)) {
            value *= SCALE_FACTORS[scale - SML_MIN_SCALE];
            switch (type) {
            case OBIS_INSTANTANEOUS_POWER_TYPE:
               switch (index) {
               case OBIS_POSITIVE_ACTIVE_POWER:
                  _powerInW = (uint32_t)value;
                  break;
               case OBIS_NEGATIVE_ACTIVE_POWER:
                  _powerOutW = (uint32_t)value;;
                  break;
               case OBIS_SUM_ACTIVE_POWER:
                  _powerInW = (uint32_t)(value >= 0 ? value : 0U);
                  _powerOutW = (uint32_t)(value <= 0 ? -value : 0U);
                  break;
               }
               break;

            case OBIS_ENERGY_TYPE:
               switch (index) {
               case OBIS_POSITIVE_ACTIVE_POWER:
                  _energyInWh = (uint64_t)value;
                  break;
               case OBIS_NEGATIVE_ACTIVE_POWER:
                  _energyOutWh = (uint64_t)value;
                  break;
               }
               break;
            }
         }
      }
      return true;
   }
/**
    * @brief Parse the message body and store parsed information
    * @param pos  Position in the packet
    */
@brief Parse the message body and store parsed information
@param pos  Position in the packet
@brief Parse the message body and store parsed information @param pos Position in the packet
bool parseMessageBody(int pos) {
      getLength(pos);            
      uint16_t message = (uint16_t)getNextIntValue(pos);
      if (message != SML_GET_LIST_RES) {
         return false;
      }
      getLength(pos);             body
      getNextElement(pos, 4);    
      int listElements = getLength(pos);
      for (int i = 0; i < listElements; ++i) {
         getLength(pos);         
         pos += 3;               
         uint8_t index = _pPacket[pos++];
         uint8_t type = _pPacket[pos++];
         uint8_t tariff = _pPacket[pos++];
         ++pos;                  
         getNextElement(pos, 2);  
         getNextIntValue(pos);      
         int8_t scale = (int8_t)getNextIntValue(pos);
         int64_t value = (int64_t)getNextIntValue(pos);
         getNextElement(pos);    
         if ((tariff == OBIS_TARIFF) && (scale >= SML_MIN_SCALE) && (scale <= SML_MAX_SCALE)) {
            value *= SCALE_FACTORS[scale - SML_MIN_SCALE];
            switch (type) {
            case OBIS_INSTANTANEOUS_POWER_TYPE:
               switch (index) {
               case OBIS_POSITIVE_ACTIVE_POWER:
                  _powerInW = (uint32_t)value;
                  break;
               case OBIS_NEGATIVE_ACTIVE_POWER:
                  _powerOutW = (uint32_t)value;;
                  break;
               case OBIS_SUM_ACTIVE_POWER:
                  _powerInW = (uint32_t)(value >= 0 ? value : 0U);
                  _powerOutW = (uint32_t)(value <= 0 ? -value : 0U);
                  break;
               }
               break;
            case OBIS_ENERGY_TYPE:
               switch (index) {
               case OBIS_POSITIVE_ACTIVE_POWER:
                  _energyInWh = (uint64_t)value;
                  break;
               case OBIS_NEGATIVE_ACTIVE_POWER:
                  _energyOutWh = (uint64_t)value;
                  break;
               }
               break;
            }
         }
      }
      return true;
   }
bool parseMessageBody ( int pos ) { getLength ( pos ) ; uint16_t message = ( uint16_t ) getNextIntValue ( pos ) ; if ( message != SML_GET_LIST_RES ) { return false ; } getLength ( pos ) ; getNextElement ( pos , 4 ) ; int listElements = getLength ( pos ) ; for ( int i = 0 ; i < listElements ; ++ i ) { getLength ( pos ) ; pos += 3 ; uint8_t index = _pPacket [ pos ++ ] ; uint8_t type = _pPacket [ pos ++ ] ; uint8_t tariff = _pPacket [ pos ++ ] ; ++ pos ; getNextElement ( pos , 2 ) ; getNextIntValue ( pos ) ; int8_t scale = ( int8_t ) getNextIntValue ( pos ) ; int64_t value = ( int64_t ) getNextIntValue ( pos ) ; getNextElement ( pos ) ; if ( ( tariff == OBIS_TARIFF ) && ( scale >= SML_MIN_SCALE ) && ( scale <= SML_MAX_SCALE ) ) { value *= SCALE_FACTORS [ scale - SML_MIN_SCALE ] ; switch ( type ) { case OBIS_INSTANTANEOUS_POWER_TYPE : switch ( index ) { case OBIS_POSITIVE_ACTIVE_POWER : _powerInW = ( uint32_t ) value ; break ; case OBIS_NEGATIVE_ACTIVE_POWER : _powerOutW = ( uint32_t ) value ; ; break ; case OBIS_SUM_ACTIVE_POWER : _powerInW = ( uint32_t ) ( value >= 0 ? value : 0U ) ; _powerOutW = ( uint32_t ) ( value <= 0 ? - value : 0U ) ; break ; } break ; case OBIS_ENERGY_TYPE : switch ( index ) { case OBIS_POSITIVE_ACTIVE_POWER : _energyInWh = ( uint64_t ) value ; break ; case OBIS_NEGATIVE_ACTIVE_POWER : _energyOutWh = ( uint64_t ) value ; break ; } break ; } } } return true ; }
@brief Parse the message body and store parsed information
 @param pos  Position in the packet
@brief Parse the message body and store parsed information @param pos Position in the packet
// Skip list identifier of message // Skip list identifier of message body // Skip first 4 entries of GET_LIST_RES message // Skip the list identifier of the SML_LIST_ENTRY // Skip the beginning of the value-identifier // Skip next value // Skip status and timestamp // Skip unit // Skip signature // Store the value in fields