meshtastic 0.0.132 → 0.0.134
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/lib/meshtastic/mqtt.rb +26 -2
 - data/lib/meshtastic/version.rb +1 -1
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 2a019972ccb99e42fee81bb0b2f8a18d2c7c0223e579234a64239eb1f0d89652
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: b8882c221fb7d8faf2b927f596b78f54f9868917a8d5c6d889d31b1ab5114990
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 61346686f811a67bf81d68a94b3189aaf0b6232c59e0cbdbfba3cfaa6850284beec8f68616adbcbd92f3e88c8200f1134954bb40d25eed29303fb023b433b8ef
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 7fec0467aca8ad1ad68afdcb67ef206dc76499285282f802fee25f938335c6092cb29cb6c4720e74e8481be0235ce225fbd1616e548cba8cb0076cbd278e0698
         
     | 
    
        data/lib/meshtastic/mqtt.rb
    CHANGED
    
    | 
         @@ -278,10 +278,34 @@ module Meshtastic 
     | 
|
| 
       278 
278 
     | 
    
         
             
                  opts[:via] = :mqtt
         
     | 
| 
       279 
279 
     | 
    
         | 
| 
       280 
280 
     | 
    
         
             
                  # TODO: Implement chunked message to deal with large messages
         
     | 
| 
      
 281 
     | 
    
         
            +
                  raw_text = opts[:text].to_s
         
     | 
| 
      
 282 
     | 
    
         
            +
                  max_bytes = 232
         
     | 
| 
       281 
283 
     | 
    
         
             
                  mui = Meshtastic::MeshInterface.new
         
     | 
| 
       282 
     | 
    
         
            -
                  protobuf_text = mui.send_text(opts)
         
     | 
| 
       283 
284 
     | 
    
         | 
| 
       284 
     | 
    
         
            -
                   
     | 
| 
      
 285 
     | 
    
         
            +
                  if raw_text.bytesize > max_bytes
         
     | 
| 
      
 286 
     | 
    
         
            +
                    chunks = []
         
     | 
| 
      
 287 
     | 
    
         
            +
                    current_chunk = ''
         
     | 
| 
      
 288 
     | 
    
         
            +
                    raw_text.each_char do |char|
         
     | 
| 
      
 289 
     | 
    
         
            +
                      if (current_chunk + char).bytesize > max_bytes
         
     | 
| 
      
 290 
     | 
    
         
            +
                        chunks.push(current_chunk)
         
     | 
| 
      
 291 
     | 
    
         
            +
                        current_chunk = char
         
     | 
| 
      
 292 
     | 
    
         
            +
                      else
         
     | 
| 
      
 293 
     | 
    
         
            +
                        current_chunk += char
         
     | 
| 
      
 294 
     | 
    
         
            +
                      end
         
     | 
| 
      
 295 
     | 
    
         
            +
                    end
         
     | 
| 
      
 296 
     | 
    
         
            +
                    chunks.push(current_chunk) unless current_chunk.empty?
         
     | 
| 
      
 297 
     | 
    
         
            +
             
     | 
| 
      
 298 
     | 
    
         
            +
                    total_chunks = chunks.length
         
     | 
| 
      
 299 
     | 
    
         
            +
                    chunks.each_with_index do |chunk, index|
         
     | 
| 
      
 300 
     | 
    
         
            +
                      opts[:text] = chunk
         
     | 
| 
      
 301 
     | 
    
         
            +
                      opts[:text] = "[#{index + 1}/#{total_chunks}] #{chunk}"
         
     | 
| 
      
 302 
     | 
    
         
            +
                      protobuf_chunk = mui.send_text(opts)
         
     | 
| 
      
 303 
     | 
    
         
            +
                      push(mqtt_obj.publish(absolute_topic, protobuf_chunk))
         
     | 
| 
      
 304 
     | 
    
         
            +
                    end
         
     | 
| 
      
 305 
     | 
    
         
            +
                  else
         
     | 
| 
      
 306 
     | 
    
         
            +
                    protobuf_text = mui.send_text(opts)
         
     | 
| 
      
 307 
     | 
    
         
            +
                    mqtt_obj.publish(absolute_topic, protobuf_text)
         
     | 
| 
      
 308 
     | 
    
         
            +
                  end
         
     | 
| 
       285 
309 
     | 
    
         
             
                rescue StandardError => e
         
     | 
| 
       286 
310 
     | 
    
         
             
                  raise e
         
     | 
| 
       287 
311 
     | 
    
         
             
                end
         
     | 
    
        data/lib/meshtastic/version.rb
    CHANGED