Modbus function WRITE_MULTIPLE_COILS (0x0F)

        :param bits_addr: bits address (0 to 65535)
        :type bits_addr: int
        :param bits_value: bits values to write
        :type bits_value: list
        :returns: True if write ok or None if fail
        :rtype: bool or None

def write_multiple_coils(self, bits_addr, bits_value):
        """Modbus function WRITE_MULTIPLE_COILS (0x0F)

        :param bits_addr: bits address (0 to 65535)
        :type bits_addr: int
        :param bits_value: bits values to write
        :type bits_value: list
        :returns: True if write ok or None if fail
        :rtype: bool or None
        """
        # number of bits to write
        bits_nb = len(bits_value)
        # check params
        if not (0x0000 <= int(bits_addr) <= 0xffff):
            self.__debug_msg('write_multiple_coils(): bits_addr out of range')
            return None
        if not (0x0001 <= int(bits_nb) <= 0x07b0):
            self.__debug_msg('write_multiple_coils(): number of bits out of range')
            return None
        if (int(bits_addr) + int(bits_nb)) > 0x10000:
            self.__debug_msg('write_multiple_coils(): write after ad 65535')
            return None
        # build frame
        # format bits value string
        bits_val_str = b''
        # allocate bytes list
        b_size = int(bits_nb / 8)
        b_size += 1 if (bits_nb % 8) else 0
        bytes_l = [0] * b_size
        # populate bytes list with bits_value
        for i, item in enumerate(bits_value):
            if item:
                byte_i = int(i/8)
                bytes_l[byte_i] = set_bit(bytes_l[byte_i], i % 8)
        # format bits_val_str
        for byte in bytes_l:
            bits_val_str += struct.pack('B', byte)
        bytes_nb = len(bits_val_str)
        # format modbus frame body
        body = struct.pack('>HHB', bits_addr, bits_nb, bytes_nb) + bits_val_str
        tx_buffer = self._mbus_frame(const.WRITE_MULTIPLE_COILS, body)
        # send request
        s_send = self._send_mbus(tx_buffer)
        # check error
        if not s_send:
            return None
        # receive
        f_body = self._recv_mbus()
        # check error
        if not f_body:
            return None
        # check fix frame size
        if len(f_body) != 4:
            self.__last_error = const.MB_RECV_ERR
            self.__debug_msg('write_multiple_coils(): rx frame size error')
            self.close()
            return None
        # register extract
        (rx_bit_addr, rx_bit_nb) = struct.unpack('>HH', f_body[:4])
        # check regs write
        is_ok = (rx_bit_addr == bits_addr)
        return True if is_ok else None