B4R Question Transmitter!?

cloner7801

Active Member
Licensed User
Longtime User
How Can I write a code like this codes in b4r?
B4X:
#include <VirtualWire.h>
void setup()
{
    vw_set_ptt_inverted(true);  // Required by the RF module
    vw_setup(2000);            // bps connection speed
    vw_set_tx_pin(3);         // Arduino pin to connect the receiver data pin
}
void loop()
{
   //Message to send:
   const char *msg = "Hello World";
   vw_send((uint8_t *)msg, strlen(msg));

   vw_wait_tx();        // We wait to finish sending the message
   delay(200);         // We wait to send the message again               
}

I want to create a Transmitter/Receiver like this :
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Currently there is no wrapper available for this library.

You can use inline C code to call it:
B4X:
Sub Process_Globals
   Public Serial1 As Serial
End Sub

Private Sub AppStart
   Serial1.Initialize(115200)
   Log("AppStart")
   RunNative("vw_start", Null)
   SendMessage("hello!")
End Sub

Private Sub SendMessage(msg() As Byte)
   RunNative("vw_send", msg)
End Sub

#if c
#include <VirtualWire.h>
void vw_start(B4R::Object* o) {
  vw_set_ptt_inverted(true);  // Required by the RF module
  vw_setup(2000);  // bps connection speed
  vw_set_tx_pin(3);  // Arduino pin to connect the receiver data pin
}
void vw_send(B4R::Object* msg) {
   B4R::Array* arr = (B4R::Array*)msg->data.PointerField;
   vw_send((Byte*)arr->data, arr->length);
   vw_wait_tx();
}
#end if
 
Upvote 0

cloner7801

Active Member
Licensed User
Longtime User
Currently there is no wrapper available for this library.

You can use inline C code to call it:
B4X:
Sub Process_Globals
   Public Serial1 As Serial
End Sub

Private Sub AppStart
   Serial1.Initialize(115200)
   Log("AppStart")
   RunNative("vw_start", Null)
   SendMessage("hello!")
End Sub

Private Sub SendMessage(msg() As Byte)
   RunNative("vw_send", msg)
End Sub

#if c
#include <VirtualWire.h>
void vw_start(B4R::Object* o) {
  vw_set_ptt_inverted(true);  // Required by the RF module
  vw_setup(2000);  // bps connection speed
  vw_set_tx_pin(3);  // Arduino pin to connect the receiver data pin
}
void vw_send(B4R::Object* msg) {
   B4R::Array* arr = (B4R::Array*)msg->data.PointerField;
   vw_send((Byte*)arr->data, arr->length);
   vw_wait_tx();
}
#end if
I tested it but it doesn't work.
I think data didn't send
 
Upvote 0
Top