meshtastic 0.0.133 → 0.0.135
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 +11 -18
 - 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: b2450abd9bb6ac40987c0cae82e08c2ca1a8fb466a510185a12cf7af2c0b1115
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: cc6380613f57613b0d9920ce53caaa7149afe2e67ca6da7f0abd84912d76bb1c
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 9f00a1b9e3061dc4592495957db02af2440f15580a8b84277d1ca809af67648ed7e57fe3c72017b8f1b02eafef5a0520767b17ec959c82f7f6394d72f901f5c0
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: c493f51bf1efd690e035571270860e10ac7aca0a020e60e58c501b5ba9ee5d99eb447076683d0409183cf02b4b9e57ee3088ec52e7a15b23a2af5ed46cd6b362
         
     | 
    
        data/lib/meshtastic/mqtt.rb
    CHANGED
    
    | 
         @@ -278,29 +278,22 @@ module Meshtastic 
     | 
|
| 
       278 
278 
     | 
    
         
             
                  opts[:via] = :mqtt
         
     | 
| 
       279 
279 
     | 
    
         | 
| 
       280 
280 
     | 
    
         
             
                  # TODO: Implement chunked message to deal with large messages
         
     | 
| 
       281 
     | 
    
         
            -
                   
     | 
| 
      
 281 
     | 
    
         
            +
                  text = opts[:text].to_s
         
     | 
| 
       282 
282 
     | 
    
         
             
                  max_bytes = 233
         
     | 
| 
       283 
283 
     | 
    
         
             
                  mui = Meshtastic::MeshInterface.new
         
     | 
| 
       284 
284 
     | 
    
         | 
| 
       285 
     | 
    
         
            -
                  if  
     | 
| 
       286 
     | 
    
         
            -
                     
     | 
| 
       287 
     | 
    
         
            -
                     
     | 
| 
       288 
     | 
    
         
            -
             
     | 
| 
       289 
     | 
    
         
            -
                       
     | 
| 
       290 
     | 
    
         
            -
             
     | 
| 
       291 
     | 
    
         
            -
             
     | 
| 
       292 
     | 
    
         
            -
                       
     | 
| 
       293 
     | 
    
         
            -
             
     | 
| 
       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|
         
     | 
| 
      
 285 
     | 
    
         
            +
                  if text.bytesize > max_bytes
         
     | 
| 
      
 286 
     | 
    
         
            +
                    total_chunks = (text.bytesize.to_f / max_bytes).ceil
         
     | 
| 
      
 287 
     | 
    
         
            +
                    total_chunks.times do |i|
         
     | 
| 
      
 288 
     | 
    
         
            +
                      chunk_num = i + 1
         
     | 
| 
      
 289 
     | 
    
         
            +
                      chunk_prefix = "(#{chunk_num} of #{total_chunks})"
         
     | 
| 
      
 290 
     | 
    
         
            +
                      chunk_prefix_len = chunk_prefix.bytesize
         
     | 
| 
      
 291 
     | 
    
         
            +
                      start_index = i * (max_bytes - chunk_prefix_len)
         
     | 
| 
      
 292 
     | 
    
         
            +
                      end_index = (start_index + (max_bytes - chunk_prefix_len)) - 1
         
     | 
| 
      
 293 
     | 
    
         
            +
                      chunk = "#{chunk_prefix} #{text.byteslice(start_index..end_index)}"
         
     | 
| 
       300 
294 
     | 
    
         
             
                      opts[:text] = chunk
         
     | 
| 
       301 
     | 
    
         
            -
                      opts[:text] = "[#{index + 1}/#{total_chunks}] #{chunk}"
         
     | 
| 
       302 
295 
     | 
    
         
             
                      protobuf_chunk = mui.send_text(opts)
         
     | 
| 
       303 
     | 
    
         
            -
                       
     | 
| 
      
 296 
     | 
    
         
            +
                      mqtt_obj.publish(absolute_topic, protobuf_chunk)
         
     | 
| 
       304 
297 
     | 
    
         
             
                    end
         
     | 
| 
       305 
298 
     | 
    
         
             
                  else
         
     | 
| 
       306 
299 
     | 
    
         
             
                    protobuf_text = mui.send_text(opts)
         
     | 
    
        data/lib/meshtastic/version.rb
    CHANGED