B9X Voice Client SDK For Windows

The B9X Voice Client Library For Windows works seamlessly with the Xojo development environment. Just load the provided example project and compile. The B9X Voice Client SDK For Windows includes a DLL and Xojo Module. These are both free of charge and distributable. There are no royalties when used with any purchased version of B9X Voice Server(TM).

To add to your own project you simply include the provided dll next to the xojo project file in the project directory. You add the modVoice module Xojo module to your project by using copy and paste on this module. The below methods can then be called. You can right click the Windows icon in your project and add a ‘Build Setting|Build Step|Copy Files’ and drag the dllvoip.dll file to this window. Click again on the Windows icon and be sure to set the destination to AppParent folder. This way the dll will be copied to the build exe folder when you build your app. The Windows archetitecture should additionally be set to ‘x86 32-bit’. Be sure to additionally set the IP, of the PC running the B9X Voice Server(TM), in the example project.

You can load the sample application, that is a fully functional client, that can be executed on your Windows PC. With 2 PCs and/ or Phones connected to our server, the 2 devices can communicate with each other. If more devices are connected, they can additionally communicate with the group.

The description of the DLL library’s methods and subs are described below. The ‘Additional Methods’ section are only provided if communicating with one or more B9X Radios:

xSetkey(ByVal key As CString) as Integer – This method sets the key for encryption of the connection to the server.
Parameters:

  • key – This key is required, must be exactly 32 bytes long, and must be identical to the key set at the server.

Returns: none

xClearKey as Integer – This method clears the key. The DLL will not be able to connect to the server if the key is cleared.
Parameters:
None.

Returns: none

xConnect(ByVal hst as CString, ByVal port as integer, ByVal srcPort as integer, ByVal pw as CString) As Integer- This method connects to the B9X Voice Server(TM). Once connected to the server, real time audio chat with other clients can take place.
Parameters:

  • hst – the the host or ip address of the Windows machine running B9X Voice Server(TM)
  • port – the port number of the instance of B9X Voice Server(TM)
  • srcPort – the port number this app is listening on.
  • pw – The password is required. The server has two passwords to set. The Admin Password, at the server, allows for both voice chat and broadcast messages. The Password, at the server, allows only voice chat.

Returns: “[CONNECT_OK]” – a successful connection was established with the server. This value is returned by calling xGetMsg.

xClose As Integer – This method closes the previous xConnect to the B9X Voice Server(TM). Once vClose is called, real time audio chat with other stops.
Parameters: none

Returns: “[CLOSE_OK]” – a current connection, with the server, is now closed. This value is returned by calling xGetMsg.

xBroadcast(ByVal msg as CString) As Integer – This method will send text to the server and any of its connected clients. You must have previously connected to the server with the Admin Password that was set at the server.
Parameters:

  • msg – this method will send text to the server and any of its connected clients. You must have previously connected to the server with the Admin Password that was set at the server.

Returns: “[BCAST_OK]” – the text provided in msg was successfully sent to server and broadcasted to server connected clients. This value is returned by calling xGetMsg.

xStartListening(listenPort as integer, deviceID as integer, samplesPerSecond as integer, channels as integer, bitsPerSample as integer) As Integer – This method sets the port number that your app will listen on. This port will receive the audio and broadcast messages from the server.
Parameters:

  • listenPort – The port number this client will listen on and sets the audio format of sent audio and received audio. This port number must be unique and cannot be a reserved or well established UDP ports. This port cannot be the same as the port set at the server.
  • deviceID – the soundcard’s device number.Set to zero for the default sound card
  • samplesPerSecond – at this time, 11025 samples per second is the only supported sample rate available.
  • channels – at this time, 2 channels is the only supported channels available.
  • bitsPerSample – at this time, 16 bits is the only supported sample size available.

Returns:

When audio arrives:

“[VOICE_RECEIVE_ON][ip][port]” – voice audio was received from the server, at the server’s ip and port(from any of the connected clients at the server).
“[VOICE_RECEIVE_OFF]” – receiving voice audio stopped.
These values are returned by calling xGetMsg.

xStopListening As Integer – This method will stop your app from listening for audio and status messages.
Parameters: none

Returns: none.

xStartSending As Integer – This method will stop sending audio to the server and any connected clients at the server.
Parameters: none

Returns: “[START_SENDING]” – the xStartSending method was invoked. This value is returned by calling xGetMsg.

xStopSending As Integer – This method will stop sending audio to the server and any connected clients at the server. At some point, xStopSending must be called otherwise audio from the PC’s mic audio will continue to be sent to the server and its connected clients.
Parameters: none

Returns: “[STOP_SENDING]” – the xStopSending method was invoked. This value is returned by calling xGetMsg.

xGetNthField(findex as integer, evtData as string) As String – This method will return the nth field of a string with square bracketed delimited data.
Parameters:
fIndex – the field number. Starts at 1.
evtData – the string to search.

Returns:

Example: A string such as s=[VOICE_RECEIVE_ON][192.168.1.1][20000]
a=xGetNthField(2, s) will return a string value for ‘a’ of “192.168.1.1”

xMsgReady As Integer – returns 1 if a message is waiting or 0 if there are no messages waiting.

xGetMsg(msg As Ptr) As Integer – this method will retrieve the oldest pending message. The message received will have square bracketed delimited data or less than/greater than brackets.
Example(this method can be called in a timer’s action event where Action event occurs about every 100ms or more):

Var msg as new memoryblock(256)
Var s as string

If xIsMsgReady() = 1 Then
  Call xGetMsg(msg)
  s=msg.CString(0)
  lstevents.AddRow(s)
End If


Parameters:
msg – a memory block to fill with the retrieved message.
Additional messages not defined above are:

“[VOX_TRIGGER_ON]” – the voice from the mic was triggered.
“[VOX_TRIGGER_OFF]” – the voice from the mic stopped.
“[PING]” – this string is sent periodically by the server to this client indicating an active connection to the server.

<SQUELCH_ON><nodeName of radio><signal level> – squelch open on radio with identifier nodeName.
<SQUELCH_OFF><nodeName of radio> – squelch closed on radio with identifier nodeName.
<DTMF_DIGITS><nodeName of radio><digits received> – dtmf digits received on radio with identifier nodeName.

Additional Methods

xGetSMeter(nodeName as String) – This method will retrieve the signal strength of any signals received on B9XRadio that has nodeName as its identifier.

Returns: <GETSMETER_OK><nodeName of radio><signal level> This value is returned by calling xGetMsg.

xSetChannel(nodeName As String, channel As String) – This method sets the channel of the B9XRadio with the provided nodeName. Channels are defined in the channels.txt file that can be found on the sdcard’s top level directory. The sdcard is found on B9XRadio’s sdcard slot.

Returns: <SETCHANNEL_OK><nodeName of radio> This value is returned by calling xGetMsg.

xSetRadio(nodeName As String, bandWidth as integer, txFreq as double, rxFreq as double, txCTCSS as double, squelch as integer, rxCTCSS as double) – This method sets the B9XRadio’s frequency and other operating parameters of the B9XRadio with the provided nodeName. These values are defined as:

  • bandwidth – 0 sets 12.5khz and 1 sets 25khz
  • transmitFreq – the B9XRadio’s frequency to transmit on. A value of 425.4 is 425.4 Mhz
  • receiveFreq – the B9XRadio’s frequency to receive on. A value of 425.4 is 425.4 Mhz
  • txCTCSS – the B9XRadio’s CTCSS tone(any standard tone) to include when transmitting.
  • squelch – the squelch level. Can be a value of 1 to 8. 0 value opens the squelch where you hear channel noise.
  • rxCTCSS – the B9XRadio’s CTCSS tone(any standard tone) to open the squelch when receiving.

Returns: <SETRADIO_OK><nodeName of radio> This value is returned by calling xGetMsg.

xStartPlay(nodeName as String) – This method will initialize the transmitting of .wav files from B9XRadio’s sdcard that has nodeName as its identifier.

Returns: <TTSSTART_OK><nodeName> of radio> This value is returned by calling xGetMsg.

xAddFileToPlay(nodeName as String, fname as string) – This method will queue a wav file to transmit from B9XRadio’s sdcard that has nodeName as its identifier and fname as wav file. The fname uses the 8×3 convention like “xxxxxxxx.wav”. Files found in top level directory do not require a drive or path name, like xxxxxxxx.wav. If they are in a directory like myfiles, you specify the string as “myfiles/xxxxxxxx.wav”.

Returns: <TTSADDFILE_OK><nodeName of radio> This value is returned by calling xGetMsg.

xAddNumberToPlay(nodeName as String, num as double) – This method will queue a number, num, to transmit over the B9XRadio that has nodeName as its identifier.

Returns: <TTSADDFILE_OK><nodeName of radio> This value is returned by calling xGetMsg.

xAddCharactersToPlay(nodeName as String, chs as string) – This method will queue a string of characters, chs to transmit over the B9XRadio that has nodeName as its identifier. Valid characters are ‘a’ to ‘z’ and ‘0’ to ‘9’. Spaces can be added to introduce a pause in playing.

Returns: <TTSADDCHARACTERS_OK><nodeName of radio> This value is returned by calling xGetMsg.

xPlayAll(nodeName as String) – This method will key the transmitter, play any files or values previously queued, and then un-key the transmitter. over the B9XRadio that has nodeName as its identifier.

Returns: <TTSPLAYALL_OK><nodeName of radio> This value is returned by calling xGetMsg.

References And Disclaimer

B9X Electronics

Website: https://b9xelectronics.com

B9X Voice Server™ and B9X Voice Client™ are trademarks of B9X Electronics.

Windows™ is a trademark of Microsoft Corporation.

Android™ and Google™ are trademarks of Google.

Yaesu™ and products mentioned are trademarks of Yaesu/Vertex Standard.

Icom™ and products mentioned are trademarks of Icom.

All other references are trademarks and copyrights of their respective holders.

The specifications in this document are only given to provide information, without any guarantee in regards to either mistakes or omissions. B9X Electronics reserves the right to make changes to the products contained in this publication for any reason.

IN NO EVENT WILL B9X ELECTRONICS BE LIABLE TO YOU OR ANYONE FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO INJURY TO PERSON OR PRODUCT, LOST PROFITS, LEGAL COSTS, LOST SAVINGS, OR OTHER INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THIS AND ANY OF OUR PRODUCTS.