This function configures the specified port.

Syntax

int SetConfig(
  const unsigned int com_port, 
  void *setting
);

Parameters

com_port
[in] Specify the port number for configuration settings.
ValueDescription
COM3 Bluetooth SPP (Master)
COM4 Bluetooth HID (Slave)
COM5 Bluetooth SPP (Slave)
It does not support the acquisition of other COM port settings.
setting
[in]A pointer to the setconfig_comapi structure.
The structure that stores the settings depends on the communication type.

Return value

The function returns a successful setting (OK) or a failure (ERROR).
ValueDescription
OK Setting succeeded.
ERROR Setting failed.

Remarks

Make sure that the port is closed when using this function.
If it is open, the set value will be reflected at the next opening even if it is set by this function.
Since Bluetooth uses a common configuration area, all COM3, COM4, and COM5 settings will be updated if specified.

Requirements

Header file:
lib.h
Library file:
libSTARTUPOPH5000.a

Sample

#include <stdio.h>
#include "lib.h"

void main( void )
{
    int ch;
    setconfig_comapi config;

    SetDefault( COM5 );
    GetConfig( COM5, (void *)&config );
    config.blt.encryption = 1;
    SetConfig( COM5, (void *)&config );

    ComOpen( COM5 );    // Open the COM port
    for(;;)
    {
        if( (ch = GetCom( 0 )) != -1)
        {
            putchar( ch );
            PutCom( ch );
        }
        if( (ch = getchar()) != EOF)
        {
            putchar( ch );
            PutCom( ch );
        }
        Idle();    // Very important to lower the power consumption
    }
}

Last updated: 2020/10/07