phone

    • chevron_right

      Erlang Solutions: Elixir, 7 steps to start your journey

      news.movim.eu / PlanetJabber • 9 February, 2023 • 3 minutes

    Read this post in Spanish .

    Let’s talk about Elixir!

    Elixir is a functional programming language created by José Valim to build concurrent and scalable systems. It is defined as:

    “a dynamic, functional language for building scalable and maintainable applications”.

    https://elixir-lang.org/

    Its first version was released in 2012. Since then, new features and improvements have been added until its current version . It is a relatively young programming language that has established itself quickly due to its nice syntax and short learning curve. Also, it is supported by a technology that has been working since the eighties in production systems, the BEAM.

    Elixir runs on the BEAM, Erlang’s virtual machine.

    In a later blog post, we’ll go into more detail about the virtual machine. For now, I want to mention a few features that make the BEAM a solid technology and a fantastic choice for system development. For example:

    • It simultaneously supports millions of users and transactions.
    • It has a mechanism to detect failures and define strategies that allow a system to recover from them.
    • It has all the necessary elements to develop a system capable of operating without interruptions or, failing that, with the minimum of them.
    • It allows system updates in real-time without stopping and in an “invisible” way for end users.

    Elixir inherits all these properties from BEAM. Adding to it that-the language has a very nice syntax, it is easy to learn, there are many resources (blogs, podcasts, etc), and the community is very friendly. So creating a project from scratch to start practicing requires very little time and effort.

    I was introduced to Elixir by chance in 2018. The project I learned it with made me suffer a bit because it was a different experience than what I was used to until then. But once I got into the rhythm, it became pretty enjoyable. Sometime last year, I wondered what would have happened if I hadn’t discovered it by coincidence.

    Would Elixir have caught my attention on its own? Is it a recommended option for someone learning to program? Do you require previous experience?

    So I posted a tweet asking other developers:

    Here are some answers :

    It is not easy to reach a definitive conclusion since choosing this language, as the first option will depend on the tastes and experiences of the individual. Some of its advantages are mentioned in the tweet replies, which motivated me to write this series.

    Without further ado, I welcome you to the series Elixir, 7 steps to start your journey.

    Throughout seven chapters, we’ll talk a bit about history, relevant technical aspects and delve into why Elixir has quickly gained popularity. I will also tell you a little about my experience in the projects in which I have participated.

    What topics will it cover?

    1. Erlang’s virtual machine, the BEAM
    2. Understanding processes and concurrency
    3. Libraries and frameworks
    4. Testing and debugging
    5. The Elixir Community
    6. Functional Programming vs. Object-Oriented Programming
    7. My first project with Elixir!

    Who is this series for?

    • People with no experience in any programming language looking for an option to explore.
    • People with previous experience in other programming languages who want to experiment with Elixir.

    Difficulty level: Beginner

    Elixir official documentation:

    In each chapter, I’ll share resources to dig deeper into the topics. You can find me on Twitter as @loreniuxmr to clarify questions or continue the conversation. You can also use the hashtags #MyElixirStatus and #Elixirlang  to find other Elixir developers.

    The next post will be about Erlang’s virtual machine, the BEAM, and why it is so relevant when it comes to Elixir. See you!

    The post Elixir, 7 steps to start your journey appeared first on Erlang Solutions .

    • chevron_right

      Erlang Solutions: Elixir, 7 pasos para iniciar tu viaje

      news.movim.eu / PlanetJabber • 9 February, 2023 • 3 minutes

    ¡Hablemos de Elixir!

    Elixir es un lenguaje de programación funcional creado por José Valim para construi sistemas concurrentes y escalables.

    “a dynamic, functional language for building scalable and maintainable applications”.

    https://elixir-lang.org/

    Su primera versión fue liberada en 2012. Desde entonces, se le han agregado nuevas funcionalidades y mejoras hasta llegar a su versión actual . Se trata de un lenguaje de programación relativamente joven, pero bien establecido y que ha ganado aceptación rápidamente gracias su sintaxis agradable y una curva de aprendizaje corta. Elixir está respaldado por una tecnología que ha estado en funcionamiento en sistemas reales desde los años ochenta, la BEAM.

    Elixir corre sobre la máquina virtual de Erlang, la BEAM.

    Más adelante entraremos en más detalles y hablaremos de la máquina virtual. Por ahora me gustaría mencionar algunas características que hacen de la BEAM una tecnología sólida y una gran opción para el desarrollo de sistemas. Por ejemplo:

    • Soporta simultáneamente millones de usuarios y transacciones .
    • Tiene un mecanismo para detectar fallos y te permite definir estrategias para recuperarse de ellos.
    • Te brinda todos los elementos necesarios para desarrollar sistemas capaces de operar sin interrupciones o, en su defecto, con el mínimo de ellas.
    • Permite hacer actualizaciones de un sistema en tiempo real sin detenerlo, y de manera “invisible” para los usuarios finales.

    Elixir hereda todas estas propiedades de la BEAM. Y a eso le sumamos que el lenguaje tiene una sintaxis bastante agradable, es fácil de aprender, existen muchos recursos (blogs, podcasts, etc) y la comunidad es increíble. Así que crear un proyecto desde cero para practicar y aprender require de muy poco tiempo y esfuerzo.

    Conocí Elixir por casualidad en 2018. El proyecto con el que lo aprendí me hizo sufrir un poco, porque se trataba de un lenguaje totalmente diferente a los que había conocido hasta ese entonces (orientados a objetos) pero mi experiencia una vez que descubrí todo lo que había se volvió muy disfrutable. En algún momento del año pasado me pregunté qué hubiera pasado de no haberlo descubierto por coincidencia.

    ¿Me hubiera llamado la atención en algún momento? ¿Es una opción recomendada para alguien que está aprendiendo programación? ¿Requiere experiencia previa?

    Así que le pregunté en Twitter a otros desarrolladores :

    A continuación algunas respuestas:

    Es difícil llegar a una conclusión definitiva, pues escoger este lenguaje como primera opción o no dependerá de los gustos y la experiencia de cada quien. Algunas de las respuestas hablan acerca de las ventajas de este lenguaje de programación y fueron la razón que me motivo a escribir esta serie.

    Así que sin más que decir, bienvenido a Elixir, 7 pasos para iniciar tu viaje.

    A lo largo de siete capítulos hablaremos un poco acerca de su historia, aspectos técnicos relevantes y por qué ha ganado popularidad rápidamente. También te contaré cómo ha sido mi experiencia en los proyectos en los que he participado.

    ¿Qué temas cubrirá?

    1. La máquina virtual de Erlang, la BEAM
    2. Entendiendo procesos y concurrencia
    3. Bibliotecas y frameworks
    4. Pruebas y debugging
    5. La comunidad de Elixir
    6. Programación funcional vs Programación orientada a objetos
    7. ¡Mi primer proyecto con Elixir!

    ¿A quién está dirigida esta serie?

    • Personas sin experiencia en ningún lenguaje de programación que están en busca de su primera opción para explorar.
    • Personas con experiencia previa en otros lenguajes de programación que quieran experimentar con Elixir.

    Nivel de dificultad: Principantes.

    Documentación oficial de Elixir:

    En cada capítulo te compartiré recursos para profundizar los temas. Puedes encontrarme en Twitter como @loreniuxmr para aclarar cualquier duda o seguir con la conversación. Y también puedes utilizar los siguientes hashtags para conectar con otros desarrolladores: #MyElixirStatus y #Elixirlang

    En la próxima nota hablaremos de la máquina virtual de Erlang, la BEAM y por qué es tan relevante cuando hablamos de Elixir. ¡Nos vemos!

    The post Elixir, 7 pasos para iniciar tu viaje appeared first on Erlang Solutions .

    • chevron_right

      Dino: Dino 0.4 Release

      news.movim.eu / PlanetJabber • 7 February, 2023 • 2 minutes

    Dino is a secure and open-source messaging application. It uses the XMPP (Jabber) protocol for decentralized communication. We aim to provide an intuitive and enjoyable user interface.

    The 0.4 release adds support for message reactions and replies. We also switched from GTK3 to GTK4 and make use of libadwaita now.

    Reactions and Replies

    reaction.png

    Reactions give you a quick and light-weight way to respond to a message with an emoji. They can be used to express agreement or disagreement 👍️👎️, for voting, to express a feeling 🥳🤯, and much more 🦕. You can react with any emoji you want and with as many as you want!

    The new Dino release also adds another way for you to interact with messages: Replies. The original message is displayed alongside the reply, and you can click on it to jump up to the original message.

    message_menu.png

    You can add a reaction or reply to a message via the message menu. To access the message menu, hover the message or tap it on touch-screens.

    Screenshot of a reply

    Reactions and replies are always possible in direct conversations. In group chats and channels, the admin decides whether to support the features.

    GTK4 and libadwaita

    Dino now uses GTK4 instead of GTK3 to display its user interface. To the outside there are no big UI changes. However, we can now make use of new or improved GTK features.

    Furthermore, we started using libadwaita, which contains specialized Widgets and provides tools to build mobile-friendly UIs. We already adjusted Dino’s main view for usage on mobile devices.

    Ilulissat

    Glaciers are fascinating landscapes of flowing ice. We named this Dino release “Ilulissat” after a glacier in Greenland to help spread information on the effects of global warming on glaciers.

    Glaciers are created over a span of centuries from fallen snow that compacts and transforms into glacial ice. When the ice reaches a certain thickness, it starts to behave like a liquid. Thus, glaciers are in constant movement, driven downhill by gravity under their own weight.

    Satellite view of the Ilulissat glacier and icefjord

    Satellite view of the Ilulissat glacier and icefjord

    Very large glaciers, also known as ice sheets, exist on Antarctica and Greenland. Greenland’s ice sheet covers about 80% of the island and has an average thickness of 1,5 km.

    The Greenland Ice Sheet, like all glaciers, is constantly in motion. It accumulates ice in the interior of the island and flows outwards, eventually reaching the ocean through so-called outlet glaciers. One such outlet glacier is the Ilulissat glacier in West Greenland, the fastest draining outlet of the Greenland Ice Sheet with a flow speed of over 20 meters per day.

    Unfortunately, the Greenland Ice Sheet has been shrinking for past 26 years [ 1 ]. Rising water and air temperatures are causing outlet glaciers to melt at an accelerating pace, draining the ice sheet more quickly and resulting in increased sea levels [ 2 ]. Between 1992 and 2020, meltwater from the Greenland Ice Sheet alone increased global sea levels by over 1,3 cm, where every centimeter of sea level rise is estimated to expose 6 Million people to coastal flooding [ 3 ].

    • wifi_tethering open_in_new

      This post is public

      dino.im /blog/2023/02/dino-0.4-release/

    • chevron_right

      Isode: Icon-5066 3.0 – New Capabilities

      news.movim.eu / PlanetJabber • 2 February, 2023 • 2 minutes

    We are thrilled to announce the latest update to our STANAG 5066 server, Icon-5066. With this new release, we’ve incorporated a host of exciting features and enhancements, designed to not only add new functionality to your deployment but also increase the performance of your HF Radio Network.

    The below is a list of the changes, and updates that can be found within Icon-5066 v3.0.

    ALE Management

    This major new feature enables management of ALE configuration independent of ALE implementation and allows easy sharing of configuration between nodes.  This capability is supported for modems where Isode provides ALE support.  Key features:

    • Web configuration of HF Network for each Icon-5066 node.
    • Configuration of Node ALE addressing, with support for 2G, 3G and 4G.
    • Support for fixed frequency (not using ALE for a network)
    • Configuration of HF Frequency list with options for narrowband and wideband
    • Configuration of schedules for used with ALE or fixed frequency.   This enables the frequencies used to be changed at configured times so that appropriate frequencies are used for an ALE network throughout the 24 hour cycle.
    • Import/Export of configuration, to enable easy sharing of configuration between nodes.   Model is that you configure ALE setup on one node and the transfer to other nodes.

    Security

    Two important security enhancements are included:

    1. Use of OAuth to control which operators can access Icon-5066.
    2. Support of TLS which includes:
      1. HTTPS Web Access
      2. TLS Support for GCXP to support Modem Proxy (crypto bypass) across a Red/Black boundary
      3. Web configuration of PKI setup of TLS

    STANAG 5066 Ed4 Compliance

    Icon-5066 is compliant to STANAG 5066 Ed4.   An overview of Ed4 is here .   Detailed Icon-5066 compliance is specified here .

    Most of these capabilities were in the previous release, but described as STANAG 5066 proposed extensions.   Interoperability has been tested with another Ed4 implementation.

    SNR Monitor

    A new option is provided to configure Icon-5066 as a modem monitor with a simple TCP monitoring protocol.  This is a general purpose capability, but is specifically targeted to support the ACP 127 FAB (Frequency Assignment Broadcast) capability in M-Switch to enable the FAB broadcast to report on measured link quality using a modem at a remote location.

    New Modem/ALE Support

    The following ALE capabilities are added:

    • 3G ALE support for RapidM RM8 and RM10.
    • 4G ALE support for RapidM RM10

    A new “Raw TCP” data option, which sends and receives data over simple TCP connection.   This generic capability can be used to exchange data with RapidM RM10 modem.

    Management

    Support for independent control of multiple STANAG 5066 nodes, so that on a system with multiple nodes nodes can be independently enabled and disabled by the Icon-5066 operator.

    Red/Black Driver

    A driver is provided for Isode’s Red/Black product to monitor Icon-5066.   Like the Red/Black driver for Isode supported Modems, this driver is distributed with Icon-5066, but will be picked up by a collocated Red/Black server.   It enables a Red/Black operator to enable/disable an Icon-5066 node and to monitor key parameters.

    Product Activation

    Icon-5066 servers are now controlled by Isode Product Activation.  This control includes:

    • Optional enabling of TLS.  This is helpful for export.
    • Control of the number of nodes available

    • wifi_tethering open_in_new

      This post is public

      www.isode.com /company/wordpress/icon-5066-3-0-new-capabilities/

    • chevron_right

      JMP: Newsletter: Threads, Thumbnails, XMR, ETH

      news.movim.eu / PlanetJabber • 23 January, 2023 • 2 minutes

    Hi everyone!

    Welcome to the latest edition of your pseudo-monthly JMP update!

    In case it’s been a while since you checked out JMP, here’s a refresher: JMP lets you send and receive text and picture messages (and calls) through a real phone number right from your computer, tablet, phone, or anything else that has a Jabber client.  Among other things, JMP has these features: Your phone number on every device; Multiple phone numbers, one app; Free as in Freedom; Share one number with multiple people.

    This month we released Cheogram Android 2.12.1-1 which includes several new features.  One of the big ones is an interface for having threaded conversations with other Jabber users ( watch the demo video ).  This feature will also make it easier to reply to the right message if you use the email gateway .  The app has grown support for more media features, including an ability to show an image right away if you already have it, without waiting for a download, and blurhash based placeholders for images from MMS you have not yet downloaded.

    There is also a new user experience when receiving group texts that will actually show the sender’s name (and even avatar, if you have one set for them locally) the same way as any other group chat in the app.  This is made possible by a new draft protocol extension we adopted for part of the purpose.

    This version is based on the latest 2.12.1 from upstream, which among other things has added the ability to function as a Unified Push distributor , so if you use any compatible app you may want to check that out.

    For the JMP service, this month we shipped the ability to make top-up payments using XMR or ETH directly from the top up command.  This simplifies the flow for users of those currencies, and we hope you will find it useful.  Integrating this support into registration is also coming, but not ready quite yet.

    If you are planning to be at FOSDEM 2023 , be sure to check out the realtime lounge in with the other stands.  Unfortunately no one from JMP will be there this year, but people from Snikket and other projects around the ecosystem will be present.

    To learn what’s happening with JMP between newsletters, here are some ways you can find out:

    Thanks for reading and have a wonderful rest of your week!

    • wifi_tethering open_in_new

      This post is public

      blog.jmp.chat /b/january-newsletter-2023

    • chevron_right

      ProcessOne: ejabberd 23.01

      news.movim.eu / PlanetJabber • 17 January, 2023 • 5 minutes

    Almost three months after the previous release, ejabberd 23.01 includes many bug fixes, several improvements and some new features.

    A new module, mod_mqtt_bridge , can be used to replicate changes to MQTT topics between local and remote servers.

    A more detailed explanation of those topics and other features:

    Erlang/OTP 19.3 discouraged

    Remember that support for Erlang/OTP 19.3 is discouraged, and will be removed in a future release. Please upgrade to Erlang/OTP 20.0 or newer. Check more details in the ejabberd 22.10 release announcement .

    New MQTT bridge

    This new module allows synchronizing topic changes between local and remote servers. It can be configured to replicate local changes to remote server, or can subscribe to topics on remote server and update local copies when they change.

    When connecting to a remote server you can use native or websocket encapsulated protocol, and you can connect using both v4 and v5 protocol. It can authenticate using username/password pairs or with client TLS certificates.

    New Hooks

    Regarding MQTT support, there are several new hooks:

    • mqtt_publish : New hook for MQTT publish event
    • mqtt_subscribe and mqtt_unsubscribe : New hooks for MQTT subscribe & unsubscribe events

    New option log_modules_fully

    The loglevel top-level option specifies the verbosity of log files generated by ejabberd.

    If you want some specific modules to log everything, independently from whatever value you have configured in loglevel , now you can use the new log_modules_fully option.

    For example, if you are investigating some problem in ejabberd_sm and mod_client_state :

    loglevel: warning
    log_modules_fully: [ejabberd_sm, mod_client_state]
    

    (This option works only on systems with Erlang 22 or newer).

    Changes in option outgoing_s2s_families

    The outgoing_s2s_families top-level option specifies which address families to try, in what order.

    The default value has now been changed to try IPv6 first, as servers are within data centers where IPv6 is more commonly enabled (contrary to clients). And if it’s not present, then it’ll just fall back to IPv4.

    By the way, this option is obsolete and irrelevant when using ejabberd 23.01 and Erlang/OTP 22, or newer versions of them.

    Changes in option captcha_cmd

    The captcha_cmd top-level option specifies the full path to a script that can generate a CAPTCHA image. Now this option may specify an Erlang module name, which should implement a function to generate a CAPTCHA image.

    ejabberd does not include any such module, but there are two available in the ejabberd-contrib repository that you can install and try: mod_ecaptcha and mod_captcha_rust .

    DOAP file

    The protocols implemented or supported by ejabberd are defined in the corresponding source code modules since ejabberd 15.06. Until now, only the XEP number and supported version were tracked. Since now, it’s possible to document what ejabberd version first implemented it, the implementation status and an arbitrary comment.

    That information until now was only used by the script tools/check_xep_versions.sh . A new script is added, tools/generate-doap.sh , to generate a DOAP file with that information. A new target is added to Makefile: make doap .

    And that DOAP file is now published as ejabberd.doap in the git repository. That file is read by the XMPP.org website to show ejabberd’s protocols, see XMPP Servers: ejabberd .

    VSCode

    Support for Visual Studio Code and variants is vastly improved. Thanks to the Erlang LS VSCode extension , the ejabberd git repository includes support for developing, compiling and debugging ejabberd with Visual Studio Code, VSCodium, Coder’s code-server and Github Codespaces.

    See more details in the ejabberd Docs: VSCode page.

    ChangeLog

    General

    • Add misc:uri_parse/2 to allow declaring default ports for protocols
    • CAPTCHA: Add support to define module instead of path to script
    • Clustering: Handle mnesia_system_event mnesia_up when other node joins this ( #3842 )
    • ConverseJS: Don’t set i18n option because Converse enforces it instead of browser lang ( #3951 )
    • ConverseJS: Try to redirect access to files mod_conversejs to CDN when there is no local copies
    • ext_mod: compile C files and install them in ejabberd’s priv
    • ext_mod: Support to get module status from Elixir modules
    • make-binaries: reduce log output
    • make-binaries: Bump zlib version to 1.2.13
    • MUC: Don’t store mucsub presence events in offline storage
    • MUC: hibernation_time is not an option worth storing in room state ( #3946 )
    • Multicast: Jid format when multicastc was cached ( #3950 )
    • mysql: Pass ssl options to mysql driver
    • pgsql: Do not set standard_conforming_strings to off ( #3944 )
    • OAuth: Accept jid as a HTTP URL query argument
    • OAuth: Handle when client is not identified
    • PubSub: Expose the pubsub#type field in disco#info query to the node ( #3914 )
    • Translations: Update German translation

    Admin

    • api_permissions : Fix option crash when doesn’t have who: section
    • log_modules_fully : New option to list modules that will log everything
    • outgoing_s2s_families : Changed option’s default to IPv6, and fall back to IPv4
    • Fix bash completion when using Relive or other install methods
    • Fix portability issue with some shells ( #3970 )
    • Allow admin command to subscribe new users to members_only rooms
    • Use alternative split/2 function that works with Erlang/OTP as old as 19.3
    • Silent warning in OTP24 about not specified cacerts in SQL connections
    • Fix compilation warnings with Elixir 1.14

    DOAP

    • Support extended -protocol erlang attribute
    • Add extended RFCs and XEP details to some protocol attributes
    • tools/generate-doap.sh : New script to generate DOAP file, add make doap ( #3915 )
    • ejabberd.doap : New DOAP file describing ejabberd supported protocols

    MQTT

    • Add MQTT bridge module
    • Add support for certificate authentication in MQTT bridge
    • Implement reload in MQTT bridge
    • Add support for websockets to MQTT bridge
    • Recognize ws5/wss5 urls in MQTT bridge
    • mqtt_publish : New hook for MQTT publish event
    • mqtt_(un)subscribe : New hooks for MQTT subscribe & unsubscribe events

    VSCode

    • Improve .devcontainer to use use devcontainer image and .vscode
    • Add .vscode files to instruct VSCode how to run ejabberd
    • Add Erlang LS default configuration
    • Add Elvis default configuration

    Full Changelog

    https://github.com/processone/ejabberd/compare/22.10…23.01

    ejabberd 23.01 download & feedback

    As usual, the release is tagged in the Git source code repository on GitHub .

    The source package and installers are available in ejabberd Downloads page. To check the *.asc signature files, see How to verify ProcessOne downloads integrity .

    For convenience, there are alternative download locations like the ejabberd DEB/RPM Packages Repository and the GitHub Release / Tags .

    The Docker image is in Docker Hub , and there’s an alternative Container image in GitHub Packages .

    If you suspect that you’ve found a bug, please search or fill a bug report on GitHub Issues .

    The post ejabberd 23.01 first appeared on ProcessOne .
    • chevron_right

      Paul Schaub: Use Any SOP Binary With SOP-Java and External-SOP

      news.movim.eu / PlanetJabber • 13 January, 2023 • 1 minute

    The Stateless OpenPGP Protocol specification describes a shared, standardized command line interface for OpenPGP applications. There is a bunch of such binaries available already, among them PGPainless’ pgpainless-cli , Sequoia-PGP’s sqop , as well as ProtonMails gosop . These tools make it easy to use OpenPGP from the command line, as well as from within bash scripts (both pgpainless-cli and sqop are available in Debian testing or the main repo) and the standardized interface allows users to switch from one backend to the other without the need to rewrite their scripts.

    The Java library sop-java provides a set of interface definitions that define a java API that closely mimics the command line interface. These interfaces can be implemented by anyone, such that developers could create a drop-in for sop-java using the OpenPGP library of their choice. One such backend is pgpainless-sop , which implements sop-java using the PGPainless library.

    I just released another library named external-sop , which implements sop-java and allows the user to use any SOP CLI application of their choice from within their Java / Kotlin application!

    Let’s assume we have a SOP command line application called example-sop and we want to make use of it within our Java application. external-sop makes the integration a one-liner:

    SOP sop = new ExternalSOP("/usr/bin/example-sop");

    Now we can use the resulting sop object the same way we would use for example a SOPImpl instance:

    // generate key
    byte[] keyBytes = sop.generateKey()
            .userId("John Doe <john.doe@pgpainless.org>")
            .withKeyPassword("f00b4r")
            .generate()
            .getBytes();
    
    // extract certificate
    byte[] certificateBytes = sop.extractCert()
            .key(keyBytes)
            .getBytes();
    
    byte[] plaintext = "Hello, World!\n".getBytes(); // plaintext
    
    // encrypt and sign a message
    byte[] ciphertext = sop.encrypt()
            // encrypt for each recipient
            .withCert(certificateBytes)
            // Optionally: Sign the message
            .signWith(keyBytes)
            .withKeyPassword("f00b4r") // if signing key is protected
            // provide the plaintext
            .plaintext(plaintext)
            .getBytes();
    
    // decrypt and verify a message
    ByteArrayAndResult<DecryptionResult> bytesAndResult = sop.decrypt()
            .withKey(keyBytes)
            .verifyWithCert(certificateBytes)
            .withKeyPassword("f00b4r") // if decryption key is protected
            .ciphertext(ciphertext)
            .toByteArrayAndResult();
    
    DecryptionResult result = bytesAndResult.getResult();
    byte[] plaintext = bytesAndResult.getBytes();

    The external-sop module will be available on Maven Central in a few hours for you to test.

    Happy Hacking!

    • wifi_tethering open_in_new

      This post is public

      blog.jabberhead.tk /2023/01/13/use-any-sop-binary-with-sop-java-and-external-sop/

    • chevron_right

      Erlang Solutions: Building a Remote Control Car from Scratch Using Elixir

      news.movim.eu / PlanetJabber • 12 January, 2023 • 8 minutes

    Introduction

    Elixir is undoubtedly one of the most comprehensive full stack languages available, offering battle-tested reliability and fault-tolerance on the backend. This is thanks to its origins in Erlang, the BEAM VM and OTP, powerful and agile frontend development thanks to LiveView and the ability to write to hardware with Nerves (not to mention the exciting developments happening in the machine learning space).

    Our Americas office created a project that takes full advantage of that fullstack capability- a remote control car that can be controlled from your phone. It has all the components from the car to the app, controlled and written in Elixir.

    Here’s how they did it.

    Background

    During ElixirConf , we set a Scalextric racetrack at our sponsor booth where people meeting us were able to play around with the race cars. It’s a fun way to encourage people to come to the stand, but we felt that something was missing, there was no connection between the fun we had on the stand and the languages we love (Erlang and Elixir).

    So we thought it would be cool to assemble our own remote car using Elixir. We went ahead and got rid of the cables and the track, which were physical restrictions to the fun we envisioned.

    That’s how the idea was born.

    The initial implementation was for us to gain more knowledge about Nerves and IoT in general. Our approach was to assemble some RaspberryPi with a motor driver and see if we could control the car over WiFi.

    This is when we decided to start a very rough car prototype to see how easy it was to get the whole project running in Elixir.

    Requirements

    We wanted to ensure we only used Elixir / Erlang Ecosystem in our stack:

    • Erlang/OTP 25.1.2

    • Elixir 1.14.2

    You also need the Nerves bootstrap mix archive in order to create the project scaffold and provide deeper integration within mix.

    mix archive.install hex nerves_bootstrap

    Theory

    Let’s first recap some theory and concepts:

    The basic idea is for us to move a pair of wheels. In order to do that, we need a device that is capable of power and can control a couple of motors. We decided to use a L298n motor driver that is easily available in the local electronics stores.

    The L298n is a device that can power up to two motors and is able to control their speed by issuing PWM commands.

    L298N module pinout

    We powered the device using four AA rechargeable batteries that are connected via 12v and GND pins.

    We also needed to know that for moving the wheels, we had to write GPIO commands to IN1, IN2, IN3 and IN4, while controlling the speed via PWM over the pins ENA and ENB (motor A and B respectively).

    At the end of the day, we had this circuit implemented:

    Starting the project

    We started with a blank project and chassis:

    First, we start with a blank Nerves project that will give us the scaffold we need:

    export MIX_TARGET=rpi4
    mix nerves.new jaguar
    

    Before we compiled the project, we added a couple of dependencies that we needed:

    # ...
    {:vintage_net, "~> 0.12", targets: @all_targets},
    {:vintage_net_wifi, "~> 0.11.1", targets: @all_targets},
    {:pigpiox, "~> 0.1", targets: @all_targets},
    # ...
    

    The dependencies above helped us with WiFi connectivity and GPIO / PWM commands.

    2.2 First steps

    Now that we had all dependencies in place we can proceed to compile the project:

    mix do deps.get, compile

    We now needed to focus on how to make the wheels move. At first, you might have to do some scaffolding to test your setup:

    The motors themselves don’t have any polarity, so there is no risk of magic smoke. But keep this in mind in case your wheels spin backwards.

    Now, let’s connect the other components and give it a try.

    Tune in

    After having a working setup, we need to connect to the outside world. We provided a very naive and basic way to connect to the back-end via TCP. But first, we need to make sure our device can connect to the internet at startup.

    Nerves has a third-party library that deals with networking setup and also provides WiFi configuration utilities. There are different ways to set this up but for simplicity, we are going to set the configuration statically in your config/target.exs file:

    config :vintage_net,
      config: [			
    {"wlan0", %{
           type: VintageNetWiFi,
            vintage_net_wifi: %{
    
    					
             networks: [
                %{
    
    					
                 key_mgmt: :wpa_psk,
                  ssid: "my_network_ssid",
                  psk: "a_passphrase_or_psk",
    } ]
    					
    },
    					
           ipv4: %{method: :dhcp}
          }					
    } ] 
    

    For more information about the different configuration options and setup choices, refer to the documentation.

    Once your WiFi connectivity is configured, we need to make sure that we can connect to the back-end via TCP. To do so, just create a new GenServer that connects via :gen_tcp at initialization, pretty much like this:

    ## GenServer callbacks
    @impl true
    def init(opts) do
      backend = Keyword.get(opts, :backend, "localhost") |> to_charlist()
      port = Keyword.get(opts, :port, 5000)
      state = %{socket: nil, backend: backend, port: port}
      {:ok, state, {:continue, :connect}}
    End
    
    @impl true
    def handle_continue(:connect, state) do
      Logger.info("connecting to #{inspect(state.backend)}")
      {:ok, socket} = :gen_tcp.connect(state.backend, state.port, keepalive: true)
      _ref = Port.monitor(socket)
      {:noreply, %{state | socket: socket}}
    end 
    #...
    

    Powering the device

    There is not much to this as we use a standard MakerHawk Raspberry Pi UPS that fits right down the Raspberry Pi. It is powered by two rechargeable 18650 Li-PO batteries. This hat also works as a charging device.

    Moving the wheels

    Moving the wheels is a straightforward process. We only need to take into consideration the PIN layout that we are using for communicating with the motor driver. In this case we are using the following layout:

    IN1 – GPIO 24 (A forward)

    IN2 – GPIO 23 (A backward)

    IN3 – GPIO 17 (B forward)

    IN4 – GPIO 22 (B backward)

    ENA – GPIO 25 (A speed)

    ENB – GPIO 27 (B speed)

    The PIN numbers correspond to the pinout layout for Raspberry Pi 4 model B.

    With the pins wired, we can now issue some commands to prepare the pins for output and set the initial motor speed:

    Enum.map([in1, in2, in3, in4], fn pin ->
      Pigpiox.GPIO.set_mode(pin, :output)
      Pigpiox.GPIO.write(pin, 0) # Stop
    end)
    speed = 250
    Enum.map([ena, enb], fn pin ->
      Pigpiox.GPIO.set_mode(pin, :output)
      Pigpiox.Pwm.gpio_pwm(pin, speed)
    end)
    

    After setup, we can change the speed of the motors on the fly:

    speed = 200
    :ok = Pigpiox.Pwm.gpio_pwm(ena, speed)
    :ok = Pigpiox.Pwm.gpio_pwm(enb, speed)
    

    We can also control the motors to go forwards/backwards:

    # Forwards
    _ = Enum.map([in2, in4], &Pigpiox.GPIO.write(&1, 0))
    _ = Enum.map([in1, in3], &Pigpiox.GPIO.write(&1, 1))
    # Backwards
    _ = Enum.map([in1, in3], &Pigpiox.GPIO.write(&1, 0))
    _ = Enum.map([in2, in4], &Pigpiox.GPIO.write(&1, 1))
    

    wire everything up! The idea is that we used the TCP socket we opened for listening for Erlang binary terms that when decoded, will get translated into steering instructions, that we can then translate to GPIO commands.

    With the base logic drafted, we burned the firmware into the SD card and power up the device:

    MIX_TARGET=rpi4 mix do deps.get, compile, firmware, burn

    Next steps

    Moving on to the next part of the setup. We would need a way for sending commands to the car over the internet.

    In the firmware, we have a simple interface for translating steering commands into GPIO commands. We can export those facilities over our TCP socket:

    		
    		@impl true
    def handle_info({:tcp, _, data}, state) do
    msg = data
        |> :erlang.iolist_to_binary()
        |> :erlang.binary_to_term()
      case msg do
        {:speed, speed} ->
          Vehicle.speed(speed)
        steering when steering in @valid_moves ->
    Vehicle.direction(steering)
      end
      {:noreply, state}
    End
    			

    Keep in mind that we are using a naive approach at communicating with the back-end. A more robust mechanism would be needed if you plan to drive the car in a highway.

    3.1 The back-end

    The back-end is fairly easy and is left as an exercise to the reader. Our current implementation consists of a LiveView car controller, that consists of a couple of buttons for the steering and a slider for the speed. On user input, the LiveView process will encode the information to send it to the connected car via TCP:

    # ...
    def handle_event("speed", %{"value" => speed}, socket) do
      vehicle = socket.assigns.vehicle
      speed = String.to_integer(speed)
      Vehicles.speed(vehicle.pid, speed)
      {:noreply, assign(socket, speed: speed)}
    end
    def handle_event("stop", _params, socket) do
      vehicle = socket.assigns.vehicle
      Vehicles.stop(vehicle.pid)
      {:noreply, assign(socket, stopped: true)}
    end
    def handle_event(direction, _params, socket) do
      vehicle = socket.assigns.vehicle
      case direction do
        "left" -> Vehicles.left(vehicle.pid)
        "right" -> Vehicles.right(vehicle.pid)
        "forward" -> Vehicles.forward(vehicle.pid)
    "backwards" -> Vehicles.backwards(vehicle.pid)
      end
      {:noreply, socket}
    end
    # …
    

    4 Sources and conclusions

    We are now finished! Hopefully everything is put together and, you should have something that reassembles this:

    va

    We had fun assembling the kit and working with Nerves. It was easier than we expected, and we found that Nerves is a very stable and solid frame- work for deploying Elixir applications in restrained environments without friction.

    Now that we finished our first proof of concept, we are going to see if this idea can be scaled and enhanced. Stay tuned for more!

    All the source code is available under MIT licence under GitHub:

    • Jaguar-1 source code

    • Nerves project

    • Erlang Solutions

    Need help making the most of Elixir?

    You’re in the right place. We’ve worked with the world’s biggest companies to provide transformative, mission critical solutions across a range of industries including Fintech, Health Care and Utilities providers. Learn more about our Elixir services here. Or if you’re a developer looking to take your skills to the next level check out our training page.

    The post Building a Remote Control Car from Scratch Using Elixir appeared first on Erlang Solutions .

    • wifi_tethering open_in_new

      This post is public

      www.erlang-solutions.com /blog/building-a-remote-control-car-from-scratch-using-elixir/

    • chevron_right

      Ignite Realtime Blog: Help us translate Spark and Openfire!

      news.movim.eu / PlanetJabber • 24 December, 2022

    We have started to experiment with an online tool that facilitates the process of translating Spark and Openfire. Both already have a bunch of translations, but none are complete.

    I’m looking for people wanting to test the tool and/or provide translations. The aim is to make providing translations become so easy that little technological know-how is required.

    If you’re interested, please sign up to Ignite Realtime localization | Transifex and let me know what you think!

    1 post - 1 participant

    Read full topic