meshtastic 0.0.132 → 0.0.133
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: dd7da546fac5be533cc4420c830da4514bf10c5dd48577abfd54cf912d0af58e
         | 
| 4 | 
            +
              data.tar.gz: 583508248f892029b83b21663e3666dff7bae1a034c085eaa67616c6834d4ef1
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: e689b2141774914914ef4895867a5cc7e197cdf63ee0f282fbbcf5b1fcabf917167de1a81fccbbb865e4c35082f154dd4b3957769d0d601dd8388925f4b85ea7
         | 
| 7 | 
            +
              data.tar.gz: af9a806f6fdf54668c1391ad46865a8590bfe4d8bb47829fafc7232eae7413dd470f506c1deffd25f4f08fa9dede9cd298d97a9a963c3e76cc5e031c6ca1c309
         | 
    
        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 = 233
         | 
| 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